mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-08 22:12:21 +00:00
all: replace wgcfg.IP and wgcfg.CIDR with netaddr types
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
committed by
Josh Bleecher Snyder
parent
ff2b3d02e6
commit
2fe770ed72
@@ -702,18 +702,17 @@ func peerForIP(nm *controlclient.NetworkMap, ip netaddr.IP) (n *tailcfg.Node, ok
|
||||
if nm == nil {
|
||||
return nil, false
|
||||
}
|
||||
wgIP := wgcfg.IP{Addr: ip.As16()}
|
||||
// Check for exact matches before looking for subnet matches.
|
||||
for _, p := range nm.Peers {
|
||||
for _, a := range p.Addresses {
|
||||
if a.IP == wgIP {
|
||||
if a.IP == ip {
|
||||
return p, true
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, p := range nm.Peers {
|
||||
for _, cidr := range p.AllowedIPs {
|
||||
if cidr.Contains(wgIP) {
|
||||
if cidr.Contains(ip) {
|
||||
return p, true
|
||||
}
|
||||
}
|
||||
@@ -2720,16 +2719,15 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) {
|
||||
|
||||
if c.netMap != nil {
|
||||
for _, addr := range c.netMap.Addresses {
|
||||
ip := netaddr.IPFrom16(addr.IP.Addr)
|
||||
if addr.Mask != ip.BitLen() {
|
||||
if !addr.IsSingleIP() {
|
||||
continue
|
||||
}
|
||||
sb.AddTailscaleIP(ip)
|
||||
sb.AddTailscaleIP(addr.IP)
|
||||
// TailAddr only allows for a single Tailscale IP. For
|
||||
// readability of `tailscale status`, make it the IPv4
|
||||
// address.
|
||||
if addr.IP.Is4() {
|
||||
ss.TailAddr = ip.String()
|
||||
ss.TailAddr = addr.IP.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user