[OpenSIPS-Users] is_ip_registered in invite

Schneur Rosenberg rosenberg11219 at gmail.com
Sun Dec 4 12:20:07 CET 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20161204/2f53b07d/attachment.htm>


More information about the Users mailing list