From cb274d750d05949adbecef02f601b3fc6ed5620f Mon Sep 17 00:00:00 2001 From: Antonio Silva Date: Wed, 16 Jul 2025 15:52:38 +0200 Subject: [PATCH] mod_sofia: resolve #2852 find gateway first by ip and dns later --- src/mod/endpoints/mod_sofia/sofia_reg.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index ccd42bf6ab1..ad186ff7335 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -2533,6 +2533,7 @@ static switch_bool_t is_host_from_gateway(const char *remote_ip, sofia_gateway_t hosts[1] = gateway->register_proxy_host_cfg; hosts[2] = gateway->outbound_proxy_host_cfg; + //check for ip address only for (i = 0; i < 3; i++) { if (zstr(hosts[i])) { continue; @@ -2542,14 +2543,23 @@ static switch_bool_t is_host_from_gateway(const char *remote_ip, sofia_gateway_t if (!strcmp(hosts[i], remote_ip)) { ret = SWITCH_TRUE; } - - if (ret) break; - } else { - ret = sip_resolve_compare(hosts[i], remote_ip, gateway->register_transport); if (ret) break; } } + // if not found any ip address try dns resolution + if (!ret) { + for (i = 0; i < 3; i++) { + if (zstr(hosts[i])) { + continue; + } + if (!host_is_ip_address(hosts[i])) { + ret = sip_resolve_compare(hosts[i], remote_ip, gateway->register_transport); + if (ret) break; + } + } + } + return ret; }