Reducate cognitive complexity

This commit is contained in:
Zoltán Papp
2024-10-07 12:52:55 +02:00
parent 718d9526a7
commit 9e7aac3a56

View File

@@ -458,16 +458,7 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon
}
if err = conn.configureWGEndpoint(ep); err != nil {
conn.log.Warnf("Failed to update wg peer configuration: %v", err)
if wgProxy != nil {
if ierr := wgProxy.CloseConn(); ierr != nil {
conn.log.Warnf("Failed to close wg proxy: %v", ierr)
}
}
if conn.wgProxyRelay != nil {
conn.wgProxyRelay.Work()
}
conn.handleConfigurationFailure(err, wgProxy)
return
}
wgConfigWorkaround()
@@ -810,6 +801,18 @@ func (conn *Conn) notifyReconnectLoopICEDisconnected(changed bool) {
}
}
func (conn *Conn) handleConfigurationFailure(err error, wgProxy wgproxy.Proxy) {
conn.log.Warnf("Failed to update wg peer configuration: %v", err)
if wgProxy != nil {
if ierr := wgProxy.CloseConn(); ierr != nil {
conn.log.Warnf("Failed to close wg proxy: %v", ierr)
}
}
if conn.wgProxyRelay != nil {
conn.wgProxyRelay.Work()
}
}
func isRosenpassEnabled(remoteRosenpassPubKey []byte) bool {
return remoteRosenpassPubKey != nil
}