mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 08:03:30 +01: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)
|
||||
err := ebpfProxy.Listen()
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ func (p *WGEBPFProxy) Listen() error {
|
||||
p.conn, err = net.ListenUDP("udp", &addr)
|
||||
if err != nil {
|
||||
cErr := p.Free()
|
||||
if err != nil {
|
||||
if cErr != nil {
|
||||
log.Errorf("failed to close the wgproxy: %s", cErr)
|
||||
}
|
||||
return err
|
||||
@ -153,7 +153,9 @@ func (p *WGEBPFProxy) proxyToRemote() {
|
||||
return
|
||||
}
|
||||
|
||||
p.turnConnMutex.Lock()
|
||||
conn, ok := p.turnConnStore[uint16(addr.Port)]
|
||||
p.turnConnMutex.Unlock()
|
||||
if !ok {
|
||||
log.Errorf("turn conn not found by port: %d", addr.Port)
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user