@ -3988,6 +3988,12 @@ func (b *LocalBackend) wantIngressLocked() bool {
return b . serveConfig . Valid ( ) && b . serveConfig . HasAllowFunnel ( )
return b . serveConfig . Valid ( ) && b . serveConfig . HasAllowFunnel ( )
}
}
// hasIngressEnabledLocked reports whether the node has any funnel endpoint enabled. This bool is sent to control (in
// Hostinfo.IngressEnabled) to determine whether 'Funnel' badge should be displayed on this node in the admin panel.
func ( b * LocalBackend ) hasIngressEnabledLocked ( ) bool {
return b . serveConfig . Valid ( ) && b . serveConfig . IsFunnelOn ( )
}
// setPrefsLockedOnEntry requires b.mu be held to call it, but it
// setPrefsLockedOnEntry requires b.mu be held to call it, but it
// unlocks b.mu when done. newp ownership passes to this function.
// unlocks b.mu when done. newp ownership passes to this function.
// It returns a read-only copy of the new prefs.
// It returns a read-only copy of the new prefs.
@ -5086,7 +5092,12 @@ func (b *LocalBackend) applyPrefsToHostinfoLocked(hi *tailcfg.Hostinfo, prefs ip
// if this is accidentally false, then control may not configure DNS
// if this is accidentally false, then control may not configure DNS
// properly. This exists as an optimization to control to program fewer DNS
// properly. This exists as an optimization to control to program fewer DNS
// records that have ingress enabled but are not actually being used.
// records that have ingress enabled but are not actually being used.
// TODO(irbekrm): once control knows that if hostinfo.IngressEnabled is true,
// then wireIngress can be considered true, don't send wireIngress in that case.
hi . WireIngress = b . wantIngressLocked ( )
hi . WireIngress = b . wantIngressLocked ( )
// The Hostinfo.IngressEnabled field is used to communicate to control whether
// the funnel is actually enabled.
hi . IngressEnabled = b . hasIngressEnabledLocked ( )
hi . AppConnector . Set ( prefs . AppConnector ( ) . Advertise )
hi . AppConnector . Set ( prefs . AppConnector ( ) . Advertise )
}
}
@ -6009,14 +6020,37 @@ func (b *LocalBackend) setTCPPortsInterceptedFromNetmapAndPrefsLocked(prefs ipn.
b . updateServeTCPPortNetMapAddrListenersLocked ( servePorts )
b . updateServeTCPPortNetMapAddrListenersLocked ( servePorts )
}
}
}
}
// Kick off a Hostinfo update to control if WireIngress changed.
if wire := b . wantIngressLocked ( ) ; b . hostinfo != nil && b . hostinfo . WireIngress != wire {
// Update funnel info in hostinfo and kick off control update if needed.
b . updateIngressLocked ( )
b . setTCPPortsIntercepted ( handlePorts )
}
// updateIngressLocked updates the hostinfo.WireIngress and hostinfo.IngressEnabled fields and kicks off a Hostinfo
// update if the values have changed.
// TODO(irbekrm): once control knows that if hostinfo.IngressEnabled is true, then wireIngress can be considered true,
// we can stop sending hostinfo.WireIngress in that case.
//
// b.mu must be held.
func ( b * LocalBackend ) updateIngressLocked ( ) {
if b . hostinfo == nil {
return
}
hostInfoChanged := false
if wire := b . wantIngressLocked ( ) ; b . hostinfo . WireIngress != wire {
b . logf ( "Hostinfo.WireIngress changed to %v" , wire )
b . logf ( "Hostinfo.WireIngress changed to %v" , wire )
b . hostinfo . WireIngress = wire
b . hostinfo . WireIngress = wire
hostInfoChanged = true
}
if ie := b . hasIngressEnabledLocked ( ) ; b . hostinfo . IngressEnabled != ie {
b . logf ( "Hostinfo.IngressEnabled changed to %v" , ie )
b . hostinfo . IngressEnabled = ie
hostInfoChanged = true
}
// Kick off a Hostinfo update to control if ingress status has changed.
if hostInfoChanged {
b . goTracker . Go ( b . doSetHostinfoFilterServices )
b . goTracker . Go ( b . doSetHostinfoFilterServices )
}
}
b . setTCPPortsIntercepted ( handlePorts )
}
}
// setServeProxyHandlersLocked ensures there is an http proxy handler for each
// setServeProxyHandlersLocked ensures there is an http proxy handler for each