[mod_sofia] Add tls-orq-connect-timeout profile parameter so SIP engine could try again sending an outgoing request and when possible - using an alternative address (DNS failover). Add sip_call_tls_orq_connect_timeout channel variable per call to override profile's timeout.

This commit is contained in:
Andrey Volk 2020-10-28 02:26:04 +04:00
parent 734e9776e0
commit 66a92063b6
5 changed files with 33 additions and 0 deletions

View File

@ -216,6 +216,14 @@
<!-- TLS ciphers default: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH -->
<param name="tls-ciphers" value="$${sip_tls_ciphers}"/>
<!--
Connect timeout for outgoing requests using TLS (in milliseconds).
Set the timeout and SIP engine will try again sending an outgoing request
and when possible - using an alternative address (DNS failover).
Default - 0 (disabled)
-->
<!-- <param name="tls-orq-connect-timeout" value="3000" /> -->
<!-- turn on auto-flush during bridge (skip timer sleep when the socket already has data)
(reduces delay on latent connections default true, must be disabled explicitly)-->
<!--<param name="rtp-autoflush-during-bridge" value="false"/>-->

View File

@ -216,6 +216,14 @@
<!-- TLS ciphers default: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH -->
<param name="tls-ciphers" value="$${sip_tls_ciphers}"/>
<!--
Connect timeout for outgoing requests using TLS (in milliseconds).
Set the timeout and SIP engine will try again sending an outgoing request
and when possible - using an alternative address (DNS failover).
Default - 0 (disabled)
-->
<!-- <param name="tls-orq-connect-timeout" value="3000" /> -->
<!-- turn on auto-flush during bridge (skip timer sleep when the socket already has data)
(reduces delay on latent connections default true, must be disabled explicitly)-->
<!--<param name="rtp-autoflush-during-bridge" value="false"/>-->

View File

@ -761,6 +761,7 @@ struct sofia_profile {
uint32_t timer_t1x64;
uint32_t timer_t2;
uint32_t timer_t4;
uint32_t tls_orq_connect_timeout;
char *contact_user;
char *local_network;
uint32_t trans_timeout;

View File

@ -3220,6 +3220,10 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
TPTAG_PONG2PING(1),
NTATAG_TCP_RPORT(0),
NTATAG_TLS_RPORT(0),
#ifdef NTATAG_TLS_ORQ_CONNECT_TIMEOUT
TAG_IF(profile->tls_orq_connect_timeout,
NTATAG_TLS_ORQ_CONNECT_TIMEOUT(profile->tls_orq_connect_timeout)), /* Profile based timeout */
#endif
NUTAG_RETRY_AFTER_ENABLE(0),
NUTAG_AUTO_INVITE_100(0),
TAG_IF(!strchr(profile->sipip, ':'),
@ -5917,6 +5921,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} else {
profile->timer_t4 = 4000;
}
} else if (!strcasecmp(var, "tls-orq-connect-timeout") && !zstr(val)) {
int v = atoi(val);
if (v > 0) {
profile->tls_orq_connect_timeout = v;
} else {
profile->tls_orq_connect_timeout = 0;
}
} else if (!strcasecmp(var, "sip-options-respond-503-on-busy")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY);

View File

@ -1068,6 +1068,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
const char *stir_shaken_attest = NULL;
char *identity_to_free = NULL;
const char *date = NULL;
const char *sip_call_tls_orq_connect_timeout = switch_channel_get_variable(tech_pvt->channel, "sip_call_tls_orq_connect_timeout");
if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD_INACTIVE) ||
@ -1400,6 +1401,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
NUTAG_URL(url_str),
TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
TAG_IF(!zstr(record_route), SIPTAG_HEADER_STR(record_route)),
#ifdef NUTAG_CALL_TLS_ORQ_CONNECT_TIMEOUT
/* Per call tls outgoing request connect timeout */
TAG_IF(sip_call_tls_orq_connect_timeout, NUTAG_CALL_TLS_ORQ_CONNECT_TIMEOUT(atoi(sip_call_tls_orq_connect_timeout))),
#endif
SIPTAG_TO_STR(to_str), SIPTAG_FROM_STR(from_str), SIPTAG_CONTACT_STR(invite_contact), TAG_END()))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,