mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-21 02:08:40 +02:00
Fix sonar issue
This commit is contained in:
parent
08022dca10
commit
ff167e2907
@ -413,25 +413,9 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
|
|||||||
conn.log.Infof("set ICE to active connection")
|
conn.log.Infof("set ICE to active connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
endpoint, wgProxy, err := conn.getEndpointForICEConnInfo(iceConnInfo)
|
||||||
endpoint net.Addr
|
if err != nil {
|
||||||
wgProxy wgproxy.Proxy
|
return
|
||||||
)
|
|
||||||
if iceConnInfo.RelayedOnLocal {
|
|
||||||
conn.log.Debugf("setup ice turn connection")
|
|
||||||
wgProxy = conn.wgProxyFactory.GetProxy(conn.ctx)
|
|
||||||
ep, err := wgProxy.AddTurnConn(iceConnInfo.RemoteConn)
|
|
||||||
if err != nil {
|
|
||||||
conn.log.Errorf("failed to add turn net.Conn to local proxy: %v", err)
|
|
||||||
err = wgProxy.CloseConn()
|
|
||||||
if err != nil {
|
|
||||||
conn.log.Warnf("failed to close turn proxy connection: %v", err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
endpoint = ep
|
|
||||||
} else {
|
|
||||||
endpoint = iceConnInfo.RemoteConn.RemoteAddr()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endpointUdpAddr, _ := net.ResolveUDPAddr(endpoint.Network(), endpoint.String())
|
endpointUdpAddr, _ := net.ResolveUDPAddr(endpoint.Network(), endpoint.String())
|
||||||
@ -444,7 +428,7 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := conn.config.WgConfig.WgInterface.UpdatePeer(conn.config.WgConfig.RemoteKey, conn.config.WgConfig.AllowedIps, defaultWgKeepAlive, endpointUdpAddr, conn.config.WgConfig.PreSharedKey)
|
err = conn.config.WgConfig.WgInterface.UpdatePeer(conn.config.WgConfig.RemoteKey, conn.config.WgConfig.AllowedIps, defaultWgKeepAlive, endpointUdpAddr, conn.config.WgConfig.PreSharedKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if wgProxy != nil {
|
if wgProxy != nil {
|
||||||
if err := wgProxy.CloseConn(); err != nil {
|
if err := wgProxy.CloseConn(); err != nil {
|
||||||
@ -742,6 +726,24 @@ func (conn *Conn) freeUpConnID() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (conn *Conn) getEndpointForICEConnInfo(iceConnInfo ICEConnInfo) (net.Addr, wgproxy.Proxy, error) {
|
||||||
|
if !iceConnInfo.RelayedOnLocal {
|
||||||
|
return iceConnInfo.RemoteConn.RemoteAddr(), nil, nil
|
||||||
|
}
|
||||||
|
conn.log.Debugf("setup ice turn connection")
|
||||||
|
wgProxy := conn.wgProxyFactory.GetProxy(conn.ctx)
|
||||||
|
ep, err := wgProxy.AddTurnConn(iceConnInfo.RemoteConn)
|
||||||
|
if err != nil {
|
||||||
|
conn.log.Errorf("failed to add turn net.Conn to local proxy: %v", err)
|
||||||
|
err = wgProxy.CloseConn()
|
||||||
|
if err != nil {
|
||||||
|
conn.log.Warnf("failed to close turn proxy connection: %v", err)
|
||||||
|
}
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return ep, wgProxy, nil
|
||||||
|
}
|
||||||
|
|
||||||
func isRosenpassEnabled(remoteRosenpassPubKey []byte) bool {
|
func isRosenpassEnabled(remoteRosenpassPubKey []byte) bool {
|
||||||
return remoteRosenpassPubKey != nil
|
return remoteRosenpassPubKey != nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user