@ -7240,6 +7240,10 @@ func suggestExitNode(report *netcheck.Report, nb *nodeBackend, prevSuggestion ta
// the lowest latency to this device. For peers without a DERP home, we look for
// the lowest latency to this device. For peers without a DERP home, we look for
// geographic proximity to this device's DERP home.
// geographic proximity to this device's DERP home.
func suggestExitNodeUsingDERP ( report * netcheck . Report , nb * nodeBackend , prevSuggestion tailcfg . StableNodeID , selectRegion selectRegionFunc , selectNode selectNodeFunc , allowList set . Set [ tailcfg . StableNodeID ] ) ( res apitype . ExitNodeSuggestionResponse , err error ) {
func suggestExitNodeUsingDERP ( report * netcheck . Report , nb * nodeBackend , prevSuggestion tailcfg . StableNodeID , selectRegion selectRegionFunc , selectNode selectNodeFunc , allowList set . Set [ tailcfg . StableNodeID ] ) ( res apitype . ExitNodeSuggestionResponse , err error ) {
// TODO(sfllaw): Context needs to be plumbed down here to support
// reachability testing.
ctx := context . TODO ( )
netMap := nb . NetMap ( )
netMap := nb . NetMap ( )
if report == nil || report . PreferredDERP == 0 || netMap == nil || netMap . DERPMap == nil {
if report == nil || report . PreferredDERP == 0 || netMap == nil || netMap . DERPMap == nil {
return res , ErrNoPreferredDERP
return res , ErrNoPreferredDERP
@ -7248,7 +7252,7 @@ func suggestExitNodeUsingDERP(report *netcheck.Report, nb *nodeBackend, prevSugg
// since the netmap doesn't include delta updates (e.g., home DERP or Online
// since the netmap doesn't include delta updates (e.g., home DERP or Online
// status changes) from the control plane since the last full update.
// status changes) from the control plane since the last full update.
candidates := nb . AppendMatchingPeers ( nil , func ( peer tailcfg . NodeView ) bool {
candidates := nb . AppendMatchingPeers ( nil , func ( peer tailcfg . NodeView ) bool {
if ! peer . Valid ( ) || ! peer. Online ( ) . Get ( ) {
if ! peer . Valid ( ) || ! nb. PeerIsReachable ( ctx , peer ) {
return false
return false
}
}
if allowList != nil && ! allowList . Contains ( peer . StableID ( ) ) {
if allowList != nil && ! allowList . Contains ( peer . StableID ( ) ) {
@ -7367,6 +7371,10 @@ var ErrNoNetMap = errors.New("no network map, try again later")
// the node’ s [tailcfg.Location]. To be eligible for consideration, the node
// the node’ s [tailcfg.Location]. To be eligible for consideration, the node
// must have NodeAttrSuggestExitNode in its CapMap.
// must have NodeAttrSuggestExitNode in its CapMap.
func suggestExitNodeUsingTrafficSteering ( nb * nodeBackend , allowed set . Set [ tailcfg . StableNodeID ] ) ( apitype . ExitNodeSuggestionResponse , error ) {
func suggestExitNodeUsingTrafficSteering ( nb * nodeBackend , allowed set . Set [ tailcfg . StableNodeID ] ) ( apitype . ExitNodeSuggestionResponse , error ) {
// TODO(sfllaw): Context needs to be plumbed down here to support
// reachability testing.
ctx := context . TODO ( )
nm := nb . NetMap ( )
nm := nb . NetMap ( )
if nm == nil {
if nm == nil {
return apitype . ExitNodeSuggestionResponse { } , ErrNoNetMap
return apitype . ExitNodeSuggestionResponse { } , ErrNoNetMap
@ -7386,7 +7394,7 @@ func suggestExitNodeUsingTrafficSteering(nb *nodeBackend, allowed set.Set[tailcf
if ! p . Valid ( ) {
if ! p . Valid ( ) {
return false
return false
}
}
if ! p. Online ( ) . Get ( ) {
if ! nb. PeerIsReachable ( ctx , p ) {
return false
return false
}
}
if allowed != nil && ! allowed . Contains ( p . StableID ( ) ) {
if allowed != nil && ! allowed . Contains ( p . StableID ( ) ) {