fix webRTC voice call for LAN setup

This commit is contained in:
deepashreeKedia 2026-05-19 17:00:35 +05:30 committed by deepashreeKedia
parent d93d7aff4d
commit 36fbeda433

View file

@ -105,9 +105,8 @@ def filter_outbound_sdp(sdp: str) -> str:
if FORCE_TURN_RELAY and " typ relay" not in candidate_str:
dropped_non_relay += 1
continue
if ENVIRONMENT != Environment.LOCAL.value and is_private_ip_candidate(
candidate_str
):
is_relay = " typ relay" in candidate_str
if ENVIRONMENT != Environment.LOCAL.value and not is_relay and is_private_ip_candidate(candidate_str):
continue
if FORCE_TURN_RELAY:
kept_relay += 1
@ -389,14 +388,13 @@ class SignalingManager:
if candidate_data:
candidate_str = candidate_data.get("candidate", "")
# Filter out private IP candidates in non-local environments
# This prevents TURN relay errors when coturn blocks private IP ranges
if ENVIRONMENT != Environment.LOCAL.value and is_private_ip_candidate(
# Filter out private IP candidates in non-local environments, unless
# FORCE_TURN_RELAY is on — in that case all media goes via TURN relay
# anyway, and we need the browser's LAN host candidate so the server
# can form a relay→host pair without requiring NAT hairpin.
if ENVIRONMENT != Environment.LOCAL.value and not FORCE_TURN_RELAY and is_private_ip_candidate(
candidate_str
):
logger.debug(
f"Skipping private IP candidate in {ENVIRONMENT}: {candidate_str[:50]}..."
)
return
try:
@ -406,7 +404,6 @@ class SignalingManager:
candidate.sdpMLineIndex = candidate_data.get("sdpMLineIndex")
await pc.add_ice_candidate(candidate)
logger.debug(f"Added ICE candidate for pc_id: {pc_id}")
except Exception as e:
logger.error(f"Failed to add ICE candidate: {e}")
else: