Package org.eblocker.server.common.util
Class IpUtils
java.lang.Object
org.eblocker.server.common.util.IpUtils
Utility functions that can deal with both IPv4 and IPv6 addresses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisIPAddress(String address) Returns true if a string is an IPv4 or IPv6 address.static booleanReturns true if a string is an IPv4 or IPv6 range in CIDR notation.static StringshrinkIpRange(String ipRange) Shrinks an IP range to a reasonable limit.
-
Constructor Details
-
IpUtils
public IpUtils()
-
-
Method Details
-
shrinkIpRange
Shrinks an IP range to a reasonable limit. An IPv4 prefix must be at least 8 bits while an IPv6 prefix must be at least 32 bits.- Parameters:
ipRange- IP range in CIDR notation, e.g. 17.0.0.0/8 or 2603:1000::/25- Returns:
- resulting IP range in CIDR notation
-
isIpRange
Returns true if a string is an IPv4 or IPv6 range in CIDR notation. -
isIPAddress
Returns true if a string is an IPv4 or IPv6 address.
-