[ 
https://issues.apache.org/jira/browse/NET-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14977103#comment-14977103
 ] 

Michel Risucci commented on NET-405:
------------------------------------

Hi Gary.

The method "SubnetUtils#getInfo" creates a SubnetInfo instance with useful 
metadata, but "SubnetInfo#isInRange" is the most important.
I'm testing (exactly now, actually) Spring Security's "IpAddressMatcher", as 
[~mickael.tricot] said.
Since I am already familiar with Spring (my favorite Java framework), it was 
quite easy to use, and, according to my tests, it's working flawless!

For anyone wanting to check if some IPv4/IPv6 address is "in a subnet range", 
just try "org.springframework.security.web.util.matcher.IpAddressMatcher" like 
this:

IpAddressMatcher v4Matcher = new IpAddressMatcher("192.168.0.1/24"); // IPv4 
CIDR
IpAddressMatcher v6Matcher = new IpAddressMatcher("fe80:0:0:0:0:0:c0a8:1/120"); 
// IPv6 CIDR
v4Matcher.matches("192.168.0.11");
v6Matcher.matches("fe80:0:0:0:0:0:c0a8:11");

According to documentation, "Both IPv6 and IPv4 addresses are supported, but a 
matcher which is configured with an IPv4 address will never match a request 
which returns an IPv6 address, and vice-versa." - In other words, just don't 
mix the matchers!

> Support for IPv6 in SubnetUtils
> -------------------------------
>
>                 Key: NET-405
>                 URL: https://issues.apache.org/jira/browse/NET-405
>             Project: Commons Net
>          Issue Type: Improvement
>            Reporter: Marc Lefrancois
>
> Currently, we cannot use org.apache.commons.net.util.SubnetUtils with IPv6 
> addresses. This class will become less and less useful as more internet 
> device are only assigned IPv6 addresses since all available IPv4 address 
> blocks have now been attributed. 
> http://en.wikipedia.org/wiki/IPv4_address_exhaustion



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to