From a54f3fc681ffc2b3369470e0889a7f9e23003d60 Mon Sep 17 00:00:00 2001 From: Wade Simmons Date: Sun, 2 Aug 2020 20:59:50 -0400 Subject: [PATCH] fix fast handshake trigger for static hosts (#265) We are currently triggering a fast handshake for static hosts right inside HandshakeManager.AddVpnIP, but this can actually trigger before we have generated the handshake packet to use. Instead, we should be triggering right after we call ixHandshakeStage0 in getOrHandshake (which generates the handshake packet) --- handshake_manager.go | 8 -------- inside.go | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/handshake_manager.go b/handshake_manager.go index a0b04d4..ca496bc 100644 --- a/handshake_manager.go +++ b/handshake_manager.go @@ -201,14 +201,6 @@ func (c *HandshakeManager) AddVpnIP(vpnIP uint32) *HostInfo { // main receive thread for very long by waiting to add items to the pending map c.OutboundHandshakeTimer.Add(vpnIP, c.config.tryInterval) - // If this is a static host, we don't need to wait for the HostQueryReply - // We can trigger the handshake right now - if _, ok := c.lightHouse.staticList[vpnIP]; ok { - select { - case c.trigger <- vpnIP: - default: - } - } return hostinfo } diff --git a/inside.go b/inside.go index 6e65559..9663d71 100644 --- a/inside.go +++ b/inside.go @@ -94,6 +94,15 @@ func (f *Interface) getOrHandshake(vpnIp uint32) *HostInfo { ixHandshakeStage0(f, vpnIp, hostinfo) // FIXME: Maybe make XX selectable, but probably not since psk makes it nearly pointless for us. //xx_handshakeStage0(f, ip, hostinfo) + + // If this is a static host, we don't need to wait for the HostQueryReply + // We can trigger the handshake right now + if _, ok := f.lightHouse.staticList[vpnIp]; ok { + select { + case f.handshakeManager.trigger <- vpnIp: + default: + } + } } return hostinfo