You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2014/09/07 09:48:54 UTC

git commit: Accept addresses like 0.0.0.0 or :: (IPV4 and IPV6)in the inSubnet() method (see DIRMINA-773)

Repository: mina
Updated Branches:
  refs/heads/2.0 de58078ce -> faa8e58e1


Accept addresses like 0.0.0.0 or :: (IPV4 and IPV6)in the inSubnet()
method (see DIRMINA-773)

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/faa8e58e
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/faa8e58e
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/faa8e58e

Branch: refs/heads/2.0
Commit: faa8e58e11a3fa50e5169f6f9c1119d275199fec
Parents: de58078
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Sun Sep 7 09:48:42 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Sun Sep 7 09:48:42 2014 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/mina/filter/firewall/Subnet.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/faa8e58e/mina-core/src/main/java/org/apache/mina/filter/firewall/Subnet.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/filter/firewall/Subnet.java b/mina-core/src/main/java/org/apache/mina/filter/firewall/Subnet.java
index f88e302..c5d65ca 100644
--- a/mina-core/src/main/java/org/apache/mina/filter/firewall/Subnet.java
+++ b/mina-core/src/main/java/org/apache/mina/filter/firewall/Subnet.java
@@ -45,7 +45,7 @@ public class Subnet {
 
     /**
      * Creates a subnet from CIDR notation. For example, the subnet
-     * 192.168.0.0/24 would be created using the {@link InetAddress}  
+     * 192.168.0.0/24 would be created using the {@link InetAddress}
      * 192.168.0.0 and the mask 24.
      * @param subnet The {@link InetAddress} of the subnet
      * @param mask The mask
@@ -70,7 +70,7 @@ public class Subnet {
         this.subnetMask = IP_MASK >> (mask - 1);
     }
 
-    /** 
+    /**
      * Converts an IP address into an integer
      */
     private int toInt(InetAddress inetAddress) {
@@ -84,7 +84,7 @@ public class Subnet {
     }
 
     /**
-     * Converts an IP address to a subnet using the provided 
+     * Converts an IP address to a subnet using the provided
      * mask
      * @param address The address to convert into a subnet
      * @return The subnet as an integer
@@ -99,6 +99,10 @@ public class Subnet {
      * @return True if the address is within this subnet, false otherwise
      */
     public boolean inSubnet(InetAddress address) {
+        if (address.isAnyLocalAddress()) {
+            return true;
+        }
+
         return toSubnet(address) == subnetInt;
     }