[SR-Users] userblacklist Module - Documentation fault?

marius zbihlei marius.zbihlei at 1and1.ro
Thu Jul 22 18:33:42 CEST 2010


Nicolas Rüger wrote:
> Hello,
>
> in the documentation of the Module "Userblacklist" seems not really clear to me. Please clarify my doubts.
>
> Refering to:
>
> http://www.kamailio.org/docs/modules/3.0.x/modules_k/userblacklist.html
>
> in 
>
> "4.1.  check_user_blacklist"
>
> is written:
>
> "[...]If a match is found and it is not set to whitelist, false is returned. Otherwise, true is returned.[...]"
>   

Hello Nicolas,

Before your quoted text there is this statement  "Finds the longest 
prefix that matches the request URI user (or the number parameter) for 
the given user and domain name in the database."

This means that you might have in the db a blacklist rule for the 
desired user  for prefix 555123, that this will match the numbers 
5551234 and 5551235. But you want to allow one of these numbers to be 
called by that user, you can specify that 5551234 is whitelisted.
> Question:
>
> 1.) Is "not whitelisted" equal to "blacklisted"?
>   

Before your quoted text there is this statement  "Finds the longest 
prefix that matches the request URI user (or the number parameter) for 
the given user and domain name in the database."

This means that you might have in the db a blacklist rule for the 
desired user  for prefix 555123, that this will match the numbers 
5551234 and 5551235(and others of course). But you want to allow one of 
these numbers to be called by that user, you can specify that 5551234 is 
whitelisted.

To answer your question no, if a R-URI is not whitelisted then it will  
be blacklisted only if there is a prefix that will match it(it the 
userblacklist table is empty no numbers are blacklisted)
> 2.) Why is "false" returned if the blacklist_check is positive?
>   
This is the interface.
The example in the documentation is like this:

$avp(i:80) = $rU;
# rewrite the R-URI
if (!check_user_blacklist("$avp(i:80)", "$avp(i:82)"))
	sl_send_reply("403", "Forbidden");
	exit;
}


> 3.) Is "true" even returned if there's no match?
>   
The check_use_blacklist will return true if no blacklisted prefix match 
is found, or a longer whitelisted prefix is found.
For example if you have 123 blacklisted and 1234 whitelisted, 12345 will 
be whitelisted but 1233 will be blacklisted.
> I'd have expected the following:
>
> if (user_is_blacklisted)
>   then return TRUE;
>   else return FALSE;
>
>
> Can you please clarify the behavior? Thank you.
>
>   
Hope this helps
Marius
> Regards,
>
> Nicolas
>
>
>
>
> Example that seems clear to me:
> ===============================
>
> In
>
> "4.2.  check_user_whitelist"
>
> is written:
>
> "[...]If a match is found and it is set to whitelist, true is returned. Otherwise, false is returned.[...]"
>
> cause it means to me:
>
> if (user_is_whitelisted) 
>   then return TRUE;
>   else return FALSE;
>
>
>   




More information about the sr-users mailing list