From 6694aebfd96504d5ee8e0a3650575024eaf50ed7 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Thu, 9 Apr 2026 05:56:19 +0400 Subject: [PATCH] fix: resolve 0.0.0.0 to connectable address in CallSetup relay_addr When relay listens on 0.0.0.0, derive the actual IP from the client's connection address for the CallSetup message. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/wzp-relay/src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/wzp-relay/src/main.rs b/crates/wzp-relay/src/main.rs index 02a5829..017c94e 100644 --- a/crates/wzp-relay/src/main.rs +++ b/crates/wzp-relay/src/main.rs @@ -794,10 +794,25 @@ async fn main() -> anyhow::Result<()> { } // Send CallSetup to both parties + // Use the address the client connected to (their remote addr + // is our perspective, but we need our listen addr). + // Replace 0.0.0.0 with the client's destination IP. + let relay_addr_for_setup = if listen_addr_str.starts_with("0.0.0.0:") { + let port = &listen_addr_str[8..]; + // Use the local IP from the client's connection + let local_ip = addr.ip(); + if local_ip.is_loopback() { + format!("127.0.0.1:{port}") + } else { + format!("{local_ip}:{port}") + } + } else { + listen_addr_str.clone() + }; let setup = SignalMessage::CallSetup { call_id: call_id.clone(), room: room.clone(), - relay_addr: listen_addr_str.clone(), + relay_addr: relay_addr_for_setup, }; { let hub = signal_hub.lock().await;