diff --git a/go.sum b/go.sum index 49e4c44..e9d153e 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,5 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0 golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -gvisor.dev/gvisor v0.0.0-20220819163037-ba6e795b139a h1:W1h3JsEzYWg7eD4908iHv49p7AOx7JPKsoh/fsxgylM= -gvisor.dev/gvisor v0.0.0-20220819163037-ba6e795b139a/go.mod h1:TIvkJD0sxe8pIob3p6T8IzxXunlp6yfgktvTNp+DGNM= +gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h1:m5lcgWnL3OElQNVyp3qcncItJ2c0sQlSGjYK2+nJTA4= gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c/go.mod h1:TIvkJD0sxe8pIob3p6T8IzxXunlp6yfgktvTNp+DGNM= diff --git a/system.go b/system.go index 4ffda39..b6a0bc5 100644 --- a/system.go +++ b/system.go @@ -51,6 +51,7 @@ func NewSystem(options StackOptions) (Stack, error) { mtu: options.MTU, udpTimeout: options.UDPTimeout, handler: options.Handler, + logger: options.Logger, inet4Prefixes: options.Inet4Address, inet6Prefixes: options.Inet6Address, } @@ -149,11 +150,16 @@ func (s *System) wintunLoop(winTun WinTun) { release() continue } - switch packet[0] >> 4 { + switch ipVersion := packet[0] >> 4; ipVersion { case 4: - s.processIPv4(packet) + err = s.processIPv4(packet) case 6: - s.processIPv6(packet) + err = s.processIPv6(packet) + default: + err = E.New("ip: unknown version: ", ipVersion) + } + if err != nil { + s.logger.Trace(err) } release() }