Skip to content

Commit

Permalink
[relay-client] Fix Relay disconnection handling (#2680)
Browse files Browse the repository at this point in the history
* Fix Relay disconnection handling

If has an active P2P connection meanwhile the Relay connection broken with the server then we removed the WireGuard peer configuration.

* Change logs
  • Loading branch information
pappz authored Oct 1, 2024
1 parent 24c0aaa commit ee0ea86
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/internal/peer/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,17 @@ func (conn *Conn) onWorkerRelayStateDisconnected() {
return
}

if conn.wgProxyRelay != nil {
log.Debugf("relayed connection is closed, clean up WireGuard config")
log.Debugf("relay connection is disconnected")

if conn.currentConnPriority == connPriorityRelay {
log.Debugf("clean up WireGuard config")
err := conn.config.WgConfig.WgInterface.RemovePeer(conn.config.WgConfig.RemoteKey)
if err != nil {
conn.log.Errorf("failed to remove wg endpoint: %v", err)
}
}

if conn.wgProxyRelay != nil {
conn.endpointRelay = nil
_ = conn.wgProxyRelay.CloseConn()
conn.wgProxyRelay = nil
Expand Down

0 comments on commit ee0ea86

Please sign in to comment.