[SR-Users] how can I use WITH_IPAUTH when the IP may be stored in the DB as a FQDN?

canuck15 canuck15 at hotmail.com
Sun Mar 8 21:38:52 CET 2015


Here is is the relevant section of kamailio.cfg

$var(tempfU) = $fU;
#!ifdef WITH_IPAUTH
     if((!is_method("REGISTER")) && allow_source_address() && $au == "")
     {
         # Loading $fU from database using IP

         sql_pvquery("elxpbx", "SELECT name FROM sip WHERE host = '$si' 
AND sippasswd IS NULL", "$var(tempfU)");

         # source IP allowed
         return;
     }

The problem is that when host= somefqdn.com the above will fail since 
$si will always be an IP address as far as I can tell.  More often than 
not host= is a fqdn and requiring it to always be an IP address is not 
an option.  Converting it to IP before storing it in the DB is also not 
an option because it needs to be able to work of the IP address changes.

So how can the above be done to accomodate the possibility that host= 
somefqdn.com or an IP address.  Preferably in such a way that it can 
scale to hundreds/thousands of rows in the database without slowing 
things down or crashing.




More information about the sr-users mailing list