Search in sources :

Example 1 with SequentialDnsServerAddressStreamProvider

use of io.netty.resolver.dns.SequentialDnsServerAddressStreamProvider in project graylog2-server by Graylog2.

the class DnsClient method start.

public void start(String dnsServerIps) {
    LOG.debug("Attempting to start DNS client");
    final List<InetSocketAddress> iNetDnsServerIps = parseServerIpAddresses(dnsServerIps);
    nettyEventLoop = new NioEventLoopGroup();
    final DnsNameResolverBuilder dnsNameResolverBuilder = new DnsNameResolverBuilder(nettyEventLoop.next());
    dnsNameResolverBuilder.channelType(NioDatagramChannel.class).queryTimeoutMillis(queryTimeout);
    // Specify custom DNS servers if provided. If not, use those specified in local network adapter settings.
    if (CollectionUtils.isNotEmpty(iNetDnsServerIps)) {
        LOG.debug("Attempting to start DNS client with server IPs [{}] on port [{}] with timeout [{}]", dnsServerIps, DEFAULT_DNS_PORT, requestTimeout);
        final DnsServerAddressStreamProvider dnsServer = new SequentialDnsServerAddressStreamProvider(iNetDnsServerIps);
        dnsNameResolverBuilder.nameServerProvider(dnsServer);
    } else {
        LOG.debug("Attempting to start DNS client with the local network adapter DNS server address on port [{}] with timeout [{}]", DEFAULT_DNS_PORT, requestTimeout);
    }
    resolver = dnsNameResolverBuilder.build();
    LOG.debug("DNS client startup successful");
}
Also used : DnsServerAddressStreamProvider(io.netty.resolver.dns.DnsServerAddressStreamProvider) SequentialDnsServerAddressStreamProvider(io.netty.resolver.dns.SequentialDnsServerAddressStreamProvider) SequentialDnsServerAddressStreamProvider(io.netty.resolver.dns.SequentialDnsServerAddressStreamProvider) DnsNameResolverBuilder(io.netty.resolver.dns.DnsNameResolverBuilder) InetSocketAddress(java.net.InetSocketAddress) NioDatagramChannel(io.netty.channel.socket.nio.NioDatagramChannel) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 NioDatagramChannel (io.netty.channel.socket.nio.NioDatagramChannel)1 DnsNameResolverBuilder (io.netty.resolver.dns.DnsNameResolverBuilder)1 DnsServerAddressStreamProvider (io.netty.resolver.dns.DnsServerAddressStreamProvider)1 SequentialDnsServerAddressStreamProvider (io.netty.resolver.dns.SequentialDnsServerAddressStreamProvider)1 InetSocketAddress (java.net.InetSocketAddress)1