Extend the proxy interface with RedirectTo function and implement it in Bind proxy

This commit is contained in:
Zoltán Papp
2025-02-17 15:47:20 +01:00
parent ffe74365a8
commit 1f088b7e69
6 changed files with 80 additions and 29 deletions
+10 -1
View File
@@ -370,18 +370,26 @@ func (conn *Conn) onICEConnectionIsReady(priority ConnPriority, iceConnInfo ICEC
conn.workerRelay.DisableWgWatcher()
if conn.wgProxyRelay != nil {
conn.log.Debugf("pause Relayed proxy")
conn.wgProxyRelay.Pause()
}
if wgProxy != nil {
conn.log.Debugf("run ICE proxy")
wgProxy.Work()
}
conn.log.Infof("configure WireGuard endpoint to: %s", ep.String())
if err = conn.endpointUpdater.configureWGEndpoint(ep); err != nil {
conn.handleConfigurationFailure(err, wgProxy)
return
}
wgConfigWorkaround()
if conn.wgProxyRelay != nil {
conn.wgProxyRelay.RedirectTo(ep)
}
conn.currentConnPriority = priority
conn.statusICE.Set(StatusConnected)
conn.updateIceState(iceConnInfo)
@@ -407,11 +415,12 @@ func (conn *Conn) onICEStateDisconnected() {
// switch back to relay connection
if conn.isReadyToUpgrade() {
conn.log.Infof("ICE disconnected, set Relay to active connection")
conn.wgProxyRelay.Work()
if err := conn.endpointUpdater.configureWGEndpoint(conn.wgProxyRelay.EndpointAddr()); err != nil {
conn.log.Errorf("failed to switch to relay conn: %v", err)
}
conn.wgProxyRelay.Work()
conn.workerRelay.EnableWgWatcher(conn.ctx)
conn.currentConnPriority = connPriorityRelay
} else {