Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-957

MINA build in BlacklistFilter does not support IPV6 address

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.7
    • Fix Version/s: 2.0.8
    • Component/s: Filter
    • Labels:

      Description

      MINA build in BlacklistFilter does not support IPV6 address. If MINA itself supports binding to IPV4 and IPV6 why this restriction was kept in BlacklistFilter. I checked the org.apache.mina.filter.firewall.Subnet class in MINA sources and found that it specifically checks for Inet4Address

      if (!(subnet instanceof Inet4Address))

      { throw new IllegalArgumentException("Only IPv4 supported"); }

        Activity

        Hide
        elecharny Emmanuel Lecharny added a comment -

        Added support for IPV6 in the BackFilter class

        Fixed with commit dd83fecdbb85fdd2276a350e509f91aa12e9e3ce

        Show
        elecharny Emmanuel Lecharny added a comment - Added support for IPV6 in the BackFilter class Fixed with commit dd83fecdbb85fdd2276a350e509f91aa12e9e3ce
        Hide
        nitinp Nitin Phuria added a comment -

        Today I got a mail from Apache MINA for [ANNOUNCE] Apache MINA 2.0.8 release and I could see that one of the bug raised by me https://issues.apache.org/jira/browse/DIRMINA-957 was fixed. So I downloaded the Mina 2.0.8 and also source code to see the fix and I found the following.
        I checked the org.apache.mina.filter.firewall.Subnet class
        The check for IPv4 is still there and it throws exception so the code will never go further where IPv6 support is written.

        public Subnet(InetAddress subnet, int mask) {
        if (subnet == null)

        { throw new IllegalArgumentException("Subnet address can not be null"); }

        if (!(subnet instanceof Inet4Address))

        { throw new IllegalArgumentException("Only IPv4 supported"); }

        if (subnet instanceof Inet4Address) {
        // IPV4 address
        if ((mask < 0) || (mask > 32))

        { throw new IllegalArgumentException("Mask has to be an integer between 0 and 32 for an IPV4 address"); }

        else

        { this.subnet = subnet; subnetInt = toInt(subnet); this.suffix = mask; // binary mask for this subnet this.subnetMask = IP_MASK_V4 >> (mask - 1); }

        } else {
        // IPV6 address
        if ((mask < 0) || (mask > 128))

        { throw new IllegalArgumentException("Mask has to be an integer between 0 and 128 for an IPV6 address"); }

        else

        { this.subnet = subnet; subnetLong = toLong(subnet); this.suffix = mask; // binary mask for this subnet this.subnetMask = IP_MASK_V6 >> (mask - 1); }

        }
        }

        Show
        nitinp Nitin Phuria added a comment - Today I got a mail from Apache MINA for [ANNOUNCE] Apache MINA 2.0.8 release and I could see that one of the bug raised by me https://issues.apache.org/jira/browse/DIRMINA-957 was fixed. So I downloaded the Mina 2.0.8 and also source code to see the fix and I found the following. I checked the org.apache.mina.filter.firewall.Subnet class The check for IPv4 is still there and it throws exception so the code will never go further where IPv6 support is written. public Subnet(InetAddress subnet, int mask) { if (subnet == null) { throw new IllegalArgumentException("Subnet address can not be null"); } if (!(subnet instanceof Inet4Address)) { throw new IllegalArgumentException("Only IPv4 supported"); } if (subnet instanceof Inet4Address) { // IPV4 address if ((mask < 0) || (mask > 32)) { throw new IllegalArgumentException("Mask has to be an integer between 0 and 32 for an IPV4 address"); } else { this.subnet = subnet; subnetInt = toInt(subnet); this.suffix = mask; // binary mask for this subnet this.subnetMask = IP_MASK_V4 >> (mask - 1); } } else { // IPV6 address if ((mask < 0) || (mask > 128)) { throw new IllegalArgumentException("Mask has to be an integer between 0 and 128 for an IPV6 address"); } else { this.subnet = subnet; subnetLong = toLong(subnet); this.suffix = mask; // binary mask for this subnet this.subnetMask = IP_MASK_V6 >> (mask - 1); } } }
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Stupid mistake... Fixed with commit c915d1f6fbb9809b90366405b501e9f8842e32d7

        The package can be downloaded from http://people.apache.org/~elecharny/ for test purpose. A release will be done shortly.

        Show
        elecharny Emmanuel Lecharny added a comment - Stupid mistake... Fixed with commit c915d1f6fbb9809b90366405b501e9f8842e32d7 The package can be downloaded from http://people.apache.org/~elecharny/ for test purpose. A release will be done shortly.

          People

          • Assignee:
            Unassigned
            Reporter:
            nitinp Nitin Phuria
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development