cmd/tailscale: fix alternate ControlURL handling. (#72)

With the Fast User Switching support in Tailscale 1.34,
it is no longer necessary (nor sufficient) to exit
and restart the app, as the settings are saved upon
first connection.

Therefore:
- do not restart the app after changing the control URL,
  just go back to the authentication screen.
- call `ipn/ipnlocal/local.go:Start()` to reinitialize
  the backend using the new auth URL.

Fixes https://github.com/tailscale/tailscale/issues/6671

Signed-off-by: Denton Gentry <dgentry@tailscale.com>

Signed-off-by: Denton Gentry <dgentry@tailscale.com>
pull/71/head
Denton Gentry 1 year ago committed by GitHub
parent 7f11150cb6
commit 0244fd108d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -441,9 +441,15 @@ func (a *App) runBackend() error {
case SetLoginServerEvent:
state.Prefs.ControlURL = e.URL
b.backend.SetPrefs(state.Prefs)
// A hack to get around ipnlocal's inability to update
// ControlURL after Start()... Can we re-init instead?
os.Exit(0)
// Need to restart to force the login URL to be regenerated
// with the new control URL. Start from a goroutine to avoid
// deadlock.
go func() {
err := b.backend.Start(ipn.Options{})
if err != nil {
fatalErr(err)
}
}()
case LogoutEvent:
go b.backend.Logout()
case ConnectEvent:

@ -396,8 +396,9 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
if ui.loginServerSave.Clicked() {
text := ui.loginServer.Text()
ui.showMessage(gtx, "Login server saved, relaunch the app")
ui.showMessage(gtx, "Login server saved")
events = append(events, SetLoginServerEvent{URL: text})
ui.setLoginServer = false
}
if ui.loginServerCancel.Clicked() {
ui.setLoginServer = false
@ -725,7 +726,7 @@ func (ui *UI) layoutSignIn(gtx layout.Context, state *BackendState) layout.Dimen
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: unit.Dp(16)}.Layout(gtx, func(gtx C) D {
return border.Layout(gtx, func(gtx C) D {
button := material.Button(ui.theme, &ui.loginServerSave, "Save and restart")
button := material.Button(ui.theme, &ui.loginServerSave, "Save")
button.Background = color.NRGBA{} // transparent
button.Color = rgb(textColor)
return button.Layout(gtx)

Loading…
Cancel
Save