From 2ec371fe8b9c0e6fdec5b9013ab2224803c0b65d Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Fri, 29 Apr 2022 15:34:53 -0700 Subject: [PATCH] ipn: remove FakeExpireAfter Backend function No callers remain (last one was removed with tailscale/corp@1c095ae08fcc21362db65035a117672a71b4a081), and it's pretty esoteric. Signed-off-by: Mihai Parparita --- ipn/backend.go | 5 ----- ipn/fake_test.go | 8 -------- ipn/handle.go | 4 ---- ipn/ipnlocal/local.go | 22 ---------------------- ipn/message.go | 13 ------------- 5 files changed, 52 deletions(-) diff --git a/ipn/backend.go b/ipn/backend.go index 949bf5444..dd597e716 100644 --- a/ipn/backend.go +++ b/ipn/backend.go @@ -245,11 +245,6 @@ type Backend interface { // counts. Connection events are emitted automatically without // polling. RequestEngineStatus() - // FakeExpireAfter pretends that the current key is going to - // expire after duration x. This is useful for testing GUIs to - // make sure they react properly with keys that are going to - // expire. - FakeExpireAfter(x time.Duration) // Ping attempts to start connecting to the given IP and sends a Notify // with its PingResult. If the host is down, there might never // be a PingResult sent. The cmd/tailscale CLI client adds a timeout. diff --git a/ipn/fake_test.go b/ipn/fake_test.go index 4f6c9273b..3d08cfc46 100644 --- a/ipn/fake_test.go +++ b/ipn/fake_test.go @@ -5,8 +5,6 @@ package ipn import ( - "time" - "tailscale.com/ipn/ipnstate" "tailscale.com/tailcfg" "tailscale.com/types/netmap" @@ -102,12 +100,6 @@ func (b *FakeBackend) RequestEngineStatus() { } } -func (b *FakeBackend) FakeExpireAfter(x time.Duration) { - if b.notify != nil { - b.notify(Notify{NetMap: &netmap.NetworkMap{}}) - } -} - func (b *FakeBackend) Ping(ip string, useTSMP bool) { if b.notify != nil { b.notify(Notify{PingResult: &ipnstate.PingResult{}}) diff --git a/ipn/handle.go b/ipn/handle.go index e19080ce4..35f4c041b 100644 --- a/ipn/handle.go +++ b/ipn/handle.go @@ -174,7 +174,3 @@ func (h *Handle) Logout() { func (h *Handle) RequestEngineStatus() { h.b.RequestEngineStatus() } - -func (h *Handle) FakeExpireAfter(x time.Duration) { - h.b.FakeExpireAfter(x) -} diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 4b9e54cee..324ca652b 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -1699,28 +1699,6 @@ func (b *LocalBackend) StartLoginInteractive() { } } -// FakeExpireAfter implements Backend. -func (b *LocalBackend) FakeExpireAfter(x time.Duration) { - b.logf("FakeExpireAfter: %v", x) - - b.mu.Lock() - defer b.mu.Unlock() - - if b.netMap == nil { - return - } - - // This function is called very rarely, - // so we prefer to fully copy the netmap over introducing in-place modification here. - mapCopy := *b.netMap - e := mapCopy.Expiry - if e.IsZero() || time.Until(e) > x { - mapCopy.Expiry = time.Now().Add(x) - } - b.setNetMapLocked(&mapCopy) - b.send(ipn.Notify{NetMap: b.netMap}) -} - func (b *LocalBackend) Ping(ipStr string, useTSMP bool) { ip, err := netaddr.ParseIP(ipStr) if err != nil { diff --git a/ipn/message.go b/ipn/message.go index b9e868da0..02cca9bd2 100644 --- a/ipn/message.go +++ b/ipn/message.go @@ -13,7 +13,6 @@ import ( "fmt" "io" "log" - "time" "tailscale.com/envknob" "tailscale.com/tailcfg" @@ -52,10 +51,6 @@ type SetPrefsArgs struct { New *Prefs } -type FakeExpireAfterArgs struct { - Duration time.Duration -} - type PingArgs struct { IP string UseTSMP bool @@ -83,7 +78,6 @@ type Command struct { SetPrefs *SetPrefsArgs RequestEngineStatus *NoArgs RequestStatus *NoArgs - FakeExpireAfter *FakeExpireAfterArgs Ping *PingArgs } @@ -205,9 +199,6 @@ func (bs *BackendServer) GotCommand(ctx context.Context, cmd *Command) error { } else if c := cmd.SetPrefs; c != nil { bs.b.SetPrefs(c.New) return nil - } else if c := cmd.FakeExpireAfter; c != nil { - bs.b.FakeExpireAfter(c.Duration) - return nil } return fmt.Errorf("BackendServer.Do: no command specified") } @@ -320,10 +311,6 @@ func (bc *BackendClient) RequestStatus() { bc.send(Command{AllowVersionSkew: true, RequestStatus: &NoArgs{}}) } -func (bc *BackendClient) FakeExpireAfter(x time.Duration) { - bc.send(Command{FakeExpireAfter: &FakeExpireAfterArgs{Duration: x}}) -} - func (bc *BackendClient) Ping(ip string, useTSMP bool) { bc.send(Command{Ping: &PingArgs{ IP: ip,