cmd/tailscale,ipn: add relay-server-port "tailscale set" flag and Prefs field (#15594)
This flag is currently no-op and hidden. The flag does round trip through the related pref. Subsequent commits will tie them to net/udprelay.Server. There is no corresponding "tailscale up" flag, enabling/disabling of the relay server will only be supported via "tailscale set". This is a string flag in order to support disablement via empty string as a port value of 0 means "enable the server and listen on a random unused port". Disablement via empty string also follows existing flag convention, e.g. advertise-routes. Early internal discussions settled on "tailscale set --relay="<port>", but the author felt this was too ambiguous around client vs server, and may cause confusion in the future if we add related flags. Updates tailscale/corp#27502 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
@@ -65,6 +65,7 @@ func TestPrefsEqual(t *testing.T) {
|
||||
"PostureChecking",
|
||||
"NetfilterKind",
|
||||
"DriveShares",
|
||||
"RelayServerPort",
|
||||
"AllowSingleHosts",
|
||||
"Persist",
|
||||
}
|
||||
@@ -73,6 +74,9 @@ func TestPrefsEqual(t *testing.T) {
|
||||
have, prefsHandles)
|
||||
}
|
||||
|
||||
relayServerPort := func(port int) *int {
|
||||
return &port
|
||||
}
|
||||
nets := func(strs ...string) (ns []netip.Prefix) {
|
||||
for _, s := range strs {
|
||||
n, err := netip.ParsePrefix(s)
|
||||
@@ -341,6 +345,16 @@ func TestPrefsEqual(t *testing.T) {
|
||||
&Prefs{AdvertiseServices: []string{"svc:tux", "svc:amelie"}},
|
||||
false,
|
||||
},
|
||||
{
|
||||
&Prefs{RelayServerPort: relayServerPort(0)},
|
||||
&Prefs{RelayServerPort: nil},
|
||||
false,
|
||||
},
|
||||
{
|
||||
&Prefs{RelayServerPort: relayServerPort(0)},
|
||||
&Prefs{RelayServerPort: relayServerPort(1)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
got := tt.a.Equals(tt.b)
|
||||
|
||||
Reference in New Issue
Block a user