Skip to content

mod_sofia: resolve #2852 find gateway first by ip and dns later #2860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/mod/endpoints/mod_sofia/sofia_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down