mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-28 08:13:11 +00:00
types/persist: use new node key type.
Updates #3206 Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/structs"
|
||||
"tailscale.com/types/wgkey"
|
||||
)
|
||||
|
||||
//go:generate go run tailscale.com/cmd/cloner -type=Persist -output=persist_clone.go
|
||||
@@ -31,8 +30,8 @@ type Persist struct {
|
||||
// this field, lest the frontend persist it to disk.
|
||||
LegacyFrontendPrivateMachineKey key.MachinePrivate `json:"PrivateMachineKey"`
|
||||
|
||||
PrivateNodeKey wgkey.Private
|
||||
OldPrivateNodeKey wgkey.Private // needed to request key rotation
|
||||
PrivateNodeKey key.NodePrivate
|
||||
OldPrivateNodeKey key.NodePrivate // needed to request key rotation
|
||||
Provider string
|
||||
LoginName string
|
||||
}
|
||||
@@ -55,7 +54,7 @@ func (p *Persist) Equals(p2 *Persist) bool {
|
||||
func (p *Persist) Pretty() string {
|
||||
var (
|
||||
mk key.MachinePublic
|
||||
ok, nk wgkey.Key
|
||||
ok, nk key.NodePublic
|
||||
)
|
||||
if !p.LegacyFrontendPrivateMachineKey.IsZero() {
|
||||
mk = p.LegacyFrontendPrivateMachineKey.Public()
|
||||
@@ -66,12 +65,6 @@ func (p *Persist) Pretty() string {
|
||||
if !p.PrivateNodeKey.IsZero() {
|
||||
nk = p.PrivateNodeKey.Public()
|
||||
}
|
||||
ss := func(k wgkey.Key) string {
|
||||
if k.IsZero() {
|
||||
return ""
|
||||
}
|
||||
return k.ShortString()
|
||||
}
|
||||
return fmt.Sprintf("Persist{lm=%v, o=%v, n=%v u=%#v}",
|
||||
mk.ShortString(), ss(ok), ss(nk), p.LoginName)
|
||||
mk.ShortString(), ok.ShortString(), nk.ShortString(), p.LoginName)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ package persist
|
||||
import (
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/structs"
|
||||
"tailscale.com/types/wgkey"
|
||||
)
|
||||
|
||||
// Clone makes a deep copy of Persist.
|
||||
@@ -28,8 +27,8 @@ func (src *Persist) Clone() *Persist {
|
||||
var _PersistCloneNeedsRegeneration = Persist(struct {
|
||||
_ structs.Incomparable
|
||||
LegacyFrontendPrivateMachineKey key.MachinePrivate
|
||||
PrivateNodeKey wgkey.Private
|
||||
OldPrivateNodeKey wgkey.Private
|
||||
PrivateNodeKey key.NodePrivate
|
||||
OldPrivateNodeKey key.NodePrivate
|
||||
Provider string
|
||||
LoginName string
|
||||
}{})
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/wgkey"
|
||||
)
|
||||
|
||||
func fieldsOf(t reflect.Type) (fields []string) {
|
||||
@@ -28,15 +27,8 @@ func TestPersistEqual(t *testing.T) {
|
||||
have, persistHandles)
|
||||
}
|
||||
|
||||
newPrivate := func() wgkey.Private {
|
||||
k, err := wgkey.NewPrivate()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return k
|
||||
}
|
||||
m1 := key.NewMachine()
|
||||
k1 := newPrivate()
|
||||
k1 := key.NewNode()
|
||||
tests := []struct {
|
||||
a, b *Persist
|
||||
want bool
|
||||
@@ -59,7 +51,7 @@ func TestPersistEqual(t *testing.T) {
|
||||
|
||||
{
|
||||
&Persist{PrivateNodeKey: k1},
|
||||
&Persist{PrivateNodeKey: newPrivate()},
|
||||
&Persist{PrivateNodeKey: key.NewNode()},
|
||||
false,
|
||||
},
|
||||
{
|
||||
@@ -70,7 +62,7 @@ func TestPersistEqual(t *testing.T) {
|
||||
|
||||
{
|
||||
&Persist{OldPrivateNodeKey: k1},
|
||||
&Persist{OldPrivateNodeKey: newPrivate()},
|
||||
&Persist{OldPrivateNodeKey: key.NewNode()},
|
||||
false,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user