[SR-Users] Htable simple CPS Limit

Gareth Rylance gareth at rylance.me.uk
Thu Sep 12 21:21:47 CEST 2013

I was inspired by Daniels ClueCon 2013 talk and have decide to try to add
simple rate limiting using a HTable.
$var(srcgroup) is an id that identifies the invites source/ I wish to limit
invites from a given source.

$var(rateHashMin) was added just to allow simple monitoring.
I query the table via XML-RPC to get an idea of current load.
I think it would be better to add it to a seperate table and then I could
increase the exprires time to capture more of the course grain points.

I am interested in any comments.

modparam("htable", "htable",
modparam("htable", "htable",

if (is_method("INVITE")){
$var(rateHashSec) = (str)$var(srcgroup)+":sec:"+$timef(%Y/%m/%d_%H_%M_%S);
$var(rateHashMin) = (str)$var(srcgroup)+":min:"+$timef(%Y/%m/%d_%H_%M_00);
 $sht(htable_source_group_rates=>$var(rateHashSec)) =
$sht(htable_source_group_rates=>$var(rateHashSec)) + 1;
$sht(htable_source_group_rates=>$var(rateHashMin)) =
$sht(htable_source_group_rates=>$var(rateHashMin)) + 1;
 if($sht(htable_source_group_rates=>$var(rateHashSec)) >
sl_send_reply("503", "$si over source Limit of
$sht(htable_source_group_rates=>$var(rateHashSec)) /

Thanks Gareth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130912/90c4bfb7/attachment.html>

More information about the sr-users mailing list