Formatting (no-op)
This commit is contained in:
@@ -37,6 +37,7 @@ import java.util.List;
|
|||||||
* both IPv4 and IPv6.
|
* both IPv4 and IPv6.
|
||||||
*/
|
*/
|
||||||
public class CIDRUtils {
|
public class CIDRUtils {
|
||||||
|
|
||||||
private final String cidr;
|
private final String cidr;
|
||||||
|
|
||||||
private InetAddress inetAddress;
|
private InetAddress inetAddress;
|
||||||
@@ -44,7 +45,6 @@ public class CIDRUtils {
|
|||||||
private InetAddress endAddress;
|
private InetAddress endAddress;
|
||||||
private final int prefixLength;
|
private final int prefixLength;
|
||||||
|
|
||||||
|
|
||||||
public CIDRUtils(String cidr) throws UnknownHostException {
|
public CIDRUtils(String cidr) throws UnknownHostException {
|
||||||
|
|
||||||
this.cidr = cidr;
|
this.cidr = cidr;
|
||||||
@@ -66,7 +66,6 @@ public class CIDRUtils {
|
|||||||
|
|
||||||
|
|
||||||
private void calculate() throws UnknownHostException {
|
private void calculate() throws UnknownHostException {
|
||||||
|
|
||||||
ByteBuffer maskBuffer;
|
ByteBuffer maskBuffer;
|
||||||
int targetSize;
|
int targetSize;
|
||||||
if (inetAddress.getAddress().length == 4) {
|
if (inetAddress.getAddress().length == 4) {
|
||||||
@@ -120,14 +119,9 @@ public class CIDRUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getNetworkAddress() {
|
public String getNetworkAddress() {
|
||||||
|
|
||||||
return this.startAddress.getHostAddress();
|
return this.startAddress.getHostAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBroadcastAddress() {
|
|
||||||
return this.endAddress.getHostAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInRange(String ipAddress) throws UnknownHostException {
|
public boolean isInRange(String ipAddress) throws UnknownHostException {
|
||||||
InetAddress address = InetAddress.getByName(ipAddress);
|
InetAddress address = InetAddress.getByName(ipAddress);
|
||||||
BigInteger start = new BigInteger(1, this.startAddress.getAddress());
|
BigInteger start = new BigInteger(1, this.startAddress.getAddress());
|
||||||
@@ -139,4 +133,5 @@ public class CIDRUtils {
|
|||||||
|
|
||||||
return (st == -1 || st == 0) && (te == -1 || te == 0);
|
return (st == -1 || st == 0) && (te == -1 || te == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user