code: public static boolean isInetAddress(String host) {
  		int colons = 0;
  		int dots = 0;
  		byte[] bytes = encodeAscii(host);
  
  		// expect ipv6 address
  		if (bytes[0] == '[') {
  			return bytes[bytes.length - 1] == ']' && checkIpv6(bytes, 1, bytes.length - 1);
  		}
  
  		// assume ipv4 could be as oct, bin, dec; ipv6 - hex
  		for (byte b : bytes) {
  			if (b == '.') {
  				dots++;
  			} else if (b == ':') {
  				if (dots != 0) {
  					return false;
  				}
  				colons++;
  			} else if (Character.digit(b, 16) == -1) {
  				return false;
  			}
  		}
  
  		if (dots < 4) {
  			if (colons > 0 && colons < 8) {
  				return checkIpv6(bytes, 0, bytes.length);
  			}
  			return checkIpv4(bytes, 0, bytes.length);
  		}
  		return false;
  	}
docs: https://url.spec.whatwg.org/