Example usage for io.netty.util NetUtil isIpV4StackPreferred

List of usage examples for io.netty.util NetUtil isIpV4StackPreferred

Introduction

In this page you can find the example usage for io.netty.util NetUtil isIpV4StackPreferred.

Prototype

public static boolean isIpV4StackPreferred() 

Source Link

Document

Returns true if IPv4 should be used even if the system supports both IPv4 and IPv6.

Usage

From source file:com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup.java

License:Apache License

private static List<DnsQuestion> newQuestions(String hostname,
        @Nullable ResolvedAddressTypes resolvedAddressTypes) {

    if (resolvedAddressTypes == null) {
        if (NetUtil.isIpV4StackPreferred()) {
            resolvedAddressTypes = ResolvedAddressTypes.IPV4_ONLY;
        } else {/*from   w ww.  java 2  s .co m*/
            resolvedAddressTypes = ResolvedAddressTypes.IPV4_PREFERRED;
        }
    }

    final ImmutableList.Builder<DnsQuestion> builder = ImmutableList.builder();
    switch (resolvedAddressTypes) {
    case IPV4_ONLY:
    case IPV4_PREFERRED:
    case IPV6_PREFERRED:
        builder.add(new DefaultDnsQuestion(hostname, DnsRecordType.A));
        break;
    }
    switch (resolvedAddressTypes) {
    case IPV6_ONLY:
    case IPV4_PREFERRED:
    case IPV6_PREFERRED:
        builder.add(new DefaultDnsQuestion(hostname, DnsRecordType.AAAA));
        break;
    }
    return builder.build();
}

From source file:io.vertx.ext.mail.MailSslTest.java

License:Open Source License

@Test
public void mailTestSSLValidCertIpv6(TestContext testContext) {
    // don't run ipv6 tests when ipv4 is preferred, this should enable running the tests
    // on CI where ipv6 is not configured
    Assume.assumeFalse("no ipv6 support",
            NetUtil.isIpV4StackPreferred() || "true".equals(System.getProperty("test.disableIpV6")));
    this.testContext = testContext;
    startServer(SERVER_JKS);/*from   w ww  . j a v  a2  s .c  o  m*/
    final MailConfig config = new MailConfig("::1", 1465, StartTLSOptions.DISABLED, LoginOption.DISABLED)
            .setSsl(true).setKeyStore(CLIENT_JKS).setKeyStorePassword("password");
    MailClient mailClient = MailClient.createNonShared(vertx, config);
    testSuccess(mailClient);
}

From source file:io.vertx.ext.mail.MailSslTest.java

License:Open Source License

@Test
public void mailTestSSLValidCertIpv6_2(TestContext testContext) {
    Assume.assumeFalse("no ipv6 support",
            NetUtil.isIpV4StackPreferred() || "true".equals(System.getProperty("test.disableIpV6")));
    this.testContext = testContext;
    startServer(SERVER_JKS);/*from www  . ja v a2 s  .c  o m*/
    final MailConfig config = new MailConfig("[::1]", 1465, StartTLSOptions.DISABLED, LoginOption.DISABLED)
            .setSsl(true).setKeyStore(CLIENT_JKS).setKeyStorePassword("password");
    MailClient mailClient = MailClient.createNonShared(vertx, config);
    testSuccess(mailClient);
}

From source file:io.vertx.ext.mail.MailSslTest.java

License:Open Source License

@Test
public void mailTestSSLValidCertIpv6_3(TestContext testContext) {
    Assume.assumeFalse("no ipv6 support",
            NetUtil.isIpV4StackPreferred() || "true".equals(System.getProperty("test.disableIpV6")));
    this.testContext = testContext;
    startServer(SERVER_JKS);/*from ww w.j  av a  2s .com*/
    final MailConfig config = new MailConfig("[0000:0000:0000:0000:0000:0000:0000:0001]", 1465,
            StartTLSOptions.DISABLED, LoginOption.DISABLED).setSsl(true).setKeyStore(CLIENT_JKS)
                    .setKeyStorePassword("password");
    MailClient mailClient = MailClient.createNonShared(vertx, config);
    testSuccess(mailClient);
}