summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 16:11:33 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 16:11:33 +0100
commit9e728c2eb07e9d551bef2bcb3681ea0afc2dd1a0 (patch)
treeb754e8633d7b725ec6f8d35edc3beff22a373654
parenteaf664e4e9134ab7d5100d7284274a821122fbbc (diff)
device: rename unsafeRemovePeer to removePeerLocked
This matches the new naming scheme of upLocked and downLocked. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--device/device.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/device/device.go b/device/device.go
index 1641c3b..de479bc 100644
--- a/device/device.go
+++ b/device/device.go
@@ -125,12 +125,8 @@ func (device *Device) isUp() bool {
return device.deviceState() == deviceStateUp
}
-/* Converts the peer into a "zombie", which remains in the peer map,
- * but processes no packets and does not exists in the routing table.
- *
- * Must hold device.peers.Mutex
- */
-func unsafeRemovePeer(device *Device, peer *Peer, key NoisePublicKey) {
+// Must hold device.peers.Lock()
+func removePeerLocked(device *Device, peer *Peer, key NoisePublicKey) {
// stop routing and processing of packets
device.allowedips.RemoveByPeer(peer)
peer.Stop()
@@ -245,7 +241,7 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
for key, peer := range device.peers.keyMap {
if peer.handshake.remoteStatic.Equals(publicKey) {
peer.handshake.mutex.RUnlock()
- unsafeRemovePeer(device, peer, key)
+ removePeerLocked(device, peer, key)
peer.handshake.mutex.RLock()
}
}
@@ -334,7 +330,7 @@ func (device *Device) RemovePeer(key NoisePublicKey) {
peer, ok := device.peers.keyMap[key]
if ok {
- unsafeRemovePeer(device, peer, key)
+ removePeerLocked(device, peer, key)
}
}
@@ -343,7 +339,7 @@ func (device *Device) RemoveAllPeers() {
defer device.peers.Unlock()
for key, peer := range device.peers.keyMap {
- unsafeRemovePeer(device, peer, key)
+ removePeerLocked(device, peer, key)
}
device.peers.keyMap = make(map[NoisePublicKey]*Peer)