Minor fixes

This commit is contained in:
世界 2022-09-09 19:39:46 +08:00
parent 575ac29417
commit c7dd5d457e
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 10 additions and 5 deletions

View file

@ -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()
}