derp: move away from [32]byte key types

And some minor cleanup in the process.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2020-02-17 13:52:11 -08:00
committed by Brad Fitzpatrick
parent 4d09316f9a
commit 259406e797
8 changed files with 144 additions and 130 deletions

View File

@@ -22,6 +22,7 @@ import (
"tailscale.com/derp/derphttp"
"tailscale.com/stun"
"tailscale.com/stunner"
"tailscale.com/types/key"
)
// A Conn routes UDP packets and actively manages a list of its endpoints.
@@ -446,12 +447,12 @@ func (c *Conn) ReceiveIPv6(buff []byte) (int, device.Endpoint, *net.UDPAddr, err
return 0, nil, nil, syscall.EAFNOSUPPORT
}
func (c *Conn) SetPrivateKey(privateKey [32]byte) error {
func (c *Conn) SetPrivateKey(privateKey wgcfg.PrivateKey) error {
if c.derpServer == "" {
return nil
}
derp, err := derphttp.NewClient(privateKey, c.derpServer, log.Printf)
derp, err := derphttp.NewClient(key.Private(privateKey), c.derpServer, log.Printf)
if err != nil {
return err
}
@@ -528,7 +529,7 @@ func (c *Conn) LinkChange() {
// AddrSet is a set of UDP addresses that implements wireguard/device.Endpoint.
type AddrSet struct {
publicKey [32]byte // peer public key used for DERP communication
publicKey key.Public // peer public key used for DERP communication
addrs []net.UDPAddr // ordered priority list provided by wgengine
mu sync.Mutex // guards roamAddr and curAddr