public void testToUriStringIPv4() { String ipStr = "1.2.3.4"; InetAddress ip = InetAddresses.forString(ipStr); assertEquals("1.2.3.4", InetAddresses.toUriString(ip)); }
public void testToUriStringIPv6() { // Unfortunately the InetAddress.toString() method for IPv6 addresses // does not collapse contiguous shorts of zeroes with the :: abbreviation. String ipStr = "3ffe::1"; InetAddress ip = InetAddresses.forString(ipStr); assertEquals("[3ffe::1]", InetAddresses.toUriString(ip)); }
return new HostSpecifier(InetAddresses.toUriString(addr));
return new HostSpecifier(InetAddresses.toUriString(addr));
return new HostSpecifier(InetAddresses.toUriString(addr));
/** * Creates a URL to parse to FFmpeg based on the scheme, address and port. * * <p>TODO Move this method to somewhere better. * * @param scheme * @param address * @param port * @return * @throws URISyntaxException */ @CheckReturnValue static URI createUri(String scheme, InetAddress address, int port) throws URISyntaxException { checkNotNull(address); return new URI( scheme, null /* userInfo */, InetAddresses.toUriString(address), port, null /* path */, null /* query */, null /* fragment */); }
public static String describe(SocketAddress address) { if (address instanceof InetSocketAddress) { InetSocketAddress inet = (InetSocketAddress) address; return InetAddresses.toUriString(inet.getAddress()) + ":" + inet.getPort(); } else { return address.toString(); } }
private String findPublicHostname() { try { return InetAddress.getLocalHost().getHostName().toLowerCase(); } catch (UnknownHostException e) { // Java 7u5 and later on MacOS sometimes throws this unless the local hostname is in DNS // or hosts file. The exception message is the hostname followed by a colon and an error message. final Matcher matcher = HOST_EXCEPTION_MESSAGE_PATTERN.matcher(e.getMessage()); if (matcher.matches()) { return matcher.group(1).toLowerCase(); } return InetAddresses.toUriString(internalIp); } } }
/** * Add a key-value pair that describes an socket address. No attempt is * made to resolve the IP address and the value is recorded as * {@literal <addr>:<port>}. If the supplied value is null and * {@link #omitNullValues} has not been called then {@literal unknown} is * recorded. */ public NetLoggerBuilder add(String name, InetSocketAddress sock) { if (!omitNullValues || sock != null) { s.append(' ').append(name).append('='); if (sock != null) { s.append(InetAddresses.toUriString(sock.getAddress())).append(':').append(sock.getPort()); } } return this; }
public static String toString(InetAddress a) { String name = a.getHostName(); if (InetAddresses.isInetAddress(name)) { return InetAddresses.toAddrString(a); } else { return name + "/" + InetAddresses.toUriString(a); } }
@Override public IRemoteAddress resolve(String domain) { // This is a literal IP address without any port // We add the default port and return the value if (InetAddresses.isInetAddress(domain)) { String host = InetAddresses.toUriString(InetAddresses.forString(domain)); return new RemoteAddress(host, port); } // This is an IP address with a port in it // We return verbatim if (InetAddresses.isUriInetAddress(domain)) { URI v = URI.create(domain); return new RemoteAddress(v.getHost(), v.getPort()); } if (domain.contains(":")) { URI v = URI.create("matrix://" + domain); return new RemoteAddress(v.getHost(), v.getPort()); } return lookupSrv(domain).orElseGet(() -> new RemoteAddress(domain, port)); }
public void testToUriStringIPv4() { String ipStr = "1.2.3.4"; InetAddress ip = InetAddresses.forString(ipStr); assertEquals("1.2.3.4", InetAddresses.toUriString(ip)); }
public void testToUriStringIPv6() { // Unfortunately the InetAddress.toString() method for IPv6 addresses // does not collapse contiguous shorts of zeroes with the :: abbreviation. String ipStr = "3ffe::1"; InetAddress ip = InetAddresses.forString(ipStr); assertEquals("[3ffe::1]", InetAddresses.toUriString(ip)); }
httpUri = buildUri("http", InetAddresses.toUriString(nodeInfo.getInternalIp()), config.getHttpPort()); httpExternalUri = buildUri("http", nodeInfo.getExternalAddress(), httpUri.getPort()); httpsUri = buildUri("https", InetAddresses.toUriString(nodeInfo.getInternalIp()), config.getHttpsPort()); httpsExternalUri = buildUri("https", nodeInfo.getExternalAddress(), httpsUri.getPort()); adminUri = buildUri("https", InetAddresses.toUriString(nodeInfo.getInternalIp()), config.getAdminPort()); adminExternalUri = buildUri("https", nodeInfo.getExternalAddress(), adminUri.getPort()); } else { adminUri = buildUri("http", InetAddresses.toUriString(nodeInfo.getInternalIp()), config.getAdminPort()); adminExternalUri = buildUri("http", nodeInfo.getExternalAddress(), adminUri.getPort());
return new HostSpecifier(InetAddresses.toUriString(addr));
return new HostSpecifier(InetAddresses.toUriString(addr));
return new HostSpecifier(InetAddresses.toUriString(addr));
return new HostSpecifier(InetAddresses.toUriString(addr));
return new HostSpecifier(InetAddresses.toUriString(addr));
httpUri = buildUri("http", InetAddresses.toUriString(nodeInfo.getInternalIp()), port(httpChannel)); httpExternalUri = buildUri("http", nodeInfo.getExternalAddress(), httpUri.getPort()); adminUri = buildUri("http", InetAddresses.toUriString(nodeInfo.getInternalIp()), port(adminChannel)); adminExternalUri = buildUri("http", nodeInfo.getExternalAddress(), adminUri.getPort());