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:
Zoltan Papp
2023-08-03 18:24:23 +02:00
committed by GitHub
parent 24e19ae287
commit d9686bae92
2 changed files with 4 additions and 2 deletions

View File

@@ -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