Fix set gateway

This commit is contained in:
世界 2024-12-12 22:37:13 +08:00
parent edabb6d7ba
commit d0887eabba
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

20
tun.go
View file

@ -103,10 +103,12 @@ func (o *Options) Inet4GatewayAddr() netip.Addr {
case "darwin": case "darwin":
return o.Inet4Address[0].Addr() return o.Inet4Address[0].Addr()
default: default:
if HasNextAddress(o.Inet4Address[0], 1) { if !o.InterfaceScope {
return o.Inet4Address[0].Addr().Next() if HasNextAddress(o.Inet4Address[0], 1) {
} else { return o.Inet4Address[0].Addr().Next()
return o.Inet4Address[0].Addr() } else {
return o.Inet4Address[0].Addr()
}
} }
} }
} }
@ -127,10 +129,12 @@ func (o *Options) Inet6GatewayAddr() netip.Addr {
case "darwin": case "darwin":
return o.Inet6Address[0].Addr() return o.Inet6Address[0].Addr()
default: default:
if HasNextAddress(o.Inet6Address[0], 1) { if !o.InterfaceScope {
return o.Inet6Address[0].Addr().Next() if HasNextAddress(o.Inet6Address[0], 1) {
} else { return o.Inet6Address[0].Addr().Next()
return o.Inet6Address[0].Addr() } else {
return o.Inet6Address[0].Addr()
}
} }
} }
} }