Home / File/ DefaultDnsServerAddressStreamProvider.java — netty Source File

DefaultDnsServerAddressStreamProvider.java — netty Source File

Architecture documentation for DefaultDnsServerAddressStreamProvider.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2017 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.resolver.dns;

import io.netty.util.NetUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.SocketUtils;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;

import java.lang.reflect.Method;
import java.net.Inet6Address;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static io.netty.resolver.dns.DnsServerAddresses.sequential;

/**
 * A {@link DnsServerAddressStreamProvider} which will use predefined default DNS servers to use for DNS resolution.
 * These defaults do not respect your host's machines defaults.
 * <p>
 * This may use the JDK's blocking DNS resolution to bootstrap the default DNS server addresses.
 */
public final class DefaultDnsServerAddressStreamProvider implements DnsServerAddressStreamProvider {
    private static final InternalLogger logger =
            InternalLoggerFactory.getInstance(DefaultDnsServerAddressStreamProvider.class);
    private static final String DEFAULT_FALLBACK_SERVER_PROPERTY = "io.netty.resolver.dns.defaultNameServerFallback";
    public static final DefaultDnsServerAddressStreamProvider INSTANCE = new DefaultDnsServerAddressStreamProvider();

    private static final List<InetSocketAddress> DEFAULT_NAME_SERVER_LIST;
    private static final DnsServerAddresses DEFAULT_NAME_SERVERS;
    static final int DNS_PORT = 53;

    static {
        final List<InetSocketAddress> defaultNameServers = new ArrayList<InetSocketAddress>(2);
        if (!PlatformDependent.isAndroid()) {
            // Skip this on Android; it has neither /etc/resolv.conf nor JNDI classes.
            // See https://github.com/netty/netty/issues/8654
            if (!PlatformDependent.isWindows()) {
                // Try reading /etc/resolv.conf. It's usually found on Linux or macOS, but can also be missing.
                try {
                    defaultNameServers.addAll(ResolvConf.system().getNameservers());
                } catch (IllegalStateException e) {
                    String fallbackMessage = "Failed to get name servers from /etc/resolv.conf; will fall back to JNDI";
// ... (122 more lines)

Subdomains

Frequently Asked Questions

What does DefaultDnsServerAddressStreamProvider.java do?
DefaultDnsServerAddressStreamProvider.java is a source file in the netty codebase, written in java. It belongs to the NativeResolver domain, JavaResolver subdomain.
Where is DefaultDnsServerAddressStreamProvider.java in the architecture?
DefaultDnsServerAddressStreamProvider.java is located at resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsServerAddressStreamProvider.java (domain: NativeResolver, subdomain: JavaResolver, directory: resolver-dns/src/main/java/io/netty/resolver/dns).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free