From 7a725589d2ea7c5e91661abcb57529cdb8464a9e Mon Sep 17 00:00:00 2001 From: lazedo Date: Fri, 18 Jan 2019 12:30:59 +0000 Subject: [PATCH] allow override of missing expires on REGISTER --- kamailio/registrar-role.cfg | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index d14f137..c5ef230 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -4,6 +4,7 @@ #!trydef REGISTRAR_MAX_EXPIRES 3600 #!trydef REGISTRAR_DEFAULT_EXPIRES 600 #!trydef REGISTRAR_ERROR_MIN_EXPIRES 1 +#!trydef REGISTRAR_ERROR_MISSING_EXPIRES 1 #!trydef REGISTRAR_CONTACT_MAX_SIZE 2048 #!trydef REGISTRAR_QUERY_TIMEOUT_MS 2500 @@ -73,6 +74,7 @@ modparam("registrar", "xavp_rcd", "ulrcd") modparam("registrar", "contact_max_size", REGISTRAR_CONTACT_MAX_SIZE) 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" @@ -175,9 +177,7 @@ route[ATTEMPT_AUTHORIZATION] t_drop(); } - if($sel(cfg_get.kazoo.registrar_error_min_expires) == 1) { - route(REGISTRAR_BOUNDS); - } + route(REGISTRAR_BOUNDS); $var(auth) = pv_auth_check("$fd", "$uuid(g)", "0", "0"); if($var(auth) != -2) { @@ -396,16 +396,24 @@ route[REGISTRAR_BOUNDS] } else if($(sel(contact){tobody.params}{param.value,expires}) != "") { $var(expires) = $(sel(contact){tobody.params}{param.value,expires}{s.int}); } else { - send_reply("400", "Missing Expires"); - exit; + if($sel(cfg_get.kazoo.registrar_error_missing_expires) == 1) { + xlog("L_WARNING", "$ci|end|missing expires registering $Au from IP $si:$sp\n"); + send_reply("400", "Missing Expires"); + exit; + } else { + xlog("L_WARNING", "$ci|end|allowing missing expires registering $Au from IP $si:$sp\n"); + } } if($var(expires) != 0) { - if($var(expires) < REGISTRAR_MIN_EXPIRES) { - $var(expires) = REGISTRAR_MIN_EXPIRES; - append_to_reply("Min-Expires: $var(expires)\r\n"); - send_reply("423", "Interval Too Brief"); - exit; + if($sel(cfg_get.kazoo.registrar_error_min_expires) == 1) { + if($var(expires) < REGISTRAR_MIN_EXPIRES) { + $var(expires) = REGISTRAR_MIN_EXPIRES; + xlog("L_WARNING", "$ci|end|expires $var(expires) too brief registering $Au from IP $si:$sp\n"); + append_to_reply("Min-Expires: $var(expires)\r\n"); + send_reply("423", "Interval Too Brief"); + exit; + } } }