types/netmap: use new node key type.

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/3204/head
David Anderson 3 years ago
parent 96ad68c5d6
commit 6e5175373e

@ -10,6 +10,7 @@ import (
"sort" "sort"
"strconv" "strconv"
"go4.org/mem"
"inet.af/netaddr" "inet.af/netaddr"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/types/key" "tailscale.com/types/key"
@ -112,7 +113,7 @@ func (ms *mapSession) netmapForResponse(resp *tailcfg.MapResponse) *netmap.Netwo
nm := &netmap.NetworkMap{ nm := &netmap.NetworkMap{
NodeKey: tailcfg.NodeKey(ms.privateNodeKey.Public()), NodeKey: tailcfg.NodeKey(ms.privateNodeKey.Public()),
PrivateKey: ms.privateNodeKey, PrivateKey: key.NodePrivateFromRaw32(mem.B(ms.privateNodeKey[:])),
MachineKey: ms.machinePubKey, MachineKey: ms.machinePubKey,
Peers: resp.Peers, Peers: resp.Peers,
UserProfiles: make(map[tailcfg.UserID]tailcfg.UserProfile), UserProfiles: make(map[tailcfg.UserID]tailcfg.UserProfile),

@ -15,7 +15,6 @@ import (
"inet.af/netaddr" "inet.af/netaddr"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/types/key" "tailscale.com/types/key"
"tailscale.com/types/wgkey"
"tailscale.com/wgengine/filter" "tailscale.com/wgengine/filter"
) )
@ -28,7 +27,7 @@ type NetworkMap struct {
SelfNode *tailcfg.Node SelfNode *tailcfg.Node
NodeKey tailcfg.NodeKey NodeKey tailcfg.NodeKey
PrivateKey wgkey.Private PrivateKey key.NodePrivate
Expiry time.Time Expiry time.Time
// Name is the DNS name assigned to this node. // Name is the DNS name assigned to this node.
Name string Name string

@ -106,7 +106,7 @@ func setupWGTest(b *testing.B, logf logger.Logf, traf *TrafficGen, a1, a2 netadd
} }
e2.SetNetworkMap(&netmap.NetworkMap{ e2.SetNetworkMap(&netmap.NetworkMap{
NodeKey: tailcfg.NodeKeyFromNodePublic(k2.Public()), NodeKey: tailcfg.NodeKeyFromNodePublic(k2.Public()),
PrivateKey: k2.AsWGPrivate(), PrivateKey: k2,
Peers: []*tailcfg.Node{&n}, Peers: []*tailcfg.Node{&n},
}) })
@ -143,7 +143,7 @@ func setupWGTest(b *testing.B, logf logger.Logf, traf *TrafficGen, a1, a2 netadd
} }
e1.SetNetworkMap(&netmap.NetworkMap{ e1.SetNetworkMap(&netmap.NetworkMap{
NodeKey: tailcfg.NodeKeyFromNodePublic(k1.Public()), NodeKey: tailcfg.NodeKeyFromNodePublic(k1.Public()),
PrivateKey: k1.AsWGPrivate(), PrivateKey: k1,
Peers: []*tailcfg.Node{&n}, Peers: []*tailcfg.Node{&n},
}) })

@ -256,7 +256,7 @@ func meshStacks(logf logger.Logf, mutateNetmap func(idx int, nm *netmap.NetworkM
buildNetmapLocked := func(myIdx int) *netmap.NetworkMap { buildNetmapLocked := func(myIdx int) *netmap.NetworkMap {
me := ms[myIdx] me := ms[myIdx]
nm := &netmap.NetworkMap{ nm := &netmap.NetworkMap{
PrivateKey: me.privateKey, PrivateKey: key.NodePrivateFromRaw32(mem.B(me.privateKey[:])),
NodeKey: tailcfg.NodeKey(me.privateKey.Public()), NodeKey: tailcfg.NodeKey(me.privateKey.Public()),
Addresses: []netaddr.IPPrefix{netaddr.IPPrefixFrom(netaddr.IPv4(1, 0, 0, byte(myIdx+1)), 32)}, Addresses: []netaddr.IPPrefix{netaddr.IPPrefixFrom(netaddr.IPv4(1, 0, 0, byte(myIdx+1)), 32)},
} }

@ -55,7 +55,7 @@ func cidrIsSubnet(node *tailcfg.Node, cidr netaddr.IPPrefix) bool {
func WGCfg(nm *netmap.NetworkMap, logf logger.Logf, flags netmap.WGConfigFlags, exitNode tailcfg.StableNodeID) (*wgcfg.Config, error) { func WGCfg(nm *netmap.NetworkMap, logf logger.Logf, flags netmap.WGConfigFlags, exitNode tailcfg.StableNodeID) (*wgcfg.Config, error) {
cfg := &wgcfg.Config{ cfg := &wgcfg.Config{
Name: "tailscale", Name: "tailscale",
PrivateKey: key.NodePrivateFromRaw32(mem.B(nm.PrivateKey[:])), PrivateKey: nm.PrivateKey,
Addresses: nm.Addresses, Addresses: nm.Addresses,
Peers: make([]wgcfg.Peer, 0, len(nm.Peers)), Peers: make([]wgcfg.Peer, 0, len(nm.Peers)),
} }

Loading…
Cancel
Save