@Test public void should_recognise_ipv6_literal() { assertThat(subject.isLiteralIpAddress("db8::")).hasValue("db8::"); assertThat(subject.isLiteralIpAddress("::1")).hasValue("::1"); assertThat(subject.isLiteralIpAddress("0db8::1")).hasValue("0db8::1"); assertThat(subject.isLiteralIpAddress("Db8:db9:1")).hasValue("Db8:db9:1"); assertThat(subject.isLiteralIpAddress("dB8:db9::1%eth0")).hasValue("dB8:db9::1%eth0"); assertThat(subject.isLiteralIpAddress("fe80::b62e:99ff:fe46:41f2%en0")).hasValue("fe80::b62e:99ff:fe46:41f2%en0"); assertThat(subject.isLiteralIpAddress("::FFFF:192.168.1.250")).hasValue("::FFFF:192.168.1.250"); }
Optional<String> isLiteralIpAddress(String host) { if (isLiteralV4Address(host)) return Optional.of(host); else if (host.contains(":")) { final Matcher matcher = IPV6_ADDRESS_PATTERN.matcher(host); if (matcher.matches()) return Optional.of(matcher.group(1)); } return Optional.empty(); }
HappyEyeballsResolver implements SocketAddressResolver { Optional<String> isLiteralIpAddress(String host) { if (isLiteralV4Address(host)) return Optional.of(host); else if (host.contains(":")) { final Matcher matcher = IPV6_ADDRESS_PATTERN.matcher(host); if (matcher.matches()) return Optional.of(matcher.group(1)); } return Optional.empty(); } }
HappyEyeballsResolver implements SocketAddressResolver { Optional<String> isLiteralIpAddress(String host) { if (isLiteralV4Address(host)) return Optional.of(host); else if (host.contains(":")) { final Matcher matcher = IPV6_ADDRESS_PATTERN.matcher(host); if (matcher.matches()) return Optional.of(matcher.group(1)); } return Optional.empty(); } HappyEyeballsResolver(HttpClient httpClient); }
HappyEyeballsResolver implements SocketAddressResolver { Optional<String> isLiteralIpAddress(String host) { if (isLiteralV4Address(host)) return Optional.of(host); else if (host.contains(":")) { final Matcher matcher = IPV6_ADDRESS_PATTERN.matcher(host); if (matcher.matches()) return Optional.of(matcher.group(1)); } return Optional.empty(); } HappyEyeballsResolver(HttpClient httpClient); @Override void resolve(String host, int port, Promise<List<InetSocketAddress>> promise); }
HappyEyeballsResolver implements SocketAddressResolver { Optional<String> isLiteralIpAddress(String host) { if (isLiteralV4Address(host)) return Optional.of(host); else if (host.contains(":")) { final Matcher matcher = IPV6_ADDRESS_PATTERN.matcher(host); if (matcher.matches()) return Optional.of(matcher.group(1)); } return Optional.empty(); } HappyEyeballsResolver(HttpClient httpClient); @Override void resolve(String host, int port, Promise<List<InetSocketAddress>> promise); static final long HAPPY_EYEBALLS_TOTAL_TIMEOUT_NANOS; }