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

Function peerChange

tsserver/server.go:694–735  ·  view source on GitHub ↗
(req *tailcfg.MapRequest, node *tailcfg.Node)

Source from the content-addressed store, hash-verified

692}
693
694func peerChange(req *tailcfg.MapRequest, node *tailcfg.Node) tailcfg.PeerChange {
695 ret := tailcfg.PeerChange{
696 NodeID: node.ID,
697 }
698
699 if node.Key.String() != req.NodeKey.String() {
700 ret.Key = &req.NodeKey
701 }
702
703 if node.DiscoKey.String() != req.DiscoKey.String() {
704 ret.DiscoKey = &req.DiscoKey
705 }
706
707 if node.Hostinfo.Valid() &&
708 node.Hostinfo.NetInfo().Valid() &&
709 req.Hostinfo != nil &&
710 req.Hostinfo.NetInfo != nil &&
711 node.Hostinfo.NetInfo().PreferredDERP() != req.Hostinfo.NetInfo.PreferredDERP {
712 ret.DERPRegion = req.Hostinfo.NetInfo.PreferredDERP
713 }
714
715 if req.Hostinfo != nil && req.Hostinfo.NetInfo != nil {
716 // If there is no stored Hostinfo or NetInfo, use
717 // the new PreferredDERP.
718 if !node.Hostinfo.Valid() {
719 ret.DERPRegion = req.Hostinfo.NetInfo.PreferredDERP
720 } else if !node.Hostinfo.NetInfo().Valid() {
721 ret.DERPRegion = req.Hostinfo.NetInfo.PreferredDERP
722 } else {
723 // If there is a PreferredDERP check if it has changed.
724 if node.Hostinfo.NetInfo().PreferredDERP() != req.Hostinfo.NetInfo.PreferredDERP {
725 ret.DERPRegion = req.Hostinfo.NetInfo.PreferredDERP
726 }
727 }
728 }
729
730 ret.Endpoints = req.Endpoints
731
732 ret.LastSeen = ptr.To(time.Now())
733
734 return ret
735}
736
737func hostInfoChanged(old, new *tailcfg.Hostinfo) (bool, bool) {
738 if old.Equal(new) {

Callers 1

handleEndpointUpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected