ipn/ipnstate: use key.NodePublic instead of the generic key.Public.

Updates #3206.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2021-10-28 16:56:44 -07:00
committed by Dave Anderson
parent ebae0d95d0
commit c1d009b9e9
6 changed files with 24 additions and 19 deletions

View File

@@ -3081,7 +3081,11 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) {
}
sb.MutateSelfStatus(func(ss *ipnstate.PeerStatus) {
ss.PublicKey = c.privateKey.Public()
if !c.privateKey.IsZero() {
ss.PublicKey = key.NodePrivateFromRaw32(mem.B(c.privateKey[:])).Public()
} else {
ss.PublicKey = key.NodePublic{}
}
ss.Addrs = make([]string, 0, len(c.lastEndpoints))
for _, ep := range c.lastEndpoints {
ss.Addrs = append(ss.Addrs, ep.Addr.String())
@@ -3113,7 +3117,7 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) {
ps := &ipnstate.PeerStatus{InMagicSock: true}
//ps.Addrs = append(ps.Addrs, n.Endpoints...)
ep.populatePeerStatus(ps)
sb.AddPeer(key.Public(ep.publicKey), ps)
sb.AddPeer(key.NodePublicFromRaw32(mem.B(ep.publicKey[:])), ps)
})
c.foreachActiveDerpSortedLocked(func(node int, ad activeDerp) {

View File

@@ -205,8 +205,8 @@ func (s *magicStack) Close() {
s.conn.Close()
}
func (s *magicStack) Public() key.Public {
return s.privateKey.Public().AsPublic()
func (s *magicStack) Public() key.NodePublic {
return s.privateKey.Public()
}
func (s *magicStack) Status() *ipnstate.Status {
@@ -995,10 +995,10 @@ func testTwoDevicePing(t *testing.T, d *devices) {
// Wait for magicsock to be told about peers from meshStacks.
tstest.WaitFor(10*time.Second, func() error {
if p := m1.Status().Peer[m2.privateKey.Public().AsPublic()]; p == nil || !p.InMagicSock {
if p := m1.Status().Peer[m2.Public()]; p == nil || !p.InMagicSock {
return errors.New("m1 not ready")
}
if p := m2.Status().Peer[m1.privateKey.Public().AsPublic()]; p == nil || !p.InMagicSock {
if p := m2.Status().Peer[m1.Public()]; p == nil || !p.InMagicSock {
return errors.New("m2 not ready")
}
return nil

View File

@@ -1242,7 +1242,7 @@ func (e *userspaceEngine) UpdateStatus(sb *ipnstate.StatusBuilder) {
return
}
for _, ps := range st.Peers {
sb.AddPeer(key.Public(ps.NodeKey), &ipnstate.PeerStatus{
sb.AddPeer(key.NodePublicFromRaw32(mem.B(ps.NodeKey[:])), &ipnstate.PeerStatus{
RxBytes: int64(ps.RxBytes),
TxBytes: int64(ps.TxBytes),
LastHandshake: ps.LastHandshake,