mirror of
https://github.com/netbirdio/netbird.git
synced 2025-05-29 22:31:50 +02:00
Handle conn store in thread safe way (#1047)
* Handle conn store in thread safe way * Change log line * Fix proper error handling
This commit is contained in:
parent
24e19ae287
commit
d9686bae92
@ -12,7 +12,7 @@ func NewFactory(wgPort int) *Factory {
|
|||||||
ebpfProxy := NewWGEBPFProxy(wgPort)
|
ebpfProxy := NewWGEBPFProxy(wgPort)
|
||||||
err := ebpfProxy.Listen()
|
err := ebpfProxy.Listen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to initialize ebpf proxy: %s", err)
|
log.Warnf("failed to initialize ebpf proxy, fallback to user space proxy: %s", err)
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func (p *WGEBPFProxy) Listen() error {
|
|||||||
p.conn, err = net.ListenUDP("udp", &addr)
|
p.conn, err = net.ListenUDP("udp", &addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cErr := p.Free()
|
cErr := p.Free()
|
||||||
if err != nil {
|
if cErr != nil {
|
||||||
log.Errorf("failed to close the wgproxy: %s", cErr)
|
log.Errorf("failed to close the wgproxy: %s", cErr)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@ -153,7 +153,9 @@ func (p *WGEBPFProxy) proxyToRemote() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.turnConnMutex.Lock()
|
||||||
conn, ok := p.turnConnStore[uint16(addr.Port)]
|
conn, ok := p.turnConnStore[uint16(addr.Port)]
|
||||||
|
p.turnConnMutex.Unlock()
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Errorf("turn conn not found by port: %d", addr.Port)
|
log.Errorf("turn conn not found by port: %d", addr.Port)
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user