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,8 +608,10 @@ func (p *SNIProxy) handleConnection(clientConn net.Conn) {
|
|||||||
tunnel.count--
|
tunnel.count--
|
||||||
if tunnel.count == 0 {
|
if tunnel.count == 0 {
|
||||||
tunnel.cancel()
|
tunnel.cancel()
|
||||||
|
if p.activeTunnels[hostname] == tunnel {
|
||||||
delete(p.activeTunnels, hostname)
|
delete(p.activeTunnels, hostname)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
p.activeTunnelsLock.Unlock()
|
p.activeTunnelsLock.Unlock()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user