Class IpUtils

java.lang.Object
org.eblocker.server.common.util.IpUtils

public class IpUtils extends Object
Utility functions that can deal with both IPv4 and IPv6 addresses.
  • Constructor Details

    • IpUtils

      public IpUtils()
  • Method Details

    • shrinkIpRange

      public static String shrinkIpRange(String ipRange)
      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

      public static boolean isIpRange(String ipRange)
      Returns true if a string is an IPv4 or IPv6 range in CIDR notation.
    • isIPAddress

      public static boolean isIPAddress(String address)
      Returns true if a string is an IPv4 or IPv6 address.