mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-22 02:50:42 +00:00
tailcfg: move NodeKey type to types/key.
This leaves behind a type alias and associated constructor, to allow for gradual switchover. Updates #3206. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
@@ -78,8 +78,11 @@ func (u StableNodeID) IsZero() bool {
|
||||
return u == ""
|
||||
}
|
||||
|
||||
// NodeKey is the curve25519 public key for a node.
|
||||
type NodeKey [32]byte
|
||||
// NodeKey is the WireGuard public key for a node.
|
||||
//
|
||||
// Deprecated: prefer to use key.NodePublic instead. If you must have
|
||||
// a NodeKey, use NodePublic.AsNodeKey.
|
||||
type NodeKey = key.NodeKey
|
||||
|
||||
// NodeKeyFromNodePublic returns k converted to a NodeKey.
|
||||
//
|
||||
@@ -87,14 +90,14 @@ type NodeKey [32]byte
|
||||
// gets removed from the codebase. Do not introduce new uses that
|
||||
// aren't related to #3206.
|
||||
func NodeKeyFromNodePublic(k key.NodePublic) NodeKey {
|
||||
return k.Raw32()
|
||||
return k.AsNodeKey()
|
||||
}
|
||||
|
||||
// DiscoKey is the curve25519 public key for path discovery key.
|
||||
// It's never written to disk or reused between network start-ups.
|
||||
type DiscoKey [32]byte
|
||||
|
||||
// NodeKeyFromNodePublic returns k converted to a DiscoKey.
|
||||
// DiscoKeyFromNodePublic returns k converted to a DiscoKey.
|
||||
//
|
||||
// Deprecated: exists only as a compatibility bridge while DiscoKey
|
||||
// gets removed from the codebase. Do not introduce new uses that
|
||||
@@ -1145,28 +1148,6 @@ func keyMarshalText(prefix string, k [32]byte) []byte {
|
||||
return appendKey(nil, prefix, k)
|
||||
}
|
||||
|
||||
func (k NodeKey) ShortString() string { return key.NodePublicFromRaw32(mem.B(k[:])).ShortString() }
|
||||
|
||||
func (k NodeKey) String() string { return fmt.Sprintf("nodekey:%x", k[:]) }
|
||||
func (k NodeKey) MarshalText() ([]byte, error) {
|
||||
nk := key.NodePublicFromRaw32(mem.B(k[:]))
|
||||
return nk.MarshalText()
|
||||
}
|
||||
func (k *NodeKey) UnmarshalText(text []byte) error {
|
||||
var nk key.NodePublic
|
||||
if err := nk.UnmarshalText(text); err != nil {
|
||||
return err
|
||||
}
|
||||
nk.AppendTo(k[:0])
|
||||
return nil
|
||||
}
|
||||
func (k NodeKey) AsNodePublic() key.NodePublic {
|
||||
return key.NodePublicFromRaw32(mem.B(k[:]))
|
||||
}
|
||||
|
||||
// IsZero reports whether k is the zero value.
|
||||
func (k NodeKey) IsZero() bool { return k == NodeKey{} }
|
||||
|
||||
func (k DiscoKey) String() string { return fmt.Sprintf("discokey:%x", k[:]) }
|
||||
func (k DiscoKey) MarshalText() ([]byte, error) {
|
||||
dk := key.DiscoPublicFromRaw32(mem.B(k[:]))
|
||||
|
Reference in New Issue
Block a user