mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-24 01:26:39 +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
@@ -146,15 +146,22 @@ func TestProbeUDPLifetimeConfig_Valid(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
var lowerPriv, higherPriv key.DiscoPrivate
|
||||
var lower, higher key.DiscoPublic
|
||||
a := key.NewDisco().Public()
|
||||
b := key.NewDisco().Public()
|
||||
privA := key.NewDisco()
|
||||
privB := key.NewDisco()
|
||||
a := privA.Public()
|
||||
b := privB.Public()
|
||||
if a.String() < b.String() {
|
||||
lower = a
|
||||
higher = b
|
||||
lowerPriv = privA
|
||||
higherPriv = privB
|
||||
} else {
|
||||
lower = b
|
||||
higher = a
|
||||
lowerPriv = privB
|
||||
higherPriv = privA
|
||||
}
|
||||
addr := addrQuality{epAddr: epAddr{ap: netip.MustParseAddrPort("1.1.1.1:1")}}
|
||||
newProbeUDPLifetime := func() *probeUDPLifetime {
|
||||
@@ -281,10 +288,18 @@ func Test_endpoint_maybeProbeUDPLifetimeLocked(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c := &Conn{}
|
||||
if tt.localDisco.IsZero() {
|
||||
c.discoAtomic.Set(key.NewDisco())
|
||||
} else if tt.localDisco.Compare(lower) == 0 {
|
||||
c.discoAtomic.Set(lowerPriv)
|
||||
} else if tt.localDisco.Compare(higher) == 0 {
|
||||
c.discoAtomic.Set(higherPriv)
|
||||
} else {
|
||||
t.Fatalf("unexpected localDisco value")
|
||||
}
|
||||
de := &endpoint{
|
||||
c: &Conn{
|
||||
discoPublic: tt.localDisco,
|
||||
},
|
||||
c: c,
|
||||
bestAddr: tt.bestAddr,
|
||||
}
|
||||
if tt.remoteDisco != nil {
|
||||
|
||||
Reference in New Issue
Block a user