mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-23 19:21:23 +02:00
Fix eBPF conn close logic
This commit is contained in:
parent
aa1a482669
commit
e5f8ecdeb7
@ -556,6 +556,12 @@ func (conn *Conn) onWorkerRelayStateDisconnected() {
|
|||||||
defer conn.mu.Unlock()
|
defer conn.mu.Unlock()
|
||||||
|
|
||||||
if conn.wgProxyRelay != nil {
|
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.endpointRelay = nil
|
||||||
_ = conn.wgProxyRelay.CloseConn()
|
_ = conn.wgProxyRelay.CloseConn()
|
||||||
conn.wgProxyRelay = nil
|
conn.wgProxyRelay = nil
|
||||||
|
@ -181,8 +181,8 @@ func (p *WGEBPFProxy) proxyToRemote() {
|
|||||||
conn, ok := p.turnConnStore[uint16(addr.Port)]
|
conn, ok := p.turnConnStore[uint16(addr.Port)]
|
||||||
p.turnConnMutex.Unlock()
|
p.turnConnMutex.Unlock()
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Infof("turn conn not found by port, exit form proxy: %d", addr.Port)
|
log.Debugf("turn conn not found by port because conn already has been closed: %d", addr.Port)
|
||||||
return // todo replace it to return. For debug troubleshooting keep it
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = conn.Write(buf[:n])
|
_, err = conn.Write(buf[:n])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user