summaryrefslogtreecommitdiffhomepage
path: root/control/keyfallback/keyfallback.go
diff options
context:
space:
mode:
authorAndrew Dunham <andrew@du.nham.ca>2024-10-23 00:24:39 -0500
committerAndrew Dunham <andrew@du.nham.ca>2024-10-24 11:35:48 -0500
commitfc4048014ee26448a3b0c63e8c1a748f0e45e0b7 (patch)
tree9aedb9cc4ab23b51358c97e5b3ca42760fd25495 /control/keyfallback/keyfallback.go
parentb2665d9b89ee8c7be10a8e0a2fa36d35d21d8440 (diff)
downloadtailscale-andrew/keyfallback.tar.xz
tailscale-andrew/keyfallback.zip
control/keyfallback: add baked-in fallback for control keyandrew/keyfallback
Similar to how we bake in the DERPMap to ensure that we can reach the DERP servers if DNS isn't working, also bake in the control key for the default control server that we use if the control server is down. Updates #13890 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I18ef0381e266bd3db10063685993bc3cb76b2f42
Diffstat (limited to 'control/keyfallback/keyfallback.go')
-rw-r--r--control/keyfallback/keyfallback.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/control/keyfallback/keyfallback.go b/control/keyfallback/keyfallback.go
new file mode 100644
index 000000000..44a190f69
--- /dev/null
+++ b/control/keyfallback/keyfallback.go
@@ -0,0 +1,32 @@
+// Copyright (c) Tailscale Inc & AUTHORS
+// SPDX-License-Identifier: BSD-3-Clause
+
+// Package keyfallback contains a fallback mechanism for starting up Tailscale
+// when the control server cannot be reached to obtain the primary Noise key.
+//
+// The data is backed by a JSON file `control-key.json` that is updated by
+// `update.go`:
+//
+// (cd control/keyfallback; go run update.go)
+package keyfallback
+
+import (
+ _ "embed"
+ "encoding/json"
+
+ "tailscale.com/tailcfg"
+)
+
+// Get returns the fallback control server public key that was baked into the
+// binary at compile time. It is only valid for the main Tailscale control
+// server instance.
+func Get() (*tailcfg.OverTLSPublicKeyResponse, error) {
+ out := &tailcfg.OverTLSPublicKeyResponse{}
+ if err := json.Unmarshal(controlKeyJSON, out); err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+//go:embed control-key.json
+var controlKeyJSON []byte