[ASTPPCOM-184] IP_MAP bad matching netmask Created: 22/Feb/17  Updated: 01/Apr/21  Resolved: 01/Apr/21

Status: Done
Project: ASTPP Community
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature
Reporter: Neurotec Tecnologia S.A.S (Inactive) Assignee: Samir Doshi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

hi when we register a ip settings for example, 89.80.70.0/24 this not allow calls from 89.80.70.55 throws ([ASTPP] [Dialplan] Call authentication fail..!!).

this was our fast solution on astpp.functions.lua:

replace
~~~lua
local query = "SELECT "..TBL_IP_MAP..".*, (SELECT number FROM "..TBL_USERS.." where id=accountid AND status=0 AND deleted=0) AS account_code FROM "..TBL_IP_MAP.." WHERE SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND prefix IN (NULL,'') OR SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND \"" .. destination_number .. "\" RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"
~~~

with
~~~lua
local query = "SELECT "..TBL_IP_MAP..".*, (SELECT number FROM "..TBL_USERS.." where id=accountid AND status=0 AND deleted=0) AS account_code FROM "..TBL_IP_MAP.." WHERE (INET_ATON(\"" .. params:getHeader('Hunt-Network-Addr').. "\") & (0xFFFFFFFF & (-1 << 32 - SUBSTRING_INDEX(ip, '/',-1)))) = ((0xFFFFFFFF & (-1 << 32 - SUBSTRING_INDEX(ip, '/',-1))) & INET_ATON(SUBSTRING_INDEX(ip,'/',1))) OR SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND prefix IN (NULL,'') OR SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND \"" .. destination_number .. "\" RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"
~~~

thanks for you work



 Comments   
Comment by Samir Doshi [ 24/Feb/17 ]

Thanks for the patch. We will test it out and merge it.

Best Regards

Samir Doshi
iNextrix Technologies Pvt. Ltd.
http://www.inextrix.com

Disclaimer:
The information contained in this communication is confidential and may be
legally privileged. It is intended solely for the use of the individual or
entity to whom it is addressed and others authorised to receive it. If you
are not the intended recipient you are hereby notified that any disclosure,
copying, distribution or taking action in reliance of the contents of this
information is strictly prohibited and may be unlawful.

On Wed, Feb 22, 2017 at 8:44 PM, Neurotec Tecnologia S.A.S <
notifications@github.com> wrote:

> hi when we register a ip settings for example, 89.80.70.0/24 this not
> allow calls from 89.80.70.55 for example.
>
> this was our fast solution on astpp.functions.lua:
>
> replace
>
> local query = "SELECT "..TBL_IP_MAP..".*, (SELECT number FROM "..TBL_USERS.." where id=accountid AND status=0 AND deleted=0) AS account_code FROM "..TBL_IP_MAP.." WHERE SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND prefix IN (NULL,'') OR SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND \"" .. destination_number .. "\" RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"
>
> with
>
> local query = "SELECT "..TBL_IP_MAP..".*, (SELECT number FROM "..TBL_USERS.." where id=accountid AND status=0 AND deleted=0) AS account_code FROM "..TBL_IP_MAP.." WHERE INET_ATON(\"" .. params:getHeader('Hunt-Network-Addr').. "\") = ((0xFFFFFFFF & (-1 << 32 - SUBSTRING_INDEX(ip, '/',-1))) & INET_ATON(SUBSTRING_INDEX(ip,'/',1))) OR SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND prefix IN (NULL,'') OR SUBSTRING( ip, 1, CHAR_LENGTH( ip ) -3 ) = \"" .. params:getHeader('Hunt-Network-Addr').. "\" AND \"" .. destination_number .. "\" RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"
>
> thanks for you work
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/iNextrix/ASTPP/issues/184>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AA6gcUMzfP1ESAsjOLoxeKA3UlzxjFwWks5rfFDCgaJpZM4MIxOi>
> .
>

Comment by Samir Doshi [ 01/Mar/17 ]

We applied patch now. Thanks for the contribution.

Generated at Sat Feb 10 07:14:54 CET 2024 using Jira 8.13.3#813003-sha1:22ebedbb75c99b147c66f14e031dd8a2d214753a.