From 30926251cb0bcbfb39cc304ae318567d6529ee90 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 12 Jul 2013 13:35:59 -0500 Subject: [PATCH] FS-5396 --resolve --- src/mod/endpoints/mod_sofia/mod_sofia.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 27066d924a..c4e67bdf0d 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -5043,6 +5043,24 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } } else { host++; + + if (!strchr(host, '.')) { + struct sockaddr_in sa; + struct hostent *he = gethostbyname(host); + char *ip, *tmp; + + if (he) { + memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr)); + ip = inet_ntoa(sa.sin_addr); + + tmp = switch_string_replace(dest, host, ip); + //host = switch_core_session_strdup(nsession, ip); + //dest = switch_core_session_strdup(nsession, tmp); + switch_channel_set_variable_printf(nchannel, "sip_route_uri", "sip:%s", tmp); + free(tmp); + } + } + tech_pvt->dest = switch_core_session_alloc(nsession, strlen(dest) + 5); tech_pvt->e_dest = switch_core_session_strdup(nsession, dest); switch_snprintf(tech_pvt->dest, strlen(dest) + 5, "sip:%s", dest);