all: replace tailcfg.DiscoKey with key.DiscoPublic.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2021-11-02 14:41:56 -07:00
committed by Brad Fitzpatrick
parent f771327f0c
commit 0532eb30db
16 changed files with 51 additions and 95 deletions

View File

@@ -14,7 +14,6 @@ import (
"strings"
"time"
"go4.org/mem"
"inet.af/netaddr"
"tailscale.com/types/dnstype"
"tailscale.com/types/key"
@@ -79,19 +78,6 @@ func (u StableNodeID) IsZero() bool {
return u == ""
}
// 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
// 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
// aren't related to #3206.
func DiscoKeyFromDiscoPublic(k key.DiscoPublic) DiscoKey {
return k.Raw32()
}
// User is an IPN user.
//
// A user can have multiple logins associated with it (e.g. gmail and github oauth).
@@ -163,7 +149,7 @@ type Node struct {
Key key.NodePublic
KeyExpiry time.Time
Machine key.MachinePublic
DiscoKey DiscoKey
DiscoKey key.DiscoPublic
Addresses []netaddr.IPPrefix // IP addresses of this Node directly
AllowedIPs []netaddr.IPPrefix // range of IP addresses to route to this node
Endpoints []string `json:",omitempty"` // IP+port (public via STUN, and local LANs)
@@ -751,7 +737,7 @@ type MapRequest struct {
Compress string // "zstd" or "" (no compression)
KeepAlive bool // whether server should send keep-alives back to us
NodeKey key.NodePublic
DiscoKey DiscoKey
DiscoKey key.DiscoPublic
IncludeIPv6 bool `json:",omitempty"` // include IPv6 endpoints in returned Node Endpoints (for Version 4 clients)
Stream bool // if true, multiple MapResponse objects are returned
Hostinfo *Hostinfo
@@ -1138,25 +1124,6 @@ func keyMarshalText(prefix string, k [32]byte) []byte {
return appendKey(nil, prefix, k)
}
func (k DiscoKey) String() string { return fmt.Sprintf("discokey:%x", k[:]) }
func (k DiscoKey) MarshalText() ([]byte, error) {
dk := key.DiscoPublicFromRaw32(mem.B(k[:]))
return dk.MarshalText()
}
func (k *DiscoKey) UnmarshalText(text []byte) error {
var dk key.DiscoPublic
if err := dk.UnmarshalText(text); err != nil {
return err
}
dk.AppendTo(k[:0])
return nil
}
func (k DiscoKey) ShortString() string { return fmt.Sprintf("d:%x", k[:8]) }
func (k DiscoKey) AppendTo(b []byte) []byte { return appendKey(b, "discokey:", k) }
// IsZero reports whether k is the zero value.
func (k DiscoKey) IsZero() bool { return k == DiscoKey{} }
func (id ID) String() string { return fmt.Sprintf("id:%x", int64(id)) }
func (id UserID) String() string { return fmt.Sprintf("userid:%x", int64(id)) }
func (id LoginID) String() string { return fmt.Sprintf("loginid:%x", int64(id)) }