-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added variable sip_contact_host to change the host part in the Contact header in INVITE requests #787
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
base: master
Are you sure you want to change the base?
Conversation
mjerris
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this entire block of code can be significantly simplified by building out vars for user and host and only building the invite contact one time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is right but totally untested:
if (zstr(tech_pvt->invite_contact)) {
const char *contact_user = switch_channel_get_variable(channel, "sip_contact_user”);
const char *contact_host = switch_channel_get_variable(channel, "sip_contact_host”);
if (!contact_user && !contact_host) {
tech_pvt->invite_contact = sofia_glue_get_profile_url(tech_pvt->profile, tech_pvt->mparams.remote_ip, tech_pvt->transport);
} else {
switch_port_t port = sofia_glue_transport_has_tls(tech_pvt->transport) ? tech_pvt->profile->tls_sip_port : tech_pvt->profile->extsipport
if (zstr(contact_user)) {
contact_user = “mod_sofia”;
}
if (zstr(contact_host)) {
char *ip_addr = tech_pvt->profile->sipip;
char *ipv6;
if (!zstr(tech_pvt->mparams.remote_ip) && sofia_glue_check_nat(tech_pvt->profile, tech_pvt->mparams.remote_ip)) {
ip_addr = tech_pvt->profile->extsipip;
}
ipv6 = strchr(ip_addr, ':');
contact_host = switch_core_session_sprintf(session, “%s%s%s”, ipv6 ? "[" : "", ip_addr, ipv6 ? "]" : “”);
}
tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s:%d", contact_user, contact_host, port);
}
}
|
in current version, deecaae, when using a gateway we can set the contact-host parameter, so the contact is correctly changed. I do find an issue, the incoming call from MS TEAMS, is authenticated by IP, so it doesn't hit the gateway detection so the replies we send back have the sipip address of our profile. We can set the sip-ip address to the domain name, but for multi-tenant is not valid. We need to set it from the dialplan, the the incoming invite reach the default context. I test this code and it doesn't solve the issue, the 200OK sent have in contact the profile ip. attach the log and my configuration simulating this scenario. |
|
I'm using it for multitenant scenario. You must set the sip-ip to de base domain and in dialplan the sip_contact_host var. Best regards. |
|
Hi, In the log, the variable is set correctly: but the 200OK Contact uses value of sip-ip for what i could test the "sofia_glue_do_invite" function is not called when receiving a call. |
Yes in the 200 OK the contact is the sip-ip value, but this works for Teams integration.
|
|
I've created an alternative PR for review that we propose, these changes have been used in a production environment for the last few years with thousands of calls per day. I closed the original PR years ago #849 as there was no progress getting it merged. I'm still receiving messages from FS users for this so I'm having attempt to get it merged. |
Some providers like Microsoft Teams require set the host part in the "Contact" header with the required value for auth the INVITE request, with this pull request we can change the contact host part of that header.
This is useful for multitenant scenarios.