Fix eBPF conn close logic

This commit is contained in:
Zoltán Papp 2024-07-30 15:36:10 +02:00
parent aa1a482669
commit e5f8ecdeb7
2 changed files with 8 additions and 2 deletions

View File

@ -556,6 +556,12 @@ func (conn *Conn) onWorkerRelayStateDisconnected() {
defer conn.mu.Unlock()
if conn.wgProxyRelay != nil {
log.Debugf("relayed connection is closed, clean up WireGuard config")
err := conn.config.WgConfig.WgInterface.RemovePeer(conn.config.WgConfig.RemoteKey)
if err != nil {
conn.log.Errorf("failed to remove wg endpoint: %v", err)
}
conn.endpointRelay = nil
_ = conn.wgProxyRelay.CloseConn()
conn.wgProxyRelay = nil

View File

@ -181,8 +181,8 @@ func (p *WGEBPFProxy) proxyToRemote() {
conn, ok := p.turnConnStore[uint16(addr.Port)]
p.turnConnMutex.Unlock()
if !ok {
log.Infof("turn conn not found by port, exit form proxy: %d", addr.Port)
return // todo replace it to return. For debug troubleshooting keep it
log.Debugf("turn conn not found by port because conn already has been closed: %d", addr.Port)
continue
}
_, err = conn.Write(buf[:n])