Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 53606a7

Browse files
committedNov 6, 2024
Fix gateway select
1 parent 9ece619 commit 53606a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎tun.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ func (o *Options) Inet4GatewayAddr() netip.Addr {
8989
return o.Inet4Gateway
9090
}
9191
if len(o.Inet4Address) > 0 {
92-
if HasNextAddress(o.Inet4Address[0], 1) {
92+
if runtime.GOOS == "android" {
93+
// avoid "add route 0: network is unreachable"
94+
} else if HasNextAddress(o.Inet4Address[0], 1) {
9395
return o.Inet4Address[0].Addr().Next()
9496
} else if runtime.GOOS != "linux" {
9597
return o.Inet4Address[0].Addr()
@@ -103,7 +105,9 @@ func (o *Options) Inet6GatewayAddr() netip.Addr {
103105
return o.Inet6Gateway
104106
}
105107
if len(o.Inet6Address) > 0 {
106-
if HasNextAddress(o.Inet6Address[0], 1) {
108+
if runtime.GOOS == "android" {
109+
// avoid "add route 0: network is unreachable"
110+
} else if HasNextAddress(o.Inet6Address[0], 1) {
107111
return o.Inet6Address[0].Addr().Next()
108112
} else if runtime.GOOS != "linux" {
109113
return o.Inet6Address[0].Addr()

0 commit comments

Comments
 (0)
Please sign in to comment.