Browse Source

ipn/ipnlocal: rename LogoutSync to Logout

Updates #cleanup

Signed-off-by: Maisem Ali <[email protected]>
Maisem Ali 2 years ago
parent
commit
96277b63ff
4 changed files with 9 additions and 7 deletions
  1. 1 1
      cmd/tsconnect/wasm/wasm_js.go
  2. 4 2
      ipn/ipnlocal/local.go
  3. 3 3
      ipn/ipnlocal/state_test.go
  4. 1 1
      ipn/localapi/localapi.go

+ 1 - 1
cmd/tsconnect/wasm/wasm_js.go

@@ -329,7 +329,7 @@ func (i *jsIPN) logout() {
 	go func() {
 		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
 		defer cancel()
-		i.lb.LogoutSync(ctx)
+		i.lb.Logout(ctx)
 	}()
 }
 

+ 4 - 2
ipn/ipnlocal/local.go

@@ -566,7 +566,7 @@ func (b *LocalBackend) Shutdown() {
 		ctx, cancel := context.WithTimeout(b.ctx, 5*time.Second)
 		defer cancel()
 		t0 := time.Now()
-		err := b.LogoutSync(ctx) // best effort
+		err := b.Logout(ctx) // best effort
 		td := time.Since(t0).Round(time.Millisecond)
 		if err != nil {
 			b.logf("failed to log out ephemeral node on shutdown after %v: %v", td, err)
@@ -3907,7 +3907,9 @@ func (b *LocalBackend) ShouldHandleViaIP(ip netip.Addr) bool {
 	return false
 }
 
-func (b *LocalBackend) LogoutSync(ctx context.Context) error {
+// Logout logs out the current profile, if any, and waits for the logout to
+// complete.
+func (b *LocalBackend) Logout(ctx context.Context) error {
 	b.mu.Lock()
 	if !b.hasNodeKeyLocked() {
 		// Already logged out.

+ 3 - 3
ipn/ipnlocal/state_test.go

@@ -580,7 +580,7 @@ func TestStateMachine(t *testing.T) {
 	store.awaitWrite()
 	t.Logf("\n\nLogout")
 	notifies.expect(5)
-	b.LogoutSync(context.Background())
+	b.Logout(context.Background())
 	{
 		nn := notifies.drain(5)
 		previousCC.assertCalls("pause", "Logout", "unpause", "Shutdown")
@@ -610,7 +610,7 @@ func TestStateMachine(t *testing.T) {
 	// A second logout should be a no-op as we are in the NeedsLogin state.
 	t.Logf("\n\nLogout2")
 	notifies.expect(0)
-	b.LogoutSync(context.Background())
+	b.Logout(context.Background())
 	{
 		notifies.drain(0)
 		cc.assertCalls()
@@ -623,7 +623,7 @@ func TestStateMachine(t *testing.T) {
 	// AuthCantContinue state.
 	t.Logf("\n\nLogout3")
 	notifies.expect(3)
-	b.LogoutSync(context.Background())
+	b.Logout(context.Background())
 	{
 		notifies.drain(0)
 		cc.assertCalls()

+ 1 - 1
ipn/localapi/localapi.go

@@ -1056,7 +1056,7 @@ func (h *Handler) serveLogout(w http.ResponseWriter, r *http.Request) {
 		http.Error(w, "want POST", 400)
 		return
 	}
-	err := h.b.LogoutSync(r.Context())
+	err := h.b.Logout(r.Context())
 	if err == nil {
 		w.WriteHeader(http.StatusNoContent)
 		return