|
|
@ -39,11 +39,14 @@ func Tailscale() (net.IP, *net.Interface, error) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, a := range addrs {
|
|
|
|
for _, a := range addrs {
|
|
|
|
if ipnet, ok := a.(*net.IPNet); ok && IsTailscaleIP(ipnet.IP) {
|
|
|
|
if ipnet, ok := a.(*net.IPNet); ok {
|
|
|
|
|
|
|
|
nip, ok := netaddr.FromStdIP(ipnet.IP)
|
|
|
|
|
|
|
|
if ok && tsaddr.IsTailscaleIP(nip) {
|
|
|
|
return ipnet.IP, &iface, nil
|
|
|
|
return ipnet.IP, &iface, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil, nil, nil
|
|
|
|
return nil, nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -57,13 +60,6 @@ func maybeTailscaleInterfaceName(s string) bool {
|
|
|
|
strings.HasPrefix(s, "utun")
|
|
|
|
strings.HasPrefix(s, "utun")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IsTailscaleIP reports whether ip is an IP in a range used by
|
|
|
|
|
|
|
|
// Tailscale virtual network interfaces.
|
|
|
|
|
|
|
|
func IsTailscaleIP(ip net.IP) bool {
|
|
|
|
|
|
|
|
nip, _ := netaddr.FromStdIP(ip) // TODO: push this up to caller, change func signature
|
|
|
|
|
|
|
|
return tsaddr.IsTailscaleIP(nip)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func isUp(nif *net.Interface) bool { return nif.Flags&net.FlagUp != 0 }
|
|
|
|
func isUp(nif *net.Interface) bool { return nif.Flags&net.FlagUp != 0 }
|
|
|
|
func isLoopback(nif *net.Interface) bool { return nif.Flags&net.FlagLoopback != 0 }
|
|
|
|
func isLoopback(nif *net.Interface) bool { return nif.Flags&net.FlagLoopback != 0 }
|
|
|
|
|
|
|
|
|
|
|
|