Skip to content

Commit d0887ea

Browse files
committed
Fix set gateway
1 parent edabb6d commit d0887ea

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tun.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ func (o *Options) Inet4GatewayAddr() netip.Addr {
103103
case "darwin":
104104
return o.Inet4Address[0].Addr()
105105
default:
106-
if HasNextAddress(o.Inet4Address[0], 1) {
107-
return o.Inet4Address[0].Addr().Next()
108-
} else {
109-
return o.Inet4Address[0].Addr()
106+
if !o.InterfaceScope {
107+
if HasNextAddress(o.Inet4Address[0], 1) {
108+
return o.Inet4Address[0].Addr().Next()
109+
} else {
110+
return o.Inet4Address[0].Addr()
111+
}
110112
}
111113
}
112114
}
@@ -127,10 +129,12 @@ func (o *Options) Inet6GatewayAddr() netip.Addr {
127129
case "darwin":
128130
return o.Inet6Address[0].Addr()
129131
default:
130-
if HasNextAddress(o.Inet6Address[0], 1) {
131-
return o.Inet6Address[0].Addr().Next()
132-
} else {
133-
return o.Inet6Address[0].Addr()
132+
if !o.InterfaceScope {
133+
if HasNextAddress(o.Inet6Address[0], 1) {
134+
return o.Inet6Address[0].Addr().Next()
135+
} else {
136+
return o.Inet6Address[0].Addr()
137+
}
134138
}
135139
}
136140
}

0 commit comments

Comments
 (0)