From a2f0809afe46fff663c9f281b7509e43aa949d6e Mon Sep 17 00:00:00 2001 From: Irbe Krumina Date: Wed, 22 Jan 2025 11:13:25 +0200 Subject: [PATCH] tailcfg: add a new TailscaleFunnelUsageDetected method In capver 113 we added new Hostinfo.IngressEnabled field to send to control info if a node has any active funnel endpoint. This is on top of the existing Hostinfo.WireIngress field that sends whether the user intends to use funnel (but it's not neccessarily active). We are now in a state where control will be parsing Hostinfos that can use the new (IngressEnabled) field to more correctly determine if funnel is really enabled as well as Hostinfos that must use the the old Hostinfo.WireIngress field. This PR adds a new TailscaleFunnelUsageDetected method that can be used by control to determine if funnel is enabled for Hostinfos for clients of capver <= 112. Once this merges and changes are made control-side to use this method for <= capver 112 Hostinfos, we can change the currently used TailscaleFunnelEnabled field to use the new Hostinfo.IngressEnabled field. Updates tailscale/tailscale#11572 Updates tailscale/corp#25931 Signed-off-by: Irbe Krumina --- tailcfg/tailcfg.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 937f619e6..297fa4e65 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -927,13 +927,24 @@ func (hi *Hostinfo) TailscaleSSHEnabled() bool { func (v HostinfoView) TailscaleSSHEnabled() bool { return v.ж.TailscaleSSHEnabled() } -// TailscaleFunnelEnabled reports whether or not this node has explicitly -// enabled Funnel. +// TailscaleFunnelEnabled reports whether or not this node has explicitly enabled Funnel. func (hi *Hostinfo) TailscaleFunnelEnabled() bool { + // TODO(irbekrm): once control uses TailscaleFunnelUsageDetected to determine whether funnel is enabled for + // clients with capver <= 112, use hi.IngressEnabled here. return hi != nil && hi.WireIngress } -func (v HostinfoView) TailscaleFunnelEnabled() bool { return v.ж.TailscaleFunnelEnabled() } +// TailscaleFunnelUsageDetected reports whether the node has any funnel config applied to it, including one which +// contains only disabled endpoints. +func (hi *Hostinfo) TailscaleFunnelUsageDetected() bool { + // TODO(irbekrm): I am adding the hi.IngressEnabled check here so that this method keeps working once we change + // the logic to not send Hostinfo.WireIngress when Hostinfo.IngressEnabled is already true. Update this comment + // once we make that change. + return hi != nil && (hi.WireIngress || hi.IngressEnabled) +} + +func (v HostinfoView) TailscaleFunnelEnabled() bool { return v.ж.TailscaleFunnelEnabled() } +func (v HostinfoView) TailscaleFunnelUsageDetected() bool { return v.ж.TailscaleFunnelUsageDetected() } // NetInfo contains information about the host's network state. type NetInfo struct {