mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
wgengine/magicsock: document and enforce that peerInfo.ep is non-nil.
Signed-off-by: David Anderson <danderson@tailscale.com> (cherry picked from commit 2aa5df7ac1d6cf35f91966644b78a81eb3b7d154)
This commit is contained in:
parent
ee02c95259
commit
5cf0619cb2
@ -72,7 +72,7 @@ func useDerpRoute() bool {
|
|||||||
// peerInfo is all the information magicsock tracks about a particular
|
// peerInfo is all the information magicsock tracks about a particular
|
||||||
// peer.
|
// peer.
|
||||||
type peerInfo struct {
|
type peerInfo struct {
|
||||||
ep *endpoint // optional, if wireguard-go isn't currently talking to this peer.
|
ep *endpoint // always non-nil.
|
||||||
// ipPorts is an inverted version of peerMap.byIPPort (below), so
|
// ipPorts is an inverted version of peerMap.byIPPort (below), so
|
||||||
// that when we're deleting this node, we can rapidly find out the
|
// that when we're deleting this node, we can rapidly find out the
|
||||||
// keys that need deleting from peerMap.byIPPort without having to
|
// keys that need deleting from peerMap.byIPPort without having to
|
||||||
@ -80,8 +80,9 @@ type peerInfo struct {
|
|||||||
ipPorts map[netaddr.IPPort]bool
|
ipPorts map[netaddr.IPPort]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPeerInfo() *peerInfo {
|
func newPeerInfo(ep *endpoint) *peerInfo {
|
||||||
return &peerInfo{
|
return &peerInfo{
|
||||||
|
ep: ep,
|
||||||
ipPorts: map[netaddr.IPPort]bool{},
|
ipPorts: map[netaddr.IPPort]bool{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +170,7 @@ func (m *peerMap) forEachEndpointWithDiscoKey(dk tailcfg.DiscoKey, f func(ep *en
|
|||||||
func (m *peerMap) upsertEndpoint(ep *endpoint) {
|
func (m *peerMap) upsertEndpoint(ep *endpoint) {
|
||||||
pi := m.byNodeKey[ep.publicKey]
|
pi := m.byNodeKey[ep.publicKey]
|
||||||
if pi == nil {
|
if pi == nil {
|
||||||
pi = newPeerInfo()
|
pi = newPeerInfo(ep)
|
||||||
m.byNodeKey[ep.publicKey] = pi
|
m.byNodeKey[ep.publicKey] = pi
|
||||||
}
|
}
|
||||||
old := pi.ep
|
old := pi.ep
|
||||||
|
Loading…
x
Reference in New Issue
Block a user