Remove IpSubnet.main()
- Should be run as a test case
This commit is contained in:
parent
65c526c1c8
commit
54047c69cf
@ -53,7 +53,7 @@ import java.net.UnknownHostException;
|
|||||||
*/
|
*/
|
||||||
public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
||||||
/** Internal representation */
|
/** Internal representation */
|
||||||
private CIDR cidr;
|
private final CIDR cidr;
|
||||||
|
|
||||||
/** Create IpSubnet for ALL (used for ALLOW or DENY ALL) */
|
/** Create IpSubnet for ALL (used for ALLOW or DENY ALL) */
|
||||||
public IpSubnet() {
|
public IpSubnet() {
|
||||||
@ -137,26 +137,4 @@ public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
|||||||
public int compareTo(IpSubnet o) {
|
public int compareTo(IpSubnet o) {
|
||||||
return cidr.toString().compareTo(o.cidr.toString());
|
return cidr.toString().compareTo(o.cidr.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple test functions
|
|
||||||
*
|
|
||||||
* @param args where args[0] is the netmask (standard or CIDR notation) and optional args[1] is
|
|
||||||
* the inetAddress to test with this IpSubnet
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
if (args.length != 0) {
|
|
||||||
IpSubnet ipSubnet = null;
|
|
||||||
try {
|
|
||||||
ipSubnet = new IpSubnet(args[0]);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
System.out.println("IpSubnet: " + ipSubnet.toString() + " from " + ipSubnet.cidr.getBaseAddress() + " to "
|
|
||||||
+ ipSubnet.cidr.getEndAddress() + " mask " + ipSubnet.cidr.getMask());
|
|
||||||
if (args.length > 1) {
|
|
||||||
System.out.println("Is IN: " + args[1] + " " + ipSubnet.contains(args[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user