net/netmon: handle net.IPAddr types during interface address parsing (#17523)
updates tailscale/tailscale#16836 Android's altNetInterfaces implementation now returns net.IPAddr types which netmon wasn't handling. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
This commit is contained in:
@@ -183,6 +183,10 @@ func (ifaces InterfaceList) ForeachInterfaceAddress(fn func(Interface, netip.Pre
|
||||
if pfx, ok := netaddr.FromStdIPNet(v); ok {
|
||||
fn(iface, pfx)
|
||||
}
|
||||
case *net.IPAddr:
|
||||
if ip, ok := netip.AddrFromSlice(v.IP); ok {
|
||||
fn(iface, netip.PrefixFrom(ip, ip.BitLen()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,6 +219,10 @@ func (ifaces InterfaceList) ForeachInterface(fn func(Interface, []netip.Prefix))
|
||||
if pfx, ok := netaddr.FromStdIPNet(v); ok {
|
||||
pfxs = append(pfxs, pfx)
|
||||
}
|
||||
case *net.IPAddr:
|
||||
if ip, ok := netip.AddrFromSlice(v.IP); ok {
|
||||
pfxs = append(pfxs, netip.PrefixFrom(ip, ip.BitLen()))
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Slice(pfxs, func(i, j int) bool {
|
||||
|
||||
Reference in New Issue
Block a user