mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
ipn/ipnlocal: set the push device token correctly
It would end up resetting whatever hostinfo we had constructed and leave the backend statemachine in a broken state. This fixes that by storing the PushDeviceToken on the LocalBackend and populating it on Hostinfo before passing it to controlclient. Updates tailscale/corp#8940 Updates tailscale/corp#15367 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -1553,8 +1553,7 @@ func (h *Handler) serveSetPushDeviceToken(w http.ResponseWriter, r *http.Request
|
||||
http.Error(w, "invalid JSON body", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
hostinfo.SetPushDeviceToken(params.PushDeviceToken)
|
||||
h.b.ResendHostinfoIfNeeded()
|
||||
h.b.SetPushDeviceToken(params.PushDeviceToken)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"tailscale.com/client/tailscale/apitype"
|
||||
"tailscale.com/hostinfo"
|
||||
"tailscale.com/ipn/ipnlocal"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstest"
|
||||
@@ -77,7 +76,7 @@ func TestSetPushDeviceToken(t *testing.T) {
|
||||
if res.StatusCode != 200 {
|
||||
t.Errorf("res.StatusCode=%d, want 200. body: %s", res.StatusCode, body)
|
||||
}
|
||||
if got := hostinfo.New().PushDeviceToken; got != want {
|
||||
if got := h.b.GetPushDeviceToken(); got != want {
|
||||
t.Errorf("hostinfo.PushDeviceToken=%q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user