From 04b79a2206f36cc692a6314a7abf821cb8f8a35e Mon Sep 17 00:00:00 2001 From: kari-ts <135075563+kari-ts@users.noreply.github.com> Date: Thu, 29 Jun 2023 10:09:34 -0700 Subject: [PATCH] cmd/tailscale: if first notification, set hostname even if prefs is nil (#111) Currently, if the notification (ipn.Notify) has a nil Prefs, the hostname defaults to localhost Fixes #7875 Signed-off-by: kari-ts --- cmd/tailscale/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/tailscale/main.go b/cmd/tailscale/main.go index 8fd4677..f2780ef 100644 --- a/cmd/tailscale/main.go +++ b/cmd/tailscale/main.go @@ -351,13 +351,14 @@ func (a *App) runBackend() error { case n := <-notifications: exitWasOnline := state.ExitStatus == ExitOnline if p := n.Prefs; p != nil && n.Prefs.Valid() { - first := state.Prefs == nil state.Prefs = p.AsStruct() state.updateExitNodes() - if first { - state.Prefs.Hostname = a.hostname() - go b.backend.SetPrefs(state.Prefs) - } + a.setPrefs(state.Prefs) + } + first := state.Prefs == nil + if first { + state.Prefs = &ipn.Prefs{Hostname: a.hostname()} + go b.backend.SetPrefs(state.Prefs) a.setPrefs(state.Prefs) } if s := n.State; s != nil {