[OpenSIPS-Users] is_ip_registered in invite

Răzvan Crainea razvan at opensips.org
Mon Dec 5 10:03:13 CET 2016


Hi, Schneur!

The second parameter of the is_ip_registered() function[1] should be the 
AOR of the caller, in the sip:SIP_USER at SIP_DOMAIN format. The source IP 
is only checked against the contacts of that specific subscriber.
However, if I understand correctly, your problem is determining what is 
the correct AOR to use, because the From username and domain might be 
different between REGISTER and INVITE, right? If that's the case, you 
don't have that many choices: either you search through all registered 
IPs (but there is no OpenSIPS function to do that, so you'll need 
someting external as you've already done), or you create some sort of 
mappings between the REGISTER and INVITE users/formats. Or you impose 
your customers to comply with a specific format, that can help you 
figure out the mapping.

[1] http://www.opensips.org/html/docs/modules/2.2.x/registrar.html#id294953

Best regards,

Răzvan Crainea
OpenSIPS Solutions
www.opensips-solutions.com

On 12/04/2016 01:20 PM, Schneur Rosenberg wrote:
> Hi, I would like to check during the initial  invite if the request 
> comes from a IP that is registered (I don't care about the user 
> credentials at this time), I use it to know if the invite is from a 
> registered user or if it is from a unauthenticated source (DID's or 
> hacking attempt) I can't use  is_contact_registered()  because not all 
> clients send the user name in the initial invite, and they only send 
> it in the authentication username which is absent in the initial 
> invite, therefore I want to use is_ip_registered() but I'm having 
> issues and I don't understand exactly what the second parameter is 
> for, I want to check for the ip in the $si variable if it is 
> registered (either in the contact field or in the received field).
>
> When leaving blank the AOR field, some devices work well but some don't.
>
> Due to NAT some devices register the IP in the contact field, and some 
> in the received field, I want to try to match to either one, and it 
> should parse the contact field that it should ignore the username from 
> the contact field.
>
> I was doing a avp_db_query() until now, but it had 2 major issues.
>
> 1) It runs a MYSQL query on each REQUEST which reduces performance, I 
> couldn't use memcache because IP's are dynamic in nature.
> 2)  I use db_mode 2 on usrloc and it takes about a minute for the 
> registration to appear in the DB and the user can't call out during 
> that minute, and even worse if he tries multiple times and it gets 
> rejected my iptables will block his IP.
>
> thank you
> S. Rosenberg
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20161205/a9153e60/attachment.htm>


More information about the Users mailing list