mirror of
https://github.com/fosrl/gerbil.git
synced 2026-03-27 04:56:42 +00:00
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:
@@ -608,7 +608,9 @@ func (p *SNIProxy) handleConnection(clientConn net.Conn) {
|
||||
tunnel.count--
|
||||
if tunnel.count == 0 {
|
||||
tunnel.cancel()
|
||||
delete(p.activeTunnels, hostname)
|
||||
if p.activeTunnels[hostname] == tunnel {
|
||||
delete(p.activeTunnels, hostname)
|
||||
}
|
||||
}
|
||||
p.activeTunnelsLock.Unlock()
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user