Java Code Examples for io.netty.resolver.ResolvedAddressTypes#IPV6_ONLY
The following examples show how to use
io.netty.resolver.ResolvedAddressTypes#IPV6_ONLY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DnsNameResolverBuilder.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
/** * Compute a {@link ResolvedAddressTypes} from some {@link InternetProtocolFamily}s. * An empty input will return the default value, based on "java.net" System properties. * Valid inputs are (), (IPv4), (IPv6), (Ipv4, IPv6) and (IPv6, IPv4). * @param internetProtocolFamilies a valid sequence of {@link InternetProtocolFamily}s * @return a {@link ResolvedAddressTypes} */ public static ResolvedAddressTypes computeResolvedAddressTypes(InternetProtocolFamily... internetProtocolFamilies) { if (internetProtocolFamilies == null || internetProtocolFamilies.length == 0) { return DnsNameResolver.DEFAULT_RESOLVE_ADDRESS_TYPES; } if (internetProtocolFamilies.length > 2) { throw new IllegalArgumentException("No more than 2 InternetProtocolFamilies"); } switch(internetProtocolFamilies[0]) { case IPv4: return (internetProtocolFamilies.length >= 2 && internetProtocolFamilies[1] == InternetProtocolFamily.IPv6) ? ResolvedAddressTypes.IPV4_PREFERRED: ResolvedAddressTypes.IPV4_ONLY; case IPv6: return (internetProtocolFamilies.length >= 2 && internetProtocolFamilies[1] == InternetProtocolFamily.IPv4) ? ResolvedAddressTypes.IPV6_PREFERRED: ResolvedAddressTypes.IPV6_ONLY; default: throw new IllegalArgumentException( "Couldn't resolve ResolvedAddressTypes from InternetProtocolFamily array"); } }
Example 2
Source File: DefaultDnsClient.java From servicetalk with Apache License 2.0 | 5 votes |
private static ResolvedAddressTypes toNettyType(final DnsResolverAddressTypes dnsResolverAddressTypes) { switch (dnsResolverAddressTypes) { case IPV4_ONLY: return ResolvedAddressTypes.IPV4_ONLY; case IPV6_ONLY: return ResolvedAddressTypes.IPV6_ONLY; case IPV6_PREFERRED: return ResolvedAddressTypes.IPV6_PREFERRED; case IPV4_PREFERRED: return ResolvedAddressTypes.IPV4_PREFERRED; default: throw new Error(); } }