Friday, December 26, 2014

Kamailio 4.2 Tips: #11 - Dynamic Pipes and Limits

Pipelimit module in Kamailio 4.2 gives the possibility to add new pipes at runtime, specifying the algorithm and the limit. When using pl_check(...) with all three parameters, if the pipe is not found, it will be created:

# perform pipe match for authenticated user, creating the pipe if not found
$var(limit) = 20;
if (!pl_check("$au", "traildrop", "$var(limit)")) {
 pl_drop();
 exit;
}

The limit can be adjusted later, by keeping the name and algorithm, changing the value for the third parameter. The parameters can be variables, therefore allowing full flexibility to name the pipe and set its limit.

Practically, with this version, pipes can be created as needed, not depending on record stored in database like with older versions. Here is one useful example: add pipes per each source IP, enabling new mechanisms to protect against unwanted traffic, like D/DoS attacks.

Enjoy it!

No comments:

Post a Comment