mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
net/interfaces: make syscall and netstat agree when multiple gateways are present
likelyHomeRouterIPDarwinSyscall iterates through the list of routes, looking for a private gateway, returning the first one it finds. likelyHomeRouterIPDarwinExec does the same thing, except that it returns the last one it finds. As a result, when there are multiple gateways, TestLikelyHomeRouterIPSyscallExec fails. (At least, I think that that is what is happening; I am going inferring from observed behavior.) Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
eccc167733
commit
1ebbaaaebb
@ -5,6 +5,7 @@
|
|||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"go4.org/mem"
|
"go4.org/mem"
|
||||||
@ -62,8 +63,12 @@ func likelyHomeRouterIPDarwinExec() (ret netaddr.IP, ok bool) {
|
|||||||
ip, err := netaddr.ParseIP(string(mem.Append(nil, ipm)))
|
ip, err := netaddr.ParseIP(string(mem.Append(nil, ipm)))
|
||||||
if err == nil && isPrivateIP(ip) {
|
if err == nil && isPrivateIP(ip) {
|
||||||
ret = ip
|
ret = ip
|
||||||
|
// We've found what we're looking for.
|
||||||
|
return stopReadingNetstatTable
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return ret, !ret.IsZero()
|
return ret, !ret.IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stopReadingNetstatTable = errors.New("found private gateway")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user