Top Description Fields Constructors Methods
io.netty.resolver.dns

public final Class UnixResolverDnsServerAddressStreamProvider

extends Object
implements DnsServerAddressStreamProvider
Class Inheritance
All Implemented Interfaces
io.netty.resolver.dns.DnsServerAddressStreamProvider
Imports
io.netty.util.NetUtil, io.netty.util.internal.SocketUtils, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.BufferedReader, .File, .FileReader, .IOException, java.net.InetSocketAddress, java.util.ArrayList, .Collection, .Collections, .HashMap, .List, .Map, java.util.regex.Pattern

Able to parse files such as /etc/resolv.conf and /etc/resolver to respect the system default domain servers.

Field Summary

Modifier and TypeField and Description
private final DnsServerAddresses
private static final String
private final Map<String, DnsServerAddresses>
private static final String
private static final String
private static final InternalLogger
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
UnixResolverDnsServerAddressStreamProvider(File etcResolvConf, File...
List of files of the format defined in /etc/resolver.
etcResolverFiles
)

Parse a file of the format /etc/resolv.conf which may contain the default DNS server to use, and also overrides for individual domains.

public
UnixResolverDnsServerAddressStreamProvider(String etcResolvConf, String
Directory containing files of the format defined in /etc/resolver.
etcResolverDir
)

Parse a file of the format /etc/resolv.conf which may contain the default DNS server to use, and also overrides for individual domains.

Method Summary

Modifier and TypeMethod and Description
private boolean
public DnsServerAddressStream
nameServerAddressStream(String
The hostname for which to lookup the DNS server addressed to use. If this is the final DnsServerAddressStreamProvider to be queried then generally empty string or '.' correspond to the default DnsServerAddressStream.
hostname
)

Implements io.netty.resolver.dns.DnsServerAddressStreamProvider.nameServerAddressStream.

Ask this provider for the name servers to query for hostname.
private static Map<String, DnsServerAddresses>
parse(File... etcResolverFiles)

pack-priv static UnixResolverOptions

Returns:

The options values provided by /etc/resolve.conf.
parseEtcResolverOptions
()

Parse /etc/resolv.conf and return options of interest, namely: timeout, attempts and ndots.

pack-priv static UnixResolverOptions

Returns:

The options values provided by /etc/resolve.conf.
parseEtcResolverOptions
(File
a file of the format /etc/resolv.conf.
etcResolvConf
)

Parse a file of the format /etc/resolv.conf and return options of interest, namely: timeout, attempts and ndots.

pack-priv static List<String>

Returns:

List of search domains.
parseEtcResolverSearchDomains
()

Parse a file of the format /etc/resolv.conf and return the list of search domains found in it or an empty list if not found.

pack-priv static List<String>

Returns:

List of search domains.
parseEtcResolverSearchDomains
(File
a file of the format /etc/resolv.conf.
etcResolvConf
)

Parse a file of the format /etc/resolv.conf and return the list of search domains found in it or an empty list if not found.

private static int
private static void
pack-priv static DnsServerAddressStreamProvider
parseSilently()

Attempt to parse /etc/resolv.conf and files in the /etc/resolver directory by default.

private static void
putIfAbsent(Map<String, DnsServerAddresses> domainToNameServerStreamMap, String domainName, List<InetSocketAddress> addresses, boolean rotate)

private static void
putIfAbsent(Map<String, DnsServerAddresses> domainToNameServerStreamMap, String domainName, DnsServerAddresses addresses)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultNameServerAddressesback to summary
private final DnsServerAddresses defaultNameServerAddresses
DOMAIN_ROW_LABELback to summary
private static final String DOMAIN_ROW_LABEL
domainToNameServerStreamMapback to summary
private final Map<String, DnsServerAddresses> domainToNameServerStreamMap
ETC_RESOLV_CONF_FILEback to summary
private static final String ETC_RESOLV_CONF_FILE
ETC_RESOLVER_DIRback to summary
private static final String ETC_RESOLVER_DIR
loggerback to summary
private static final InternalLogger logger
NAMESERVER_ROW_LABELback to summary
private static final String NAMESERVER_ROW_LABEL
OPTIONS_ROTATE_FLAGback to summary
private static final String OPTIONS_ROTATE_FLAG
OPTIONS_ROW_LABELback to summary
private static final String OPTIONS_ROW_LABEL
PORT_ROW_LABELback to summary
private static final String PORT_ROW_LABEL
RES_OPTIONSback to summary
private static final String RES_OPTIONS
SEARCH_ROW_LABELback to summary
private static final String SEARCH_ROW_LABEL
SORTLIST_ROW_LABELback to summary
private static final String SORTLIST_ROW_LABEL
WHITESPACE_PATTERNback to summary
private static final Pattern WHITESPACE_PATTERN

Constructor Detail

UnixResolverDnsServerAddressStreamProviderback to summary
public UnixResolverDnsServerAddressStreamProvider(File etcResolvConf, File... etcResolverFiles) throws IOException

Parse a file of the format /etc/resolv.conf which may contain the default DNS server to use, and also overrides for individual domains. Also parse list of files of the format /etc/resolver which may contain multiple files to override the name servers used for multiple domains.

Parameters
etcResolvConf:File

/etc/resolv.conf.

etcResolverFiles:File[]

List of files of the format defined in /etc/resolver.

Exceptions
IOException:
If an error occurs while parsing the input files.
UnixResolverDnsServerAddressStreamProviderback to summary
public UnixResolverDnsServerAddressStreamProvider(String etcResolvConf, String etcResolverDir) throws IOException

Parse a file of the format /etc/resolv.conf which may contain the default DNS server to use, and also overrides for individual domains. Also parse a directory of the format /etc/resolver which may contain multiple files to override the name servers used for multiple domains.

Parameters
etcResolvConf:String

/etc/resolv.conf.

etcResolverDir:String

Directory containing files of the format defined in /etc/resolver.

Exceptions
IOException:
If an error occurs while parsing the input files.

Method Detail

mayOverrideNameServersback to summary
private boolean mayOverrideNameServers()
nameServerAddressStreamback to summary
public DnsServerAddressStream nameServerAddressStream(String hostname)

Implements io.netty.resolver.dns.DnsServerAddressStreamProvider.nameServerAddressStream.

Doc from io.netty.resolver.dns.DnsServerAddressStreamProvider.nameServerAddressStream.

Ask this provider for the name servers to query for hostname.

Parameters
hostname:String

The hostname for which to lookup the DNS server addressed to use. If this is the final DnsServerAddressStreamProvider to be queried then generally empty string or '.' correspond to the default DnsServerAddressStream.

Returns:DnsServerAddressStream

The DnsServerAddressStream which should be used to resolve hostname.

Annotations
@Override
parseback to summary
private static Map<String, DnsServerAddresses> parse(File... etcResolverFiles) throws IOException
parseEtcResolverOptionsback to summary
pack-priv static UnixResolverOptions parseEtcResolverOptions() throws IOException

Parse /etc/resolv.conf and return options of interest, namely: timeout, attempts and ndots.

Returns:UnixResolverOptions

The options values provided by /etc/resolve.conf.

Exceptions
IOException:
If a failure occurs parsing the file.
parseEtcResolverOptionsback to summary
pack-priv static UnixResolverOptions parseEtcResolverOptions(File etcResolvConf) throws IOException

Parse a file of the format /etc/resolv.conf and return options of interest, namely: timeout, attempts and ndots.

Parameters
etcResolvConf:File

a file of the format /etc/resolv.conf.

Returns:UnixResolverOptions

The options values provided by /etc/resolve.conf.

Exceptions
IOException:
If a failure occurs parsing the file.
parseEtcResolverSearchDomainsback to summary
pack-priv static List<String> parseEtcResolverSearchDomains() throws IOException

Parse a file of the format /etc/resolv.conf and return the list of search domains found in it or an empty list if not found.

Returns:List<String>

List of search domains.

Exceptions
IOException:
If a failure occurs parsing the file.
parseEtcResolverSearchDomainsback to summary
pack-priv static List<String> parseEtcResolverSearchDomains(File etcResolvConf) throws IOException

Parse a file of the format /etc/resolv.conf and return the list of search domains found in it or an empty list if not found.

Parameters
etcResolvConf:File

a file of the format /etc/resolv.conf.

Returns:List<String>

List of search domains.

Exceptions
IOException:
If a failure occurs parsing the file.
parseResIntOptionback to summary
private static int parseResIntOption(String opt, String fullLabel)
parseResOptionsback to summary
private static void parseResOptions(String line, UnixResolverOptions.Builder builder)
parseSilentlyback to summary
pack-priv static DnsServerAddressStreamProvider parseSilently()

Attempt to parse /etc/resolv.conf and files in the /etc/resolver directory by default. A failure to parse will return DefaultDnsServerAddressStreamProvider.

putIfAbsentback to summary
private static void putIfAbsent(Map<String, DnsServerAddresses> domainToNameServerStreamMap, String domainName, List<InetSocketAddress> addresses, boolean rotate)
putIfAbsentback to summary
private static void putIfAbsent(Map<String, DnsServerAddresses> domainToNameServerStreamMap, String domainName, DnsServerAddresses addresses)