From 1ec093e1236ed9c9090fec68d6a92a5508a590a1 Mon Sep 17 00:00:00 2001 From: "SIPLABS, LLC" Date: Wed, 11 Feb 2015 21:23:43 +0700 Subject: [PATCH] workaround for IP in domain --- kamailio/rate-limiter-role.cfg | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kamailio/rate-limiter-role.cfg b/kamailio/rate-limiter-role.cfg index 2846099..9f7056c 100644 --- a/kamailio/rate-limiter-role.cfg +++ b/kamailio/rate-limiter-role.cfg @@ -9,6 +9,7 @@ modparam("htable", "htable", "rate_limits=>initval=-1;autoexpire=60") # init #!trydef RATE_LIMIT_MESSAGE "Over rate Limit" #!trydef RATE_LIMIT_CODE "603" +#!trydef IP_REGEX "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}" route[DOS_PREVENTION_REPLY] { setflag(FLAG_IS_REPLY); route(DOS_PREVENTION); @@ -35,8 +36,8 @@ route[DOS_PREVENTION] { } # For BYE method we use REALM from To SIP header - if (is_method("BYE")) { - xlog("L_WARNING","$ci|RL-realm log| Fixup for BYE method with IP in from URI: use to-domain"); + if ($fd =~ IP_REGEX) { + xlog("L_WARNING","$ci|RL-realm log| Fixup for $rm method with IP in from URI: use to-domain"); $var(ltpm_realm) = $td+"/TOTAL/min"; $var(ltps_realm) = $td+"/TOTAL/sec"; $var(ltpm_device) = $fU+"@"+$td+"/TOTAL/min"; @@ -66,8 +67,8 @@ route[DOS_PREVENTION] { } if (not_empty("$fU")) { - if (is_method("BYE")) { - xlog("L_WARNING","$ci|RL-realm log| Fixup for BYE method with IP in from URI: use to-domain"); + if ($fd =~ IP_REGEX) { + xlog("L_WARNING","$ci|RL-realm log| Fixup for $rm method with IP in from URI: use to-domain"); $var(entity) = $fU+"@"+$td; } else { $var(entity) = $fU+"@"+$fd; @@ -152,8 +153,8 @@ route[DOS_PREVENTION] { } } - if (is_method("BYE")) { - xlog("L_WARNING","$ci|RL-device log| Fixup for BYE method with IP in from URI: use to-domain"); + if ($fd =~ IP_REGEX) { + xlog("L_WARNING","$ci|RL-device log| Fixup for $rm method with IP in from URI: use to-domain"); $var(entity) = $td; } else { $var(entity) = $fd; @@ -169,9 +170,9 @@ route[DOS_PREVENTION] { route(DO_DOS_PREVENTION); if ( not_empty("$fU") ) { - if (is_method("BYE")) { + if ($fd =~ IP_REGEX) { $var(entity) = $fU+"@"+$td; - xlog("L_WARNING","$ci|RL-device log| Fixup for BYE method with IP in from URI: use to-domain"); + xlog("L_WARNING","$ci|RL-device log| Fixup for $rm method with IP in from URI: use to-domain"); } else { $var(entity) = $fU+"@"+$fd; }