wgengine, controlclient: fewer pointers in wgcfg key types

Signed-off-by: David Crawshaw <david@zentus.com>
This commit is contained in:
David Crawshaw
2020-02-10 22:04:52 -05:00
parent fef2548981
commit 87334fb332
5 changed files with 44 additions and 14 deletions

View File

@@ -667,6 +667,26 @@ func (a *AddrSet) String() string {
return buf.String()
}
func (a *AddrSet) Addrs() []wgcfg.Endpoint {
var eps []wgcfg.Endpoint
for _, addr := range a.addrs {
eps = append(eps, wgcfg.Endpoint{
Host: addr.IP.String(),
Port: uint16(addr.Port),
})
}
a.mu.Lock()
defer a.mu.Unlock()
if a.roamAddr != nil {
eps = append(eps, wgcfg.Endpoint{
Host: a.roamAddr.IP.String(),
Port: uint16(a.roamAddr.Port),
})
}
return eps
}
func (c *Conn) CreateEndpoint(key [32]byte, s string) (device.Endpoint, error) {
pk := wgcfg.Key(key)
log.Printf("magicsock: CreateEndpoint: key=%s: %s", pk.ShortString(), s)
@@ -723,6 +743,12 @@ func (e *singleEndpoint) DstToBytes() []byte {
func (e *singleEndpoint) UpdateDst(dst *net.UDPAddr) error {
return fmt.Errorf("magicsock.singleEndpoint(%s).UpdateDst(%s): should never be called", (*net.UDPAddr)(e), dst)
}
func (e *singleEndpoint) Addrs() []wgcfg.Endpoint {
return []wgcfg.Endpoint{{
Host: e.IP.String(),
Port: uint16(e.Port),
}}
}
// RebindingUDPConn is a UDP socket that can be re-bound.
// Unix has no notion of re-binding a socket, so we swap it out for a new one.

View File

@@ -356,9 +356,9 @@ func (e *userspaceEngine) getStatus() (*Status, error) {
log.Fatalf("IpcGetOperation: invalid key %#v\n", v)
}
p = &PeerStatus{}
pp[*pk] = p
pp[pk] = p
key := tailcfg.NodeKey(*pk)
key := tailcfg.NodeKey(pk)
p.NodeKey = key
case "rx_bytes":
n, err = strconv.ParseInt(v, 10, 64)