@ -541,7 +541,7 @@ func (b *LocalBackend) linkChange(delta *netmon.ChangeDelta) {
b . updateFilterLocked ( b . netMap , b . pm . CurrentPrefs ( ) )
b . updateFilterLocked ( b . netMap , b . pm . CurrentPrefs ( ) )
if peerAPIListenAsync && b . netMap != nil && b . state == ipn . Running {
if peerAPIListenAsync && b . netMap != nil && b . state == ipn . Running {
want := len ( b . netMap . Addresses )
want := b . netMap . GetAddresses ( ) . Len ( )
if len ( b . peerAPIListeners ) < want {
if len ( b . peerAPIListeners ) < want {
b . logf ( "linkChange: peerAPIListeners too low; trying again" )
b . logf ( "linkChange: peerAPIListeners too low; trying again" )
go b . initPeerAPIListener ( )
go b . initPeerAPIListener ( )
@ -711,8 +711,9 @@ func (b *LocalBackend) UpdateStatus(sb *ipnstate.StatusBuilder) {
var tailscaleIPs [ ] netip . Addr
var tailscaleIPs [ ] netip . Addr
if b . netMap != nil {
if b . netMap != nil {
for _ , addr := range b . netMap . Addresses {
addrs := b . netMap . GetAddresses ( )
if addr . IsSingleIP ( ) {
for i := range addrs . LenIter ( ) {
if addr := addrs . At ( i ) ; addr . IsSingleIP ( ) {
sb . AddTailscaleIP ( addr . Addr ( ) )
sb . AddTailscaleIP ( addr . Addr ( ) )
tailscaleIPs = append ( tailscaleIPs , addr . Addr ( ) )
tailscaleIPs = append ( tailscaleIPs , addr . Addr ( ) )
}
}
@ -872,7 +873,9 @@ func (b *LocalBackend) peerCapsLocked(src netip.Addr) tailcfg.PeerCapMap {
if filt == nil {
if filt == nil {
return nil
return nil
}
}
for _ , a := range b . netMap . Addresses {
addrs := b . netMap . GetAddresses ( )
for i := range addrs . LenIter ( ) {
a := addrs . At ( i )
if ! a . IsSingleIP ( ) {
if ! a . IsSingleIP ( ) {
continue
continue
}
}
@ -1566,7 +1569,7 @@ func (b *LocalBackend) updateFilterLocked(netMap *netmap.NetworkMap, prefs ipn.P
// quite hard to debug, so save yourself the trouble.
// quite hard to debug, so save yourself the trouble.
var (
var (
haveNetmap = netMap != nil
haveNetmap = netMap != nil
addrs [ ] netip . Prefix
addrs views . Slice [ netip . Prefix ]
packetFilter [ ] filter . Match
packetFilter [ ] filter . Match
localNetsB netipx . IPSetBuilder
localNetsB netipx . IPSetBuilder
logNetsB netipx . IPSetBuilder
logNetsB netipx . IPSetBuilder
@ -1577,9 +1580,9 @@ func (b *LocalBackend) updateFilterLocked(netMap *netmap.NetworkMap, prefs ipn.P
logNetsB . AddPrefix ( tsaddr . TailscaleULARange ( ) )
logNetsB . AddPrefix ( tsaddr . TailscaleULARange ( ) )
logNetsB . RemovePrefix ( tsaddr . ChromeOSVMRange ( ) )
logNetsB . RemovePrefix ( tsaddr . ChromeOSVMRange ( ) )
if haveNetmap {
if haveNetmap {
addrs = netMap . Addresses
addrs = netMap . GetAddresses ( )
for _, p := range addrs {
for i := range addrs . LenIter ( ) {
localNetsB . AddPrefix ( p )
localNetsB . AddPrefix ( addrs. At ( i ) )
}
}
packetFilter = netMap . PacketFilter
packetFilter = netMap . PacketFilter
@ -1631,7 +1634,7 @@ func (b *LocalBackend) updateFilterLocked(netMap *netmap.NetworkMap, prefs ipn.P
changed := deephash . Update ( & b . filterHash , & struct {
changed := deephash . Update ( & b . filterHash , & struct {
HaveNetmap bool
HaveNetmap bool
Addrs [ ] netip . Prefix
Addrs views . Slice [ netip . Prefix ]
FilterMatch [ ] filter . Match
FilterMatch [ ] filter . Match
LocalNets [ ] netipx . IPRange
LocalNets [ ] netipx . IPRange
LogNets [ ] netipx . IPRange
LogNets [ ] netipx . IPRange
@ -2893,7 +2896,7 @@ func (b *LocalBackend) handlePeerAPIConn(remote, local netip.AddrPort, c net.Con
func ( b * LocalBackend ) isLocalIP ( ip netip . Addr ) bool {
func ( b * LocalBackend ) isLocalIP ( ip netip . Addr ) bool {
nm := b . NetMap ( )
nm := b . NetMap ( )
return nm != nil && slices. Contains ( nm . Addresses , netip . PrefixFrom ( ip , ip . BitLen ( ) ) )
return nm != nil && views. SliceContains ( nm . GetAddresses ( ) , netip . PrefixFrom ( ip , ip . BitLen ( ) ) )
}
}
var (
var (
@ -3399,10 +3402,11 @@ func (b *LocalBackend) initPeerAPIListener() {
return
return
}
}
if len ( b . netMap . Addresses ) == len ( b . peerAPIListeners ) {
addrs := b . netMap . GetAddresses ( )
if addrs . Len ( ) == len ( b . peerAPIListeners ) {
allSame := true
allSame := true
for i , pln := range b . peerAPIListeners {
for i , pln := range b . peerAPIListeners {
if pln . ip != b. netMap . Addresses [ i ] . Addr ( ) {
if pln . ip != addrs. At ( i ) . Addr ( ) {
allSame = false
allSame = false
break
break
}
}
@ -3416,7 +3420,7 @@ func (b *LocalBackend) initPeerAPIListener() {
b . closePeerAPIListenersLocked ( )
b . closePeerAPIListenersLocked ( )
selfNode := b . netMap . SelfNode
selfNode := b . netMap . SelfNode
if len ( b . netMap . Addresses ) == 0 || ! selfNode . Valid ( ) {
if ! selfNode . Valid ( ) || b . netMap . GetAddresses ( ) . Len ( ) == 0 {
return
return
}
}
@ -3437,7 +3441,8 @@ func (b *LocalBackend) initPeerAPIListener() {
b . peerAPIServer = ps
b . peerAPIServer = ps
isNetstack := b . sys . IsNetstack ( )
isNetstack := b . sys . IsNetstack ( )
for i , a := range b . netMap . Addresses {
for i := range addrs . LenIter ( ) {
a := addrs . At ( i )
var ln net . Listener
var ln net . Listener
var err error
var err error
skipListen := i > 0 && isNetstack
skipListen := i > 0 && isNetstack
@ -3721,11 +3726,12 @@ func (b *LocalBackend) enterStateLockedOnEntry(newState ipn.State) {
// Needed so that UpdateEndpoints can run
// Needed so that UpdateEndpoints can run
b . e . RequestStatus ( )
b . e . RequestStatus ( )
case ipn . Running :
case ipn . Running :
var addrs [ ] string
var addrStrs [ ] string
for _ , addr := range netMap . Addresses {
addrs := netMap . GetAddresses ( )
addrs = append ( addrs , addr . Addr ( ) . String ( ) )
for i := range addrs . LenIter ( ) {
addrStrs = append ( addrStrs , addrs . At ( i ) . Addr ( ) . String ( ) )
}
}
systemd . Status ( "Connected; %s; %s" , activeLogin , strings . Join ( addr s, " " ) )
systemd . Status ( "Connected; %s; %s" , activeLogin , strings . Join ( addr Str s, " " ) )
case ipn . NoState :
case ipn . NoState :
// Do nothing.
// Do nothing.
default :
default :
@ -4838,13 +4844,14 @@ func (b *LocalBackend) handleQuad100Port80Conn(w http.ResponseWriter, r *http.Re
io . WriteString ( w , "No netmap.\n" )
io . WriteString ( w , "No netmap.\n" )
return
return
}
}
if len ( b . netMap . Addresses ) == 0 {
addrs := b . netMap . GetAddresses ( )
if addrs . Len ( ) == 0 {
io . WriteString ( w , "No local addresses.\n" )
io . WriteString ( w , "No local addresses.\n" )
return
return
}
}
io . WriteString ( w , "<p>Local addresses:</p><ul>\n" )
io . WriteString ( w , "<p>Local addresses:</p><ul>\n" )
for _, ipp := range b . netMap . Addresses {
for i := range addrs . LenIter ( ) {
fmt . Fprintf ( w , "<li>%v</li>\n" , ipp . Addr ( ) )
fmt . Fprintf ( w , "<li>%v</li>\n" , addrs. At ( i ) . Addr ( ) )
}
}
io . WriteString ( w , "</ul>\n" )
io . WriteString ( w , "</ul>\n" )
}
}