You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2018/01/22 15:20:00 UTC
[jira] [Resolved] (NET-651) Ip Range Check with SubnetUtils
provides incorrect answer
[ https://issues.apache.org/jira/browse/NET-651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sebb resolved NET-651.
----------------------
Resolution: Not A Problem
The Javadoc for isInRange says:
"Returns true if the parameter address is in the range of usable endpoint addresses for this subnet. This excludes the network and broadcast addresses."
> Ip Range Check with SubnetUtils provides incorrect answer
> ---------------------------------------------------------
>
> Key: NET-651
> URL: https://issues.apache.org/jira/browse/NET-651
> Project: Commons Net
> Issue Type: Bug
> Reporter: sathyam
> Priority: Major
>
> {code:java}
> private static void checkIp() {
> System.out.println(verifyCommonsNet("192.168.0.1", "192.168.0.1/32"));
> System.out.println(verifySpringSecurity("192.168.0.1", "192.168.0.1/32"));
> }
> private static boolean verifyCommonsNet(String ip, String subnet) {
> SubnetUtils.SubnetInfo subnetInfo = (new SubnetUtils(subnet)).getInfo();
> return subnetInfo.isInRange(ip);
> }
> private static boolean verifySpringSecurity(String ip, String subnet) {
> IpAddressMatcher ipAddressMatcher = new IpAddressMatcher(subnet);
> return ipAddressMatcher.matches(ip);
> }{code}
>
> Tried to check Ip range functionality with Subnet Utils. But I get an incorrect answer when using mask of 32. The same CIDR with Spring security provides the right answer. checking 192.168.0.1 against 192.168.0.1/32 should return true.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)