Skip to content

Commit

Permalink
Fix set gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Dec 13, 2024
1 parent edabb6d commit d0887ea
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ func (o *Options) Inet4GatewayAddr() netip.Addr {
case "darwin":
return o.Inet4Address[0].Addr()
default:
if HasNextAddress(o.Inet4Address[0], 1) {
return o.Inet4Address[0].Addr().Next()
} else {
return o.Inet4Address[0].Addr()
if !o.InterfaceScope {
if HasNextAddress(o.Inet4Address[0], 1) {
return o.Inet4Address[0].Addr().Next()
} else {
return o.Inet4Address[0].Addr()
}
}
}
}
Expand All @@ -127,10 +129,12 @@ func (o *Options) Inet6GatewayAddr() netip.Addr {
case "darwin":
return o.Inet6Address[0].Addr()
default:
if HasNextAddress(o.Inet6Address[0], 1) {
return o.Inet6Address[0].Addr().Next()
} else {
return o.Inet6Address[0].Addr()
if !o.InterfaceScope {
if HasNextAddress(o.Inet6Address[0], 1) {
return o.Inet6Address[0].Addr().Next()
} else {
return o.Inet6Address[0].Addr()
}
}
}
}
Expand Down

0 comments on commit d0887ea

Please sign in to comment.