mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 00:00:44 +00:00
FS-535: additional checks and use the right contact for registers inside and outside of nat
This commit is contained in:
parent
ec8f2c2bc2
commit
38f994206f
@ -2156,6 +2156,30 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
||||
sipip = profile->sipip;
|
||||
}
|
||||
|
||||
gateway->extension = switch_core_strdup(gateway->pool, extension);
|
||||
|
||||
|
||||
if (!strncasecmp(proxy, "sip:", 4)) {
|
||||
gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
|
||||
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
|
||||
} else {
|
||||
gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
|
||||
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
|
||||
}
|
||||
|
||||
/* This checks to make sure we provide the right contact on register for targets behind nat with us. */
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT)) {
|
||||
char *register_host = NULL;
|
||||
|
||||
register_host = sofia_glue_get_register_host(gateway->register_proxy);
|
||||
|
||||
if (register_host && !sofia_glue_check_nat(profile, register_host)) {
|
||||
sipip = profile->sipip;
|
||||
}
|
||||
|
||||
switch_safe_free(register_host);
|
||||
}
|
||||
|
||||
if (extension_in_contact) {
|
||||
format = strchr(sipip, ':') ? "<sip:%s@[%s]:%d%s>" : "<sip:%s@%s:%d%s>";
|
||||
gateway->register_contact = switch_core_sprintf(gateway->pool, format, extension,
|
||||
@ -2170,16 +2194,6 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
||||
profile->tls_sip_port : profile->sip_port, params);
|
||||
}
|
||||
|
||||
gateway->extension = switch_core_strdup(gateway->pool, extension);
|
||||
|
||||
if (!strncasecmp(proxy, "sip:", 4)) {
|
||||
gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
|
||||
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
|
||||
} else {
|
||||
gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
|
||||
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
|
||||
}
|
||||
|
||||
gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
|
||||
|
||||
if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
|
||||
|
@ -152,7 +152,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy);
|
||||
|
||||
/* check for NAT and place a Via header if necessary (hostname or non-local IP) */
|
||||
if (sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
|
||||
if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
|
||||
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy);
|
||||
|
||||
/* check for NAT and place a Via header if necessary (hostname or non-local IP) */
|
||||
if (sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
|
||||
if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
|
||||
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy);
|
||||
|
||||
/* check for NAT and place a Via header if necessary (hostname or non-local IP) */
|
||||
if (sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
|
||||
if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
|
||||
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user