diff --git a/control/controlclient/map.go b/control/controlclient/map.go index 6910a11a9..2f69d57ac 100644 --- a/control/controlclient/map.go +++ b/control/controlclient/map.go @@ -467,9 +467,6 @@ func (ms *mapSession) netmap() *netmap.NetworkMap { nm.Expiry = node.KeyExpiry() nm.Name = node.Name() nm.Addresses = filterSelfAddresses(node.Addresses().AsSlice()) - if node.Hostinfo().Valid() { - nm.Hostinfo = *node.Hostinfo().AsStruct() - } if node.MachineAuthorized() { nm.MachineStatus = tailcfg.MachineAuthorized } else { diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 73fdb46a6..8ef5b2be8 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -704,7 +704,9 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func ss.Online = health.GetInPollNetMap() if b.netMap != nil { ss.InNetworkMap = true - ss.HostName = b.netMap.Hostinfo.Hostname + if hi := b.netMap.SelfNode.Hostinfo(); hi.Valid() { + ss.HostName = hi.Hostname() + } ss.DNSName = b.netMap.Name ss.UserID = b.netMap.User() if sn := b.netMap.SelfNode; sn.Valid() { diff --git a/types/netmap/netmap.go b/types/netmap/netmap.go index ceedef9a7..41564ff2e 100644 --- a/types/netmap/netmap.go +++ b/types/netmap/netmap.go @@ -23,8 +23,6 @@ // The fields should all be considered read-only. They might // alias parts of previous NetworkMap values. type NetworkMap struct { - // Core networking - SelfNode tailcfg.NodeView NodeKey key.NodePublic PrivateKey key.NodePrivate @@ -44,10 +42,10 @@ type NetworkMap struct { MachineStatus tailcfg.MachineStatus MachineKey key.MachinePublic - Peers []tailcfg.NodeView // sorted by Node.ID - DNS tailcfg.DNSConfig - // TODO(maisem) : replace with View. - Hostinfo tailcfg.Hostinfo + + Peers []tailcfg.NodeView // sorted by Node.ID + DNS tailcfg.DNSConfig + PacketFilter []filter.Match PacketFilterRules views.Slice[tailcfg.FilterRule] SSHPolicy *tailcfg.SSHPolicy // or nil, if not enabled/allowed diff --git a/wgengine/userspace.go b/wgengine/userspace.go index 44fd85eea..ce7815177 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -41,6 +41,7 @@ "tailscale.com/types/key" "tailscale.com/types/logger" "tailscale.com/types/netmap" + "tailscale.com/types/views" "tailscale.com/util/clientmetric" "tailscale.com/util/deephash" "tailscale.com/util/mak" @@ -755,12 +756,11 @@ func (e *userspaceEngine) updateActivityMapsLocked(trackNodes []key.NodePublic, // hasOverlap checks if there is a IPPrefix which is common amongst the two // provided slices. -func hasOverlap(aips, rips []netip.Prefix) bool { - for _, aip := range aips { - for _, rip := range rips { - if aip == rip { - return true - } +func hasOverlap(aips, rips views.Slice[netip.Prefix]) bool { + for i := range aips.LenIter() { + aip := aips.At(i) + if views.SliceContains(rips, aip) { + return true } } return false @@ -800,9 +800,9 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config, isSubnetRouter := false if e.birdClient != nil && nm != nil && nm.SelfNode.Valid() { - isSubnetRouter = hasOverlap(nm.SelfNode.PrimaryRoutes().AsSlice(), nm.Hostinfo.RoutableIPs) + isSubnetRouter = hasOverlap(nm.SelfNode.PrimaryRoutes(), nm.SelfNode.Hostinfo().RoutableIPs()) e.logf("[v1] Reconfig: hasOverlap(%v, %v) = %v; isSubnetRouter=%v lastIsSubnetRouter=%v", - nm.SelfNode.PrimaryRoutes, nm.Hostinfo.RoutableIPs, + nm.SelfNode.PrimaryRoutes(), nm.SelfNode.Hostinfo().RoutableIPs(), isSubnetRouter, isSubnetRouter, e.lastIsSubnetRouter) } isSubnetRouterChanged := isSubnetRouter != e.lastIsSubnetRouter