MCPcopy Create free account
hub / github.com/coder/wush / hostInfoChanged

Function hostInfoChanged

tsserver/server.go:737–768  ·  view source on GitHub ↗
(old, new *tailcfg.Hostinfo)

Source from the content-addressed store, hash-verified

735}
736
737func hostInfoChanged(old, new *tailcfg.Hostinfo) (bool, bool) {
738 if old.Equal(new) {
739 return false, false
740 }
741
742 // Routes
743 oldRoutes := old.RoutableIPs
744 newRoutes := new.RoutableIPs
745
746 sort.Slice(oldRoutes, func(i, j int) bool {
747 return comparePrefix(oldRoutes[i], oldRoutes[j]) > 0
748 })
749 sort.Slice(newRoutes, func(i, j int) bool {
750 return comparePrefix(newRoutes[i], newRoutes[j]) > 0
751 })
752
753 if !xslices.Equal(oldRoutes, newRoutes) {
754 return true, true
755 }
756
757 // Services is mostly useful for discovery and not critical,
758 // except for peerapi, which is how nodes talk to eachother.
759 // If peerapi was not part of the initial mapresponse, we
760 // need to make sure its sent out later as it is needed for
761 // Taildrop.
762 // TODO(kradalby): Length comparison is a bit naive, replace.
763 if len(old.Services) != len(new.Services) {
764 return true, false
765 }
766
767 return false, false
768}
769
770// TODO(kradalby): Remove after go 1.23, will be in stdlib.
771// Compare returns an integer comparing two prefixes.

Callers 1

handleEndpointUpdateMethod · 0.85

Calls 1

comparePrefixFunction · 0.85

Tested by

no test coverage detected