Fix possible blocker if the bind will be closed earlier then proxy

This commit is contained in:
Zoltán Papp
2025-02-17 22:03:15 +01:00
parent 1963644c99
commit 3d80a25b4d
2 changed files with 21 additions and 6 deletions

View File

@@ -13,8 +13,14 @@ import (
"github.com/netbirdio/netbird/client/iface/bind"
)
type IceBind interface {
SetEndpoint(addr *net.UDPAddr, conn net.Conn) (*net.UDPAddr, error)
RemoveEndpoint(addr *net.UDPAddr)
Recv(ctx context.Context, msg bind.RecvMessage)
}
type ProxyBind struct {
bind *bind.ICEBind
bind IceBind
// wgEndpoint is a fake address that generated by the Bind.SetEndpoint based on the remote NetBird peer address
wgRelayedEndpoint *bind.Endpoint
@@ -30,7 +36,7 @@ type ProxyBind struct {
isStarted bool
}
func NewProxyBind(bind *bind.ICEBind) *ProxyBind {
func NewProxyBind(bind IceBind) *ProxyBind {
return &ProxyBind{
bind: bind,
pausedCond: sync.NewCond(&sync.Mutex{}),
@@ -172,7 +178,7 @@ func (p *ProxyBind) proxyToLocal(ctx context.Context) {
Endpoint: p.wgCurrentUsed,
Buffer: buf[:n],
}
p.bind.RecvChan <- msg
p.bind.Recv(ctx, msg)
p.pausedCond.L.Unlock()
}
}