Revert "types/key: add MachinePrivate and MachinePublic."

Broke the tailscale control plane due to surprise different serialization.

This reverts commit 4fdb88efe1.
This commit is contained in:
David Anderson
2021-09-03 11:34:34 -07:00
parent 4fdb88efe1
commit 61c3b98a24
24 changed files with 234 additions and 605 deletions

View File

@@ -8,7 +8,6 @@ package persist
import (
"fmt"
"tailscale.com/types/key"
"tailscale.com/types/structs"
"tailscale.com/types/wgkey"
)
@@ -29,7 +28,7 @@ type Persist struct {
// needed. This field should be considered read-only from GUI
// frontends. The real value should not be written back in
// this field, lest the frontend persist it to disk.
LegacyFrontendPrivateMachineKey key.MachinePrivate `json:"PrivateMachineKey"`
LegacyFrontendPrivateMachineKey wgkey.Private `json:"PrivateMachineKey"`
PrivateNodeKey wgkey.Private
OldPrivateNodeKey wgkey.Private // needed to request key rotation
@@ -53,10 +52,7 @@ func (p *Persist) Equals(p2 *Persist) bool {
}
func (p *Persist) Pretty() string {
var (
mk key.MachinePublic
ok, nk wgkey.Key
)
var mk, ok, nk wgkey.Key
if !p.LegacyFrontendPrivateMachineKey.IsZero() {
mk = p.LegacyFrontendPrivateMachineKey.Public()
}
@@ -73,5 +69,5 @@ func (p *Persist) Pretty() string {
return k.ShortString()
}
return fmt.Sprintf("Persist{lm=%v, o=%v, n=%v u=%#v}",
mk.ShortString(), ss(ok), ss(nk), p.LoginName)
ss(mk), ss(ok), ss(nk), p.LoginName)
}

View File

@@ -7,7 +7,6 @@
package persist
import (
"tailscale.com/types/key"
"tailscale.com/types/structs"
"tailscale.com/types/wgkey"
)
@@ -27,7 +26,7 @@ func (src *Persist) Clone() *Persist {
// tailscale.com/cmd/cloner -type Persist
var _PersistNeedsRegeneration = Persist(struct {
_ structs.Incomparable
LegacyFrontendPrivateMachineKey key.MachinePrivate
LegacyFrontendPrivateMachineKey wgkey.Private
PrivateNodeKey wgkey.Private
OldPrivateNodeKey wgkey.Private
Provider string

View File

@@ -8,7 +8,6 @@ import (
"reflect"
"testing"
"tailscale.com/types/key"
"tailscale.com/types/wgkey"
)
@@ -35,7 +34,6 @@ func TestPersistEqual(t *testing.T) {
}
return k
}
m1 := key.NewMachine()
k1 := newPrivate()
tests := []struct {
a, b *Persist
@@ -47,13 +45,13 @@ func TestPersistEqual(t *testing.T) {
{&Persist{}, &Persist{}, true},
{
&Persist{LegacyFrontendPrivateMachineKey: m1},
&Persist{LegacyFrontendPrivateMachineKey: key.NewMachine()},
&Persist{LegacyFrontendPrivateMachineKey: k1},
&Persist{LegacyFrontendPrivateMachineKey: newPrivate()},
false,
},
{
&Persist{LegacyFrontendPrivateMachineKey: m1},
&Persist{LegacyFrontendPrivateMachineKey: m1},
&Persist{LegacyFrontendPrivateMachineKey: k1},
&Persist{LegacyFrontendPrivateMachineKey: k1},
true,
},