cmd/tailscale/main: use localapi for logging out (#164)

Updates tailscale/tailscale#10992

Signed-off-by: kari-ts <kari@tailscale.com>
pull/174/head
kari-ts 3 months ago committed by GitHub
parent cbe8858427
commit f6b0734e49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -475,11 +475,7 @@ func (a *App) runBackend(ctx context.Context) error {
}
}()
case LogoutEvent:
go func() {
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()
b.backend.Logout(ctx)
}()
go a.logout(ctx)
case ConnectEvent:
state.Prefs.WantRunning = e.Enable
go b.backend.SetPrefs(state.Prefs)
@ -571,7 +567,7 @@ func (a *App) runBackend(ctx context.Context) error {
}
func (a *App) getBugReportID(ctx context.Context, bugReportChan chan<- string, fallbackLog string) {
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(2*time.Second))
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()
r, err := a.localAPIClient.Call(ctx, "POST", "bugreport", nil)
defer r.Body().Close()
@ -591,7 +587,7 @@ func (a *App) getBugReportID(ctx context.Context, bugReportChan chan<- string, f
}
func (a *App) login(ctx context.Context) {
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(2*time.Second))
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
r, err := a.localAPIClient.Call(ctx, "POST", "login-interactive", nil)
defer r.Body().Close()
@ -602,6 +598,22 @@ func (a *App) login(ctx context.Context) {
}
}
func (a *App) logout(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
r, err := a.localAPIClient.Call(ctx, "POST", "logout", nil)
defer r.Body().Close()
if err != nil {
log.Printf("logout: %s", err)
logoutctx, logoutcancel := context.WithTimeout(ctx, 5*time.Minute)
defer logoutcancel()
a.backend.Logout(logoutctx)
}
return err
}
func (a *App) processWaitingFiles(b *ipnlocal.LocalBackend) error {
files, err := b.WaitingFiles()
if err != nil {

Loading…
Cancel
Save