mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
cmd/tailscale/cli: add backwards compatibility 'up' processing for legacy client
Updates tailscale/corp#6781 Change-Id: I843fc810cbec0140d423d65db81e90179d6e0fa5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
d8bfb7543e
commit
ba3cc08b62
@ -762,6 +762,9 @@ func TestPrefFlagMapping(t *testing.T) {
|
|||||||
case "NotepadURLs":
|
case "NotepadURLs":
|
||||||
// TODO(bradfitz): https://github.com/tailscale/tailscale/issues/1830
|
// TODO(bradfitz): https://github.com/tailscale/tailscale/issues/1830
|
||||||
continue
|
continue
|
||||||
|
case "Egg":
|
||||||
|
// Not applicable.
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
t.Errorf("unexpected new ipn.Pref field %q is not handled by up.go (see addPrefFlagMapping and checkForAccidentalSettingReverts)", prefName)
|
t.Errorf("unexpected new ipn.Pref field %q is not handled by up.go (see addPrefFlagMapping and checkForAccidentalSettingReverts)", prefName)
|
||||||
}
|
}
|
||||||
|
@ -406,8 +406,12 @@ func updatePrefs(prefs, curPrefs *ipn.Prefs, env upCheckEnv) (simpleUp bool, jus
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runUp(ctx context.Context, args []string) (retErr error) {
|
func runUp(ctx context.Context, args []string) (retErr error) {
|
||||||
|
var egg bool
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
fatalf("too many non-flag arguments: %q", args)
|
egg = fmt.Sprint(args) == "[up down down left right left right b a]"
|
||||||
|
if !egg {
|
||||||
|
fatalf("too many non-flag arguments: %q", args)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := localClient.Status(ctx)
|
st, err := localClient.Status(ctx)
|
||||||
@ -493,6 +497,7 @@ func runUp(ctx context.Context, args []string) (retErr error) {
|
|||||||
fatalf("%s", err)
|
fatalf("%s", err)
|
||||||
}
|
}
|
||||||
if justEditMP != nil {
|
if justEditMP != nil {
|
||||||
|
justEditMP.EggSet = true
|
||||||
_, err := localClient.EditPrefs(ctx, justEditMP)
|
_, err := localClient.EditPrefs(ctx, justEditMP)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ func (src *Prefs) Clone() *Prefs {
|
|||||||
Hostname string
|
Hostname string
|
||||||
NotepadURLs bool
|
NotepadURLs bool
|
||||||
ForceDaemon bool
|
ForceDaemon bool
|
||||||
|
Egg bool
|
||||||
AdvertiseRoutes []netip.Prefix
|
AdvertiseRoutes []netip.Prefix
|
||||||
NoSNAT bool
|
NoSNAT bool
|
||||||
NetfilterMode preftype.NetfilterMode
|
NetfilterMode preftype.NetfilterMode
|
||||||
|
@ -164,6 +164,7 @@ type LocalBackend struct {
|
|||||||
authURL string // cleared on Notify
|
authURL string // cleared on Notify
|
||||||
authURLSticky string // not cleared on Notify
|
authURLSticky string // not cleared on Notify
|
||||||
interact bool
|
interact bool
|
||||||
|
egg bool
|
||||||
prevIfState *interfaces.State
|
prevIfState *interfaces.State
|
||||||
peerAPIServer *peerAPIServer // or nil
|
peerAPIServer *peerAPIServer // or nil
|
||||||
peerAPIListeners []*peerAPIListener
|
peerAPIListeners []*peerAPIListener
|
||||||
@ -423,7 +424,6 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func
|
|||||||
s.Version = version.Long
|
s.Version = version.Long
|
||||||
s.BackendState = b.state.String()
|
s.BackendState = b.state.String()
|
||||||
s.AuthURL = b.authURLSticky
|
s.AuthURL = b.authURLSticky
|
||||||
|
|
||||||
if err := health.OverallError(); err != nil {
|
if err := health.OverallError(); err != nil {
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
case multierr.Error:
|
case multierr.Error:
|
||||||
@ -2015,6 +2015,11 @@ func (b *LocalBackend) isDefaultServerLocked() bool {
|
|||||||
|
|
||||||
func (b *LocalBackend) EditPrefs(mp *ipn.MaskedPrefs) (*ipn.Prefs, error) {
|
func (b *LocalBackend) EditPrefs(mp *ipn.MaskedPrefs) (*ipn.Prefs, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
|
if mp.EggSet {
|
||||||
|
mp.EggSet = false
|
||||||
|
b.egg = true
|
||||||
|
go b.doSetHostinfoFilterServices(b.hostinfo.Clone())
|
||||||
|
}
|
||||||
p0 := b.prefs.Clone()
|
p0 := b.prefs.Clone()
|
||||||
p1 := b.prefs.Clone()
|
p1 := b.prefs.Clone()
|
||||||
p1.ApplyEdits(mp)
|
p1.ApplyEdits(mp)
|
||||||
@ -2211,6 +2216,9 @@ func (b *LocalBackend) doSetHostinfoFilterServices(hi *tailcfg.Hostinfo) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
peerAPIServices := b.peerAPIServicesLocked()
|
peerAPIServices := b.peerAPIServicesLocked()
|
||||||
|
if b.egg {
|
||||||
|
peerAPIServices = append(peerAPIServices, tailcfg.Service{Proto: "egg"})
|
||||||
|
}
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
// Make a shallow copy of hostinfo so we can mutate
|
// Make a shallow copy of hostinfo so we can mutate
|
||||||
|
@ -163,6 +163,9 @@ type Prefs struct {
|
|||||||
// for Linux/etc, which always operate in daemon mode.
|
// for Linux/etc, which always operate in daemon mode.
|
||||||
ForceDaemon bool `json:"ForceDaemon,omitempty"`
|
ForceDaemon bool `json:"ForceDaemon,omitempty"`
|
||||||
|
|
||||||
|
// Egg is a optional debug flag.
|
||||||
|
Egg bool
|
||||||
|
|
||||||
// The following block of options only have an effect on Linux.
|
// The following block of options only have an effect on Linux.
|
||||||
|
|
||||||
// AdvertiseRoutes specifies CIDR prefixes to advertise into the
|
// AdvertiseRoutes specifies CIDR prefixes to advertise into the
|
||||||
@ -217,6 +220,7 @@ type MaskedPrefs struct {
|
|||||||
HostnameSet bool `json:",omitempty"`
|
HostnameSet bool `json:",omitempty"`
|
||||||
NotepadURLsSet bool `json:",omitempty"`
|
NotepadURLsSet bool `json:",omitempty"`
|
||||||
ForceDaemonSet bool `json:",omitempty"`
|
ForceDaemonSet bool `json:",omitempty"`
|
||||||
|
EggSet bool `json:",omitempty"`
|
||||||
AdvertiseRoutesSet bool `json:",omitempty"`
|
AdvertiseRoutesSet bool `json:",omitempty"`
|
||||||
NoSNATSet bool `json:",omitempty"`
|
NoSNATSet bool `json:",omitempty"`
|
||||||
NetfilterModeSet bool `json:",omitempty"`
|
NetfilterModeSet bool `json:",omitempty"`
|
||||||
|
@ -52,6 +52,7 @@ func TestPrefsEqual(t *testing.T) {
|
|||||||
"Hostname",
|
"Hostname",
|
||||||
"NotepadURLs",
|
"NotepadURLs",
|
||||||
"ForceDaemon",
|
"ForceDaemon",
|
||||||
|
"Egg",
|
||||||
"AdvertiseRoutes",
|
"AdvertiseRoutes",
|
||||||
"NoSNAT",
|
"NoSNAT",
|
||||||
"NetfilterMode",
|
"NetfilterMode",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user