mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-23 09:06:24 +00:00
types/key,wgengine/magicsock,control/controlclient,ipn: add debug disco key rotation
Adds the ability to rotate discovery keys on running clients, needed for testing upcoming disco key distribution changes. Introduces key.DiscoKey, an atomic container for a disco private key, public key, and the public key's ShortString, replacing the prior separate atomic fields. magicsock.Conn has a new RotateDiscoKey method, and access to this is provided via localapi and a CLI debug command. Note that this implementation is primarily for testing as it stands, and regular use should likely introduce an additional mechanism that allows the old key to be used for some time, to provide a seamless key rotation rather than one that invalidates all sessions. Updates tailscale/corp#34037 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
committed by
James Tucker
parent
da508c504d
commit
c09c95ef67
@@ -20,6 +20,32 @@ import (
|
||||
"tailscale.com/util/eventbus/eventbustest"
|
||||
)
|
||||
|
||||
func TestSetDiscoPublicKey(t *testing.T) {
|
||||
initialKey := key.NewDisco().Public()
|
||||
|
||||
c := &Direct{
|
||||
discoPubKey: initialKey,
|
||||
}
|
||||
|
||||
c.mu.Lock()
|
||||
if c.discoPubKey != initialKey {
|
||||
t.Fatalf("initial disco key mismatch: got %v, want %v", c.discoPubKey, initialKey)
|
||||
}
|
||||
c.mu.Unlock()
|
||||
|
||||
newKey := key.NewDisco().Public()
|
||||
c.SetDiscoPublicKey(newKey)
|
||||
|
||||
c.mu.Lock()
|
||||
if c.discoPubKey != newKey {
|
||||
t.Fatalf("disco key not updated: got %v, want %v", c.discoPubKey, newKey)
|
||||
}
|
||||
if c.discoPubKey == initialKey {
|
||||
t.Fatal("disco key should have changed")
|
||||
}
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
func TestNewDirect(t *testing.T) {
|
||||
hi := hostinfo.New()
|
||||
ni := tailcfg.NetInfo{LinkType: "wired"}
|
||||
|
||||
Reference in New Issue
Block a user