[OpenSIPS-Users] Database Searching

Mark Farmer farmorg at gmail.com
Wed Aug 28 10:27:25 EDT 2019


Now that made it really easy.

Untested as yet but added the UA strings to the dialplan table with a
repl_ext of "BogusUA".

Then:

if (dp_translate(1, $ua, $var(BogusUA))) {
                xlog("CUSTOM_LOG: BogusUA Detected! ($ua)");
}

if $var(BogusUA)=BogusUA {
                xlog("CUSTOM_LOG: Ignoring $rm from BogusUA ($ua)");
                exit;
}

Using in memory data *was* on the wish list for this :)

As always - thank you everyone for your input.

Mark.




On Wed, 28 Aug 2019 at 13:55, Liviu Chircu <liviu at opensips.org> wrote:

> Hi all,
>
> If reloading the table whenever you update your banned UA list isn't a
> problem, then the optimal
> answer is the dialplan module and its dp_translate [1] function in order
> to test against your UA list.
> It works with in-memory data so it is super fast.
>
> Best regards,
>
> [1]:
> https://opensips.org/html/docs/modules/3.1.x/dialplan.html#func_dp_translate
>
> Liviu Chircu
> OpenSIPS Developerhttp://www.opensips-solutions.com
>
> On 28.08.2019 15:41, Mark Farmer wrote:
>
> Thanks for the reply, certainly a few options to consider :)
>
> To be more specific, the table contains $ua identifiers:
>
> MariaDB [tt]> select * from user_agent;
> +----+------------------+
> | id | ua               |
> +----+------------------+
> |  1 | sipcli           |
> |  2 | sipvicious       |
> |  3 | sip-scan         |
> |  4 | sipsak           |
> |  5 | sundayddr        |
> |  6 | friendly-scanner |
> |  7 | iWar             |
> |  8 | CSipSimple       |
> |  9 | SIVuS            |
> | 10 | Gulp             |
> | 11 | sipv             |
> | 12 | smap             |
> | 13 | friendly-request |
> | 14 | VaxIPUserAgent   |
> | 15 | VaxSIPUserAgent  |
> | 16 | siparmyknife     |
> | 17 | Test Agent       |
> +----+------------------+
>
> What I'd like to do is something like:
>
> if($ua ~=(search_ua_column_for_match) {
>     exit;
> }
>
> I should add that I'm using OpenSIPS 3.0
>
>
>
> On Wed, 28 Aug 2019 at 13:31, Alexey Kazantsev via Users <
> users at lists.opensips.org> wrote:
>
>> Hi Mark,
>>
>> I haven't understood well enough what data do you store in the table.
>>
>> Something designed by OpenSIPS developers? E.g. 'subscribers' table.
>> Or some custom data which you use in your script say via AVPs?
>>
>> If it's possible to store it as key-value pairs, I'd recommend you using
>> local cache [1], [2], [3]
>>
>> [1]  https://www.opensips.org/Documentation/Script-CoreFunctions-3-0#toc4
>> [2]  https://www.opensips.org/Documentation/Script-CoreFunctions-3-0#toc5
>>
>> [3]  https://www.opensips.org/Documentation/Script-CoreFunctions-3-0#toc6
>>
>> [4]  https://opensips.org/html/docs/modules/3.0.x/cachedb_redis.html
>> [5]  https://opensips.org/html/docs/modules/3.0.x/cachedb_sql.html
>> [6]  https://opensips.org/html/docs/modules/3.0.x/exec.html
>>
>> Depending on your OpenSIPS architecture it can be more optimal to use
>> Redis [4],
>> for example in case of OpenSIPS cluster.
>>
>> You may use CACHEDB_SQL [5] (I never used it).
>> You may execute some script with the EXEC [6] function.
>>
>> If your table is tiny and your system architecture allows it,
>> you may store data not in MariaDB but in SQLite.
>>
>> So, as you see, many things depend on the overall size of your system,
>> and it's not so easy to give some certain advice without knowing
>> its architecture and load level.
>>
>>
>>
>> -----------------------------------------------
>> BR, Alexey
>> http://alexeyka.zantsev.com/
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>
>
> --
> Mark Farmer
> farmorg at gmail.com
>
> _______________________________________________
> Users mailing listUsers at lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>


-- 
Mark Farmer
farmorg at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20190828/422a31f1/attachment-0001.html>


More information about the Users mailing list