summaryrefslogtreecommitdiffhomepage
path: root/device/peer.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-03 17:52:31 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-03 17:52:31 +0100
commit01e176af3c2b36c7da3bfd8f92f7f578ecd4fbd6 (patch)
treec4306dc04222942d819225bc31972655e7111403 /device/peer.go
parent91617b4c522eaa034d39b208edc8221ba52e0954 (diff)
device: take peer handshake when reinitializing last sent handshake
This papers over other unrelated races, unfortunately. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/peer.go')
-rw-r--r--device/peer.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/device/peer.go b/device/peer.go
index 65f73a9..0bf19fd 100644
--- a/device/peer.go
+++ b/device/peer.go
@@ -171,6 +171,10 @@ func (peer *Peer) Start() {
peer.stopping.Wait()
peer.stopping.Add(2)
+ peer.handshake.mutex.Lock()
+ peer.handshake.lastSentHandshake = time.Now().Add(-(RekeyTimeout + time.Second))
+ peer.handshake.mutex.Unlock()
+
// prepare queues
peer.queue.outbound = make(chan *QueueOutboundElement, QueueOutboundSize)
peer.queue.inbound = make(chan *QueueInboundElement, QueueInboundSize)
@@ -180,7 +184,6 @@ func (peer *Peer) Start() {
peer.device.queue.encryption.wg.Add(1) // keep encryption queue open for our writes
peer.timersInit()
- peer.handshake.lastSentHandshake = time.Now().Add(-(RekeyTimeout + time.Second))
go peer.RoutineSequentialSender()
go peer.RoutineSequentialReceiver()