ipn/ipnlocal,net/tsdial: update docs/rename funcs

Updates #cleanup

Signed-off-by: Maisem Ali <maisem@tailscale.com>
pull/8851/head
Maisem Ali 11 months ago committed by Maisem Ali
parent 92fc9a01fa
commit 98ec8924c2

@ -491,8 +491,12 @@ func (b *LocalBackend) SetDirectFileDoFinalRename(v bool) {
b.directFileDoFinalRename = v b.directFileDoFinalRename = v
} }
// pauseOrResumeControlClientLocked pauses b.cc if there is no network available
// or if the LocalBackend is in Stopped state with a valid NetMap. In all other
// cases, it unpauses it. It is a no-op if b.cc is nil.
//
// b.mu must be held. // b.mu must be held.
func (b *LocalBackend) maybePauseControlClientLocked() { func (b *LocalBackend) pauseOrResumeControlClientLocked() {
if b.cc == nil { if b.cc == nil {
return return
} }
@ -508,7 +512,7 @@ func (b *LocalBackend) linkChange(major bool, ifst *interfaces.State) {
hadPAC := b.prevIfState.HasPAC() hadPAC := b.prevIfState.HasPAC()
b.prevIfState = ifst b.prevIfState = ifst
b.maybePauseControlClientLocked() b.pauseOrResumeControlClientLocked()
// If the PAC-ness of the network changed, reconfig wireguard+route to // If the PAC-ness of the network changed, reconfig wireguard+route to
// add/remove subnets. // add/remove subnets.
@ -995,7 +999,7 @@ func (b *LocalBackend) setClientStatus(st controlclient.Status) {
prefs.WantRunning = true prefs.WantRunning = true
prefs.LoggedOut = false prefs.LoggedOut = false
} }
if findExitNodeIDLocked(prefs, st.NetMap) { if setExitNodeID(prefs, st.NetMap) {
prefsChanged = true prefsChanged = true
} }
@ -1089,9 +1093,9 @@ func (b *LocalBackend) setClientStatus(st controlclient.Status) {
b.authReconfig() b.authReconfig()
} }
// findExitNodeIDLocked updates prefs to reference an exit node by ID, rather // setExitNodeID updates prefs to reference an exit node by ID, rather
// than by IP. It returns whether prefs was mutated. // than by IP. It returns whether prefs was mutated.
func findExitNodeIDLocked(prefs *ipn.Prefs, nm *netmap.NetworkMap) (prefsChanged bool) { func setExitNodeID(prefs *ipn.Prefs, nm *netmap.NetworkMap) (prefsChanged bool) {
if nm == nil { if nm == nil {
// No netmap, can't resolve anything. // No netmap, can't resolve anything.
return false return false
@ -2747,7 +2751,7 @@ func (b *LocalBackend) setPrefsLockedOnEntry(caller string, newp *ipn.Prefs) ipn
// findExitNodeIDLocked returns whether it updated b.prefs, but // findExitNodeIDLocked returns whether it updated b.prefs, but
// everything in this function treats b.prefs as completely new // everything in this function treats b.prefs as completely new
// anyway. No-op if no exit node resolution is needed. // anyway. No-op if no exit node resolution is needed.
findExitNodeIDLocked(newp, netMap) setExitNodeID(newp, netMap)
// We do this to avoid holding the lock while doing everything else. // We do this to avoid holding the lock while doing everything else.
oldHi := b.hostinfo oldHi := b.hostinfo
@ -3631,7 +3635,7 @@ func (b *LocalBackend) enterStateLockedOnEntry(newState ipn.State) {
// Transitioning away from running. // Transitioning away from running.
b.closePeerAPIListenersLocked() b.closePeerAPIListenersLocked()
} }
b.maybePauseControlClientLocked() b.pauseOrResumeControlClientLocked()
b.mu.Unlock() b.mu.Unlock()
// prefs may change irrespective of state; WantRunning should be explicitly // prefs may change irrespective of state; WantRunning should be explicitly
@ -3962,7 +3966,7 @@ func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
b.logf("active login: %v", login) b.logf("active login: %v", login)
b.activeLogin = login b.activeLogin = login
} }
b.maybePauseControlClientLocked() b.pauseOrResumeControlClientLocked()
if nm != nil { if nm != nil {
health.SetControlHealth(nm.ControlHealth) health.SetControlHealth(nm.ControlHealth)

@ -203,6 +203,8 @@ func (d *Dialer) SetNetMap(nm *netmap.NetworkMap) {
d.dns = m d.dns = m
} }
// userDialResolve resolves addr as if a user initiating the dial. (e.g. from a
// SOCKS or HTTP outbound proxy)
func (d *Dialer) userDialResolve(ctx context.Context, network, addr string) (netip.AddrPort, error) { func (d *Dialer) userDialResolve(ctx context.Context, network, addr string) (netip.AddrPort, error) {
d.mu.Lock() d.mu.Lock()
dns := d.dns dns := d.dns
@ -298,8 +300,8 @@ func (d *Dialer) SystemDial(ctx context.Context, network, addr string) (net.Conn
}, nil }, nil
} }
// UserDial connects to the provided network address as if a user were initiating the dial. // UserDial connects to the provided network address as if a user were
// (e.g. from a SOCKS or HTTP outbound proxy) // initiating the dial. (e.g. from a SOCKS or HTTP outbound proxy)
func (d *Dialer) UserDial(ctx context.Context, network, addr string) (net.Conn, error) { func (d *Dialer) UserDial(ctx context.Context, network, addr string) (net.Conn, error) {
ipp, err := d.userDialResolve(ctx, network, addr) ipp, err := d.userDialResolve(ctx, network, addr)
if err != nil { if err != nil {

Loading…
Cancel
Save