mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-20 09:16:40 +00:00
Fix possible blocker if the bind will be closed earlier then proxy
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user