]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Add tls-orq-connect-timeout profile parameter so SIP engine could try...
authorAndrey Volk <andywolk@gmail.com>
Tue, 27 Oct 2020 22:26:04 +0000 (02:26 +0400)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:00:36 +0000 (22:00 +0300)
conf/testing/sip_profiles/internal.xml
conf/vanilla/sip_profiles/internal.xml
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 2a3564ebb403f6ce75c0bb0e7f3b49048361a55c..d7b2ef893d5dd99299081f7c66770a8b69633a7c 100644 (file)
     <!-- 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"/>-->
index 58350e827b724cfe6b7563a986d4cb78ba6f2dfc..85692fa63152e52dbba9bc5c647ea8edd3a0d6a6 100644 (file)
     <!-- 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"/>-->
index 9a739088df735d2ce8d6cae6bfa4f27641a9b3be..9d0d150354377c915a4017b7a7be1015553f7bd5 100644 (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;
index f31367a04cafc1e39332a08d319a7c2ba2a778b8..a71678dd10c49d9358b9da019e9259b8732c5df5 100644 (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);
index 68125879ce69f68465477e84e3cccd29bfcb3fc0..9a6a7acbd9337e5a8814be70f172e82c4b5f1a1e 100644 (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,