From 01e176af3c2b36c7da3bfd8f92f7f578ecd4fbd6 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 3 Feb 2021 17:52:31 +0100 Subject: [PATCH] device: take peer handshake when reinitializing last sent handshake This papers over other unrelated races, unfortunately. Signed-off-by: Jason A. Donenfeld --- device/peer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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()