fix(proxy): prevent deleting wrong tunnel in defer cleanup

Add pointer check before delete to handle race where UpdateLocalSNIs
removes our tunnel and a new one is created for the same hostname.
This commit is contained in:
Laurence
2026-03-13 16:43:16 +00:00
parent d21c09c84f
commit 5eacbb7239

View File

@@ -608,8 +608,10 @@ func (p *SNIProxy) handleConnection(clientConn net.Conn) {
tunnel.count--
if tunnel.count == 0 {
tunnel.cancel()
if p.activeTunnels[hostname] == tunnel {
delete(p.activeTunnels, hostname)
}
}
p.activeTunnelsLock.Unlock()
}()