From c33bd1cfdae75322a2dbb4381006e632d6888d83 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 27 Feb 2019 18:37:38 +0000 Subject: [PATCH] nat keepalive options --- kamailio/presence-notify.cfg | 2 +- kamailio/presence-role.cfg | 16 ++++++++-------- kamailio/registrar-role.cfg | 23 ++++++++++------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/kamailio/presence-notify.cfg b/kamailio/presence-notify.cfg index 7d480d0..2d9e214 100644 --- a/kamailio/presence-notify.cfg +++ b/kamailio/presence-notify.cfg @@ -1,5 +1,5 @@ kazoo.presence_notify = 1 descr "enable/disable sending notify callback to omnipresence" -kazoo.presence_notify_timeout = 3000 descr "timeout in ms waiting for notify reply" +kazoo.presence_notify_timeout = 3500 descr "timeout in ms waiting for notify reply" kazoo.presence_notify_log_body = 0 descr "logs the body sent in the notification" kazoo.presence_notify_log_resp_body = 0 descr "logs the body received from notification" kazoo.presence_notify_log_to_table = 1 descr "logs notify/reply to active_watchers_log table" diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 6081711..d0101d2 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -4,19 +4,14 @@ #!trydef PRESENCE_MAX_EXPIRES 3600 #!trydef KZ_PRESENCE_IGNORE_STATUS_PROBE_RESP 1 - #!trydef KZ_PRESENCE_CSEQ_OFFSET 2 - #!trydef KZ_PRESENCE_MAX_CALL_PER_PRESENTITY 20 - #!trydef BLF_USE_SINGLE_DIALOG 1 - #!trydef KZ_PRESENCE_AMQP_PUBLISH 0 - #!trydef KZ_PRESENCE_REQUEST_RESUBSCRIBE_PROBE 0 #!trydef KZ_PRESENCE_REQUEST_PROBE 1 - #!trydef KZ_PRESENCE_NO_TARGETS_LOG_LEVEL L_DBG +#!trydef KZ_PRESENCE_KEEPALIVE_UDP_ONLY 0 modparam("htable", "htable", "p=>size=32;autoexpire=3600;") modparam("htable", "htable", "first=>size=32;autoexpire=3600;initval =0;updateexpire=1;") @@ -76,6 +71,7 @@ kazoo.presence_request_resubscribe_probe = KZ_PRESENCE_REQUEST_RESUBSCRIBE_PROBE kazoo.presence_ignore_status_probe_resp = KZ_PRESENCE_IGNORE_STATUS_PROBE_RESP descr "ignore online/offline probe replies" kazoo.presence_max_call_per_presentity = KZ_PRESENCE_MAX_CALL_PER_PRESENTITY descr "max number of calls per presentity" kazoo.presence_no_targets_log_level = KZ_PRESENCE_NO_TARGETS_LOG_LEVEL descr "when a presence event is received and there no targets we can log at another level" +kazoo.presence_keepalive_udp_only = KZ_PRESENCE_KEEPALIVE_UDP_ONLY descr "should we keepalive nat phones for udp only" #!include_file "presence-query.cfg" #!include_file "presence-notify.cfg" @@ -87,8 +83,12 @@ kazoo.presence_no_targets_log_level = KZ_PRESENCE_NO_TARGETS_LOG_LEVEL descr "wh #!ifdef NAT_TRAVERSAL_ROLE route[PRESENCE_NAT] { - if (isflagset(FLT_NATS) && proto==UDP) { - nat_keepalive(); + if (isflagset(FLT_NATS)) { + if(!( ($sel(cfg_get.kazoo.presence_keepalive_udp_only) == 1 && $proto != "udp") + || ($proto =="ws" || $proto == "wss") + )) { + nat_keepalive(); + } } } #!endif diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index 0ecedf3..4acf6c1 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -16,19 +16,16 @@ #!trydef REGISTRAR_CONTACT_MAX_SIZE 2048 #!trydef REGISTRAR_QUERY_TIMEOUT_MS 2500 - #!trydef REGISTRAR_HANDLE_LOST_TCP 1 #!trydef REGISTRAR_CLOSE_EXPIRED_TCP 1 - #!trydef REGISTRAR_HANDLE_EXPIRED_TCP 1 #!trydef REGISTRAR_HANDLE_EXPIRED_UDP 0 #!trydef REGISTRAR_HANDLE_EXPIRED_TLS 1 #!trydef REGISTRAR_HANDLE_EXPIRED_WS 1 - #!trydef REGISTRAR_FORCE_QUERY 0 #!trydef REGISTRAR_FORCE_FAILOVER 0 - #!trydef REGISTRAR_CHECK_AMQP_AVAILABILITY 1 +#!trydef KZ_REGISTRAR_KEEPALIVE_UDP_ONLY 0 ######## Generic Hash Table container in shared memory ######## modparam("htable", "htable", "auth_cache=>size=16;autoexpire=7200;") @@ -84,21 +81,18 @@ modparam("registrar", "received_param", "") modparam("registrar", "xavp_rcd", "ulrcd") modparam("registrar", "contact_max_size", REGISTRAR_CONTACT_MAX_SIZE) +##### registrar realtime params ##### kazoo.registrar_error_min_expires = REGISTRAR_ERROR_MIN_EXPIRES descr "send error when UAS sends expires < min-expires" kazoo.registrar_error_missing_expires = REGISTRAR_ERROR_MISSING_EXPIRES descr "send error when UAS do not send expires header" - -##### handle expired registrations realtime params ##### kazoo.registrar_handle_expired_tcp = REGISTRAR_HANDLE_EXPIRED_TCP descr "handles expired tcp registrations" kazoo.registrar_handle_expired_udp = REGISTRAR_HANDLE_EXPIRED_UDP descr "handles expired udp registrations" kazoo.registrar_handle_expired_tls = REGISTRAR_HANDLE_EXPIRED_TLS descr "handles expired tls registrations" kazoo.registrar_handle_expired_ws = REGISTRAR_HANDLE_EXPIRED_WS descr "handles expired ws registrations" - kazoo.registrar_query_timeout_ms = REGISTRAR_QUERY_TIMEOUT_MS descr "timeout waiting for reply from registrar" - kazoo.registrar_failover = REGISTRAR_FORCE_FAILOVER descr "force failover if 1" kazoo.registrar_force_query = REGISTRAR_FORCE_QUERY descr "force query if 1" kazoo.registrar_check_amqp_availability = REGISTRAR_CHECK_AMQP_AVAILABILITY descr "checks if amqp connection is available before querying registrar" - +kazoo.registrar_keepalive_udp_only = KZ_REGISTRAR_KEEPALIVE_UDP_ONLY descr "should we keepalive nat phones for udp only" ####### Registrar Logic ######## @@ -113,7 +107,8 @@ route[REGISTRAR_NAT] if (!($ua =~ "Linksys/SPA8000" || $ua =~ "SIPp" || (af==INET6) - || (proto!=UDP) + || ($sel(cfg_get.kazoo.registrar_keepalive_udp_only) == 1 && $proto != "udp") + || ($proto =="ws" || $proto == "wss") || ($(xavp(ulattrs=>custom_channel_vars){kz.json,Keep-Alive}) == "false") )) { xlog("L_DEBUG", "$ci|log|set nat pinging\n"); @@ -196,7 +191,7 @@ route[HANDLE_REGISTER] failure_route[KZ_AUTHORIZATION_TIMEOUT] { - xlog("L_INFO", "$ci|log|failed $T_reply_code to query Kazoo for authentication credentials for $Au $si:$sp\n"); + xlog("L_INFO", "$ci|end|failed $T_reply_code querying directory for authentication credentials for $Au $si:$sp\n"); t_drop(); } @@ -404,12 +399,14 @@ route[REGISTRAR_BOUNDS] } if($var(expires) != 0) { - if($sel(cfg_get.kazoo.registrar_error_min_expires) == 1) { - if($var(expires) < REGISTRAR_MIN_EXPIRES) { + if($var(expires) < REGISTRAR_MIN_EXPIRES) { + if($sel(cfg_get.kazoo.registrar_error_min_expires) == 1) { xlog("L_WARNING", "$ci|end|expires $var(expires) too brief (configured $def(REGISTRAR_MIN_EXPIRES)) registering $Au from IP $si:$sp\n"); append_to_reply("Min-Expires: $def(REGISTRAR_MIN_EXPIRES)\r\n"); send_reply("423", "Interval Too Brief"); exit; + } else { + xlog("L_WARNING", "$ci|end|allowing expires $var(expires) too brief (configured $def(REGISTRAR_MIN_EXPIRES)) registering $Au from IP $si:$sp\n"); } } }