[Kamailio-Users] [Solved] How to configure alias_db_lookup in config script
JR Richardson
jmr.richardson at gmail.com
Wed Nov 18 23:19:26 CET 2009
Thanks for your quick replys.
Here is the syntax that is working for me:
route{
# initial sanity checks -- messages with
# max_forwards==0, or excessively long requests
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
};
if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
exit;
};
if(alias_db_lookup("dbaliases")) {
t_relay();
}else{
ds_select_dst("1", "4");
t_on_failure("1");
t_relay();
}
}
failure_route[1] {
ds_next_dst();
forward();
}
On Wed, Nov 18, 2009 at 3:45 PM, Alex Balashov <abalashov at evaristesys.com>wrote:
> JR,
>
> Like many lookup functions, the alias_db_lookup() function has a return
> value. You should check it for a negative result before proceeding further
> in the script:
>
> Example:
>
> if(!alias_db_lookup("dbaliases")) {
> sl_send_reply("404", "Not Found");
> exit;
> }
>
> Error handling in general is a must.
>
> -- Alex
>
> JR Richardson wrote:
>
> Hi All,
>> I have a real simple load balancer proxy setup using the dispatcher
>> module, works great. I want to do an alias lookup before I send the calls
>> through to the dispatcher, but I can't seem to find a good example of how
>> that should be setup in the config script. I've tried different things, the
>> aliase_db_lookup is working but if a user is not in the database, the call
>> loops and does not continue on to the dispatcher. Here is my current route
>> script (this does not work):
>> route{
>> # initial sanity checks -- messages with
>> # max_forwards==0, or excessively long requests
>> if (!mf_process_maxfwd_header("10")) {
>> sl_send_reply("483","Too Many Hops");
>> exit;
>> };
>> if (msg:len >= 2048 ) {
>> sl_send_reply("513", "Message too big");
>> exit;
>> };
>>
>> alias_db_lookup("dbaliases");
>> t_on_failure("1");
>> t_relay();
>> ds_select_dst("1", "4");
>> t_on_failure("1");
>> t_relay();
>> }
>>
>> failure_route[1] {
>> ds_next_dst();
>> forward();
>> }
>> I think there should be an 'if' 'then' or 'if' 'else' separating the
>> alias_db_lookup and the ds_select functions, but I'm not sure of the syntax
>> and where the curly brackets need to be.
>> Thanks.
>> JR
>> --
>> JR Richardson
>> Engineering for the Masses
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Kamailio (OpenSER) - Users mailing list
>> Users at lists.kamailio.org
>> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>>
>
>
> --
> Alex Balashov - Principal
> Evariste Systems
> Web : http://www.evaristesys.com/
> Tel : (+1) (678) 954-0670
> Direct : (+1) (678) 954-0671
>
--
JR Richardson
Engineering for the Masses
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/users/attachments/20091118/cf89dce0/attachment.htm>
More information about the Users
mailing list