From 6a35a1163ac5fe4b58393033af9428d2ac3ac151 Mon Sep 17 00:00:00 2001 From: jfirles Date: Wed, 12 Aug 2020 13:43:28 +0200 Subject: [PATCH] Added variable sip_contact_host to change the host part in the contact header --- src/mod/endpoints/mod_sofia/sofia_glue.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 27171890dd..f40822c850 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1270,7 +1270,24 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) if (zstr(tech_pvt->invite_contact)) { const char *contact; - if ((contact = switch_channel_get_variable(channel, "sip_contact_user"))) { + const char *contactHost; + if ((contact = switch_channel_get_variable(channel, "sip_contact_user")) && (contactHost = switch_channel_get_variable(channel, "sip_contact_host"))) { + if (sofia_glue_transport_has_tls(tech_pvt->transport)) { + tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s:%d", contact, + contactHost, tech_pvt->profile->tls_sip_port); + } else { + tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s:%d", contact, + contactHost, tech_pvt->profile->extsipport); + } + } else if ((contactHost = switch_channel_get_variable(channel, "sip_contact_host"))) { + if (sofia_glue_transport_has_tls(tech_pvt->transport)) { + tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:mod_sofia@%s:%d", contactHost, + tech_pvt->profile->tls_sip_port); + } else { + tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:mod_sofia@%s:%d", contactHost, + tech_pvt->profile->extsipport); + } + } else if ((contact = switch_channel_get_variable(channel, "sip_contact_user"))) { char *ip_addr = tech_pvt->profile->sipip; char *ipv6;