mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-20 01:47:33 +00:00
ipn: [serve] warn that foreground funnel won't work if shields are up (#14685)
We throw error early with a warning if users attempt to enable background funnel for a node that does not allow incoming connections (shields up), but if it done in foreground mode, we just silently fail (the funnel command succeeds, but the connections are not allowed). This change makes sure that we also error early in foreground mode. Updates tailscale/tailscale#11049 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
This commit is contained in:
@@ -182,3 +182,88 @@ func TestExpandProxyTargetDev(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsFunnelOn(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
sc *ServeConfig
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "nil_config",
|
||||
},
|
||||
{
|
||||
name: "empty_config",
|
||||
sc: &ServeConfig{},
|
||||
},
|
||||
{
|
||||
name: "funnel_enabled_in_background",
|
||||
sc: &ServeConfig{
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:443": true,
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "funnel_disabled_in_background",
|
||||
sc: &ServeConfig{
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:443": false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "funnel_enabled_in_foreground",
|
||||
sc: &ServeConfig{
|
||||
Foreground: map[string]*ServeConfig{
|
||||
"abc123": {
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:443": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "funnel_disabled_in_both",
|
||||
sc: &ServeConfig{
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:443": false,
|
||||
},
|
||||
Foreground: map[string]*ServeConfig{
|
||||
"abc123": {
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:8443": false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "funnel_enabled_in_both",
|
||||
sc: &ServeConfig{
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:443": true,
|
||||
},
|
||||
Foreground: map[string]*ServeConfig{
|
||||
"abc123": {
|
||||
AllowFunnel: map[HostPort]bool{
|
||||
"tailnet.xyz:8443": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.sc.IsFunnelOn(); got != tt.want {
|
||||
t.Errorf("ServeConfig.IsFunnelOn() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user