mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-20 15:10:43 +00:00
wgengine/magicsock: use key.NodePublic instead of tailcfg.NodeKey.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
d6e7cec6a7
commit
72ace0acba
@@ -1140,7 +1140,7 @@ func TestDiscoMessage(t *testing.T) {
|
||||
DiscoKey: tailcfg.DiscoKeyFromDiscoPublic(peer1Pub),
|
||||
}
|
||||
c.peerMap.upsertEndpoint(&endpoint{
|
||||
publicKey: n.Key,
|
||||
publicKey: n.Key.AsNodePublic(),
|
||||
discoKey: key.DiscoPublicFromRaw32(mem.B(n.DiscoKey[:])),
|
||||
})
|
||||
|
||||
@@ -1153,7 +1153,7 @@ func TestDiscoMessage(t *testing.T) {
|
||||
|
||||
box := peer1Priv.Shared(c.discoPrivate.Public()).Seal([]byte(payload))
|
||||
pkt = append(pkt, box...)
|
||||
got := c.handleDiscoMessage(pkt, netaddr.IPPort{}, tailcfg.NodeKey{})
|
||||
got := c.handleDiscoMessage(pkt, netaddr.IPPort{}, key.NodePublic{})
|
||||
if !got {
|
||||
t.Error("failed to open it")
|
||||
}
|
||||
@@ -1184,7 +1184,7 @@ func Test32bitAlignment(t *testing.T) {
|
||||
called := 0
|
||||
de := endpoint{
|
||||
c: &Conn{
|
||||
noteRecvActivity: func(tailcfg.NodeKey) { called++ },
|
||||
noteRecvActivity: func(key.NodePublic) { called++ },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1223,17 +1223,16 @@ func newTestConn(t testing.TB) *Conn {
|
||||
// addTestEndpoint sets conn's network map to a single peer expected
|
||||
// to receive packets from sendConn (or DERP), and returns that peer's
|
||||
// nodekey and discokey.
|
||||
func addTestEndpoint(tb testing.TB, conn *Conn, sendConn net.PacketConn) (tailcfg.NodeKey, key.DiscoPublic) {
|
||||
func addTestEndpoint(tb testing.TB, conn *Conn, sendConn net.PacketConn) (key.NodePublic, key.DiscoPublic) {
|
||||
// Give conn just enough state that it'll recognize sendConn as a
|
||||
// valid peer and not fall through to the legacy magicsock
|
||||
// codepath.
|
||||
discoKey := key.DiscoPublicFromRaw32(mem.B([]byte{31: 1}))
|
||||
nodeKey := key.NodePublicFromRaw32(mem.B([]byte{0: 'N', 1: 'K', 31: 0}))
|
||||
tnk := nodeKey.AsNodeKey()
|
||||
conn.SetNetworkMap(&netmap.NetworkMap{
|
||||
Peers: []*tailcfg.Node{
|
||||
{
|
||||
Key: tnk,
|
||||
Key: nodeKey.AsNodeKey(),
|
||||
DiscoKey: tailcfg.DiscoKeyFromDiscoPublic(discoKey),
|
||||
Endpoints: []string{sendConn.LocalAddr().String()},
|
||||
},
|
||||
@@ -1244,8 +1243,8 @@ func addTestEndpoint(tb testing.TB, conn *Conn, sendConn net.PacketConn) (tailcf
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
conn.addValidDiscoPathForTest(tnk, netaddr.MustParseIPPort(sendConn.LocalAddr().String()))
|
||||
return tnk, discoKey
|
||||
conn.addValidDiscoPathForTest(nodeKey, netaddr.MustParseIPPort(sendConn.LocalAddr().String()))
|
||||
return nodeKey, discoKey
|
||||
}
|
||||
|
||||
func setUpReceiveFrom(tb testing.TB) (roundTrip func()) {
|
||||
@@ -1405,19 +1404,19 @@ func TestSetNetworkMapChangingNodeKey(t *testing.T) {
|
||||
conn.SetPrivateKey(key.NodePrivateFromRaw32(mem.B([]byte{0: 1, 31: 0})))
|
||||
|
||||
discoKey := key.DiscoPublicFromRaw32(mem.B([]byte{31: 1}))
|
||||
nodeKey1 := tailcfg.NodeKey{0: 'N', 1: 'K', 2: '1'}
|
||||
nodeKey2 := tailcfg.NodeKey{0: 'N', 1: 'K', 2: '2'}
|
||||
nodeKey1 := key.NodePublicFromRaw32(mem.B([]byte{0: 'N', 1: 'K', 2: '1', 31: 0}))
|
||||
nodeKey2 := key.NodePublicFromRaw32(mem.B([]byte{0: 'N', 1: 'K', 2: '2', 31: 0}))
|
||||
|
||||
conn.SetNetworkMap(&netmap.NetworkMap{
|
||||
Peers: []*tailcfg.Node{
|
||||
{
|
||||
Key: nodeKey1,
|
||||
Key: nodeKey1.AsNodeKey(),
|
||||
DiscoKey: tailcfg.DiscoKeyFromDiscoPublic(discoKey),
|
||||
Endpoints: []string{"192.168.1.2:345"},
|
||||
},
|
||||
},
|
||||
})
|
||||
_, err := conn.ParseEndpoint(key.NodePublicFromRaw32(mem.B(nodeKey1[:])).UntypedHexString())
|
||||
_, err := conn.ParseEndpoint(nodeKey1.UntypedHexString())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1426,7 +1425,7 @@ func TestSetNetworkMapChangingNodeKey(t *testing.T) {
|
||||
conn.SetNetworkMap(&netmap.NetworkMap{
|
||||
Peers: []*tailcfg.Node{
|
||||
{
|
||||
Key: nodeKey2,
|
||||
Key: nodeKey2.AsNodeKey(),
|
||||
DiscoKey: tailcfg.DiscoKeyFromDiscoPublic(discoKey),
|
||||
Endpoints: []string{"192.168.1.2:345"},
|
||||
},
|
||||
@@ -1436,7 +1435,7 @@ func TestSetNetworkMapChangingNodeKey(t *testing.T) {
|
||||
|
||||
de, ok := conn.peerMap.endpointForNodeKey(nodeKey2)
|
||||
if ok && de.publicKey != nodeKey2 {
|
||||
t.Fatalf("discoEndpoint public key = %q; want %q", de.publicKey[:], nodeKey2[:])
|
||||
t.Fatalf("discoEndpoint public key = %q; want %q", de.publicKey, nodeKey2)
|
||||
}
|
||||
if de.discoKey != discoKey {
|
||||
t.Errorf("discoKey = %v; want %v", de.discoKey, discoKey)
|
||||
|
||||
Reference in New Issue
Block a user