use of io.netty.resolver.dns.DnsServerAddressStreamProvider in project netty by netty.
the class MacOSDnsServerAddressStreamProviderTest method testStream.
@Test
void testStream() {
MacOSDnsServerAddressStreamProvider.ensureAvailability();
DnsServerAddressStreamProvider provider = new MacOSDnsServerAddressStreamProvider();
DnsServerAddressStream stream = provider.nameServerAddressStream("netty.io");
assertNotNull(stream);
assertNotEquals(0, stream.size());
for (int i = 0; i < stream.size(); i++) {
assertNotEquals(0, stream.next().getPort());
}
}
use of io.netty.resolver.dns.DnsServerAddressStreamProvider 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");
}
Aggregations