Class UnixResolverDnsServerAddressStreamProvider

    • Field Detail

      • WHITESPACE_PATTERN

        private static final java.util.regex.Pattern WHITESPACE_PATTERN
      • RES_OPTIONS

        private static final java.lang.String RES_OPTIONS
      • ETC_RESOLV_CONF_FILE

        private static final java.lang.String ETC_RESOLV_CONF_FILE
        See Also:
        Constant Field Values
      • ETC_RESOLVER_DIR

        private static final java.lang.String ETC_RESOLVER_DIR
        See Also:
        Constant Field Values
      • NAMESERVER_ROW_LABEL

        private static final java.lang.String NAMESERVER_ROW_LABEL
        See Also:
        Constant Field Values
      • SORTLIST_ROW_LABEL

        private static final java.lang.String SORTLIST_ROW_LABEL
        See Also:
        Constant Field Values
      • OPTIONS_ROW_LABEL

        private static final java.lang.String OPTIONS_ROW_LABEL
        See Also:
        Constant Field Values
      • OPTIONS_ROTATE_FLAG

        private static final java.lang.String OPTIONS_ROTATE_FLAG
        See Also:
        Constant Field Values
      • DOMAIN_ROW_LABEL

        private static final java.lang.String DOMAIN_ROW_LABEL
        See Also:
        Constant Field Values
      • SEARCH_ROW_LABEL

        private static final java.lang.String SEARCH_ROW_LABEL
        See Also:
        Constant Field Values
      • domainToNameServerStreamMap

        private final java.util.Map<java.lang.String,​DnsServerAddresses> domainToNameServerStreamMap
    • Constructor Detail

      • UnixResolverDnsServerAddressStreamProvider

        public UnixResolverDnsServerAddressStreamProvider​(java.io.File etcResolvConf,
                                                          java.io.File... etcResolverFiles)
                                                   throws java.io.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 multimple domains.
        Parameters:
        etcResolvConf - /etc/resolv.conf.
        etcResolverFiles - List of files of the format defined in /etc/resolver.
        Throws:
        java.io.IOException - If an error occurs while parsing the input files.
      • UnixResolverDnsServerAddressStreamProvider

        public UnixResolverDnsServerAddressStreamProvider​(java.lang.String etcResolvConf,
                                                          java.lang.String etcResolverDir)
                                                   throws java.io.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 multimple domains.
        Parameters:
        etcResolvConf - /etc/resolv.conf.
        etcResolverDir - Directory containing files of the format defined in /etc/resolver.
        Throws:
        java.io.IOException - If an error occurs while parsing the input files.
    • Method Detail

      • mayOverrideNameServers

        private boolean mayOverrideNameServers()
      • parse

        private static java.util.Map<java.lang.String,​DnsServerAddresses> parse​(java.io.File... etcResolverFiles)
                                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • putIfAbsent

        private static void putIfAbsent​(java.util.Map<java.lang.String,​DnsServerAddresses> domainToNameServerStreamMap,
                                        java.lang.String domainName,
                                        java.util.List<java.net.InetSocketAddress> addresses,
                                        boolean rotate)
      • putIfAbsent

        private static void putIfAbsent​(java.util.Map<java.lang.String,​DnsServerAddresses> domainToNameServerStreamMap,
                                        java.lang.String domainName,
                                        DnsServerAddresses addresses)
      • parseEtcResolverOptions

        static UnixResolverOptions parseEtcResolverOptions()
                                                    throws java.io.IOException
        Parse /etc/resolv.conf and return options of interest, namely: timeout, attempts and ndots.
        Returns:
        The options values provided by /etc/resolve.conf.
        Throws:
        java.io.IOException - If a failure occurs parsing the file.
      • parseEtcResolverOptions

        static UnixResolverOptions parseEtcResolverOptions​(java.io.File etcResolvConf)
                                                    throws java.io.IOException
        Parse a file of the format /etc/resolv.conf and return options of interest, namely: timeout, attempts and ndots.
        Parameters:
        etcResolvConf - a file of the format /etc/resolv.conf.
        Returns:
        The options values provided by /etc/resolve.conf.
        Throws:
        java.io.IOException - If a failure occurs parsing the file.
      • parseResIntOption

        private static int parseResIntOption​(java.lang.String opt,
                                             java.lang.String fullLabel)
      • parseEtcResolverSearchDomains

        static java.util.List<java.lang.String> parseEtcResolverSearchDomains()
                                                                       throws java.io.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 of search domains.
        Throws:
        java.io.IOException - If a failure occurs parsing the file.
      • parseEtcResolverSearchDomains

        static java.util.List<java.lang.String> parseEtcResolverSearchDomains​(java.io.File etcResolvConf)
                                                                       throws java.io.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 - a file of the format /etc/resolv.conf.
        Returns:
        List of search domains.
        Throws:
        java.io.IOException - If a failure occurs parsing the file.