ValidHostInfo (@NotNull String host) { try { HostAndPort parsedHost = HostAndPort.fromString(host); if (parsedHost.hasPort()) { return ValidHostInfo.INVALID; } host = parsedHost.getHost(); try { InetAddresses.forString(host); return ValidHostInfo.VALID; } catch (IllegalArgumentException e) { // it is not an IPv4 or IPv6 literal } InternetDomainName.from(host); } catch (IllegalArgumentException e) { return ValidHostInfo.INVALID; } return ValidHostInfo.VALID_PROXY; }