Uploaded image for project: 'ASTPP Community'
  1. ASTPP Community
  2. ASTPPCOM-184

IP_MAP bad matching netmask

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Done
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      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

        Attachments

          Activity

            People

            Assignee:
            samir.doshi Samir Doshi
            Reporter:
            Neurotec Neurotec Tecnologia S.A.S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: