Package org.conscrypt

Class AddressUtils

java.lang.Object
org.conscrypt.AddressUtils

final class AddressUtils extends Object
Utilities to check whether IP addresses meet some criteria.
  • Field Details

  • Constructor Details

    • AddressUtils

      private AddressUtils()
  • Method Details

    • isValidSniHostname

      static boolean isValidSniHostname(String sniHostname)
      Returns true when the supplied hostname is valid for SNI purposes.
    • isLiteralIpAddress

      static boolean isLiteralIpAddress(String hostname)
      Returns true if the supplied hostname is an literal IP address.
    • isValidIPv4

      private static boolean isValidIPv4(String s, int start, int end, boolean allowLeadingZeros)
      Validates IPv4 address. Expects exactly 4 octets separated by dots, each octet being 0-255. Allows leading zeros (up to 3 digits per octet). Parses the substring [start, end) without allocation.
    • isValidIPv6

      private static boolean isValidIPv6(String s)
      Validates IPv6 address. Supports full, compressed (::), and embedded IPv4 formats. Also supports optional Zone ID (%zone) at the end. Scans the string in a single pass without allocations.
    • isValidZoneId

      private static boolean isValidZoneId(String s, int start)
      Validates the IPv6 Zone ID (Scope ID). A valid Zone ID must not be empty and must not contain any line terminators, matching the behavior of the '.' character in the original regular expression.
    • isDigit

      private static boolean isDigit(char c)
      Returns true if the character is a basic ASCII digit (0-9). We use this custom implementation instead of Character.isDigit(char) to avoid checking for other Unicode digit characters, keeping it strictly to ASCII and avoiding any locale or Unicode overhead.
    • isHexDigit

      private static boolean isHexDigit(char c)
      Returns true if the character is a valid hexadecimal digit (0-9, a-f, A-F). This is a simple range check that avoids any character class or regex compilation.
    • toLowerCaseAscii

      private static char toLowerCaseAscii(char c)
    • asciiEqualsIgnoreCase

      private static boolean asciiEqualsIgnoreCase(String s, String expected)
      Compares two ASCII strings case-insensitively. We use this custom implementation instead of String.equalsIgnoreCase(String) to: 1. Avoid dependency on Guava's Ascii class. 2. Avoid locale-dependent behavior of String.equalsIgnoreCase (e.g. Turkish 'I' mapping), ensuring strictly ASCII comparison. 3. Avoid any object allocations.