Class DnsNameResolverBuilder

    • Constructor Detail

      • DnsNameResolverBuilder

        public DnsNameResolverBuilder()
        Creates a new builder.
      • DnsNameResolverBuilder

        public DnsNameResolverBuilder​(io.netty5.channel.EventLoop eventLoop)
        Creates a new builder.
        Parameters:
        eventLoop - the EventLoop which will perform the communication with the DNS servers.
    • Method Detail

      • eventLoop

        public DnsNameResolverBuilder eventLoop​(io.netty5.channel.EventLoop eventLoop)
        Sets the EventLoop which will perform the communication with the DNS servers.
        Parameters:
        eventLoop - the EventLoop
        Returns:
        this
      • channelFactory

        protected io.netty5.channel.ChannelFactory<? extends io.netty5.channel.socket.DatagramChannel> channelFactory()
      • channelFactory

        public DnsNameResolverBuilder channelFactory​(io.netty5.channel.ChannelFactory<? extends io.netty5.channel.socket.DatagramChannel> channelFactory)
        Sets the ChannelFactory that will create a DatagramChannel.
        Parameters:
        channelFactory - the ChannelFactory
        Returns:
        this
      • channelType

        public DnsNameResolverBuilder channelType​(Class<? extends io.netty5.channel.socket.DatagramChannel> channelType)
        Sets the ChannelFactory as a ReflectiveChannelFactory of this type. Use as an alternative to channelFactory(ChannelFactory).
        Parameters:
        channelType - the type
        Returns:
        this
      • socketChannelFactory

        public DnsNameResolverBuilder socketChannelFactory​(io.netty5.channel.ChannelFactory<? extends io.netty5.channel.socket.SocketChannel> channelFactory)
        Sets the ChannelFactory that will create a SocketChannel for TCP fallback if needed.
        Parameters:
        channelFactory - the ChannelFactory or null if TCP fallback should not be supported.
        Returns:
        this
      • resolveCache

        public DnsNameResolverBuilder resolveCache​(DnsCache resolveCache)
        Sets the cache for resolution results.
        Parameters:
        resolveCache - the DNS resolution results cache
        Returns:
        this
      • cnameCache

        public DnsNameResolverBuilder cnameCache​(DnsCnameCache cnameCache)
        Sets the cache for CNAME mappings.
        Parameters:
        cnameCache - the cache used to cache CNAME mappings for a domain.
        Returns:
        this
      • dnsQueryLifecycleObserverFactory

        public DnsNameResolverBuilder dnsQueryLifecycleObserverFactory​(DnsQueryLifecycleObserverFactory lifecycleObserverFactory)
        Set the factory used to generate objects which can observe individual DNS queries.
        Parameters:
        lifecycleObserverFactory - the factory used to generate objects which can observe individual DNS queries.
        Returns:
        this
      • authoritativeDnsServerCache

        public DnsNameResolverBuilder authoritativeDnsServerCache​(AuthoritativeDnsServerCache authoritativeDnsServerCache)
        Sets the cache for authoritative NS servers
        Parameters:
        authoritativeDnsServerCache - the authoritative NS servers cache
        Returns:
        this
      • localAddress

        public DnsNameResolverBuilder localAddress​(SocketAddress localAddress)
        Configure the address that will be used to bind too. If null the default will be used.
        Parameters:
        localAddress - the bind address
        Returns:
        this
      • ttl

        public DnsNameResolverBuilder ttl​(int minTtl,
                                          int maxTtl)
        Sets the minimum and maximum TTL of the cached DNS resource records (in seconds). If the TTL of the DNS resource record returned by the DNS server is less than the minimum TTL or greater than the maximum TTL, this resolver will ignore the TTL from the DNS server and use the minimum TTL or the maximum TTL instead respectively. The default value is 0 and Integer.MAX_VALUE, which practically tells this resolver to respect the TTL from the DNS server.
        Parameters:
        minTtl - the minimum TTL
        maxTtl - the maximum TTL
        Returns:
        this
      • negativeTtl

        public DnsNameResolverBuilder negativeTtl​(int negativeTtl)
        Sets the TTL of the cache for the failed DNS queries (in seconds).
        Parameters:
        negativeTtl - the TTL for failed cached queries
        Returns:
        this
      • queryTimeoutMillis

        public DnsNameResolverBuilder queryTimeoutMillis​(long queryTimeoutMillis)
        Sets the timeout of each DNS query performed by this resolver (in milliseconds).
        Parameters:
        queryTimeoutMillis - the query timeout
        Returns:
        this
      • computeResolvedAddressTypes

        public static io.netty5.resolver.ResolvedAddressTypes computeResolvedAddressTypes​(io.netty5.channel.socket.InternetProtocolFamily... internetProtocolFamilies)
        Compute a ResolvedAddressTypes from some InternetProtocolFamilys. An empty input will return the default value, based on "java.net" System properties. Valid inputs are (), (IPv4), (IPv6), (Ipv4, IPv6) and (IPv6, IPv4).
        Parameters:
        internetProtocolFamilies - a valid sequence of InternetProtocolFamilys
        Returns:
        a ResolvedAddressTypes
      • resolvedAddressTypes

        public DnsNameResolverBuilder resolvedAddressTypes​(io.netty5.resolver.ResolvedAddressTypes resolvedAddressTypes)
        Sets the list of the protocol families of the address resolved. You can use computeResolvedAddressTypes(InternetProtocolFamily...) to get a ResolvedAddressTypes out of some InternetProtocolFamilys.
        Parameters:
        resolvedAddressTypes - the address types
        Returns:
        this
      • completeOncePreferredResolved

        public DnsNameResolverBuilder completeOncePreferredResolved​(boolean completeOncePreferredResolved)
        If true SimpleNameResolver.resolveAll(String) will notify the returned Future as soon as all queries for the preferred address-type are complete.
        Parameters:
        completeOncePreferredResolved - true to enable, false to disable.
        Returns:
        this
      • recursionDesired

        public DnsNameResolverBuilder recursionDesired​(boolean recursionDesired)
        Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.
        Parameters:
        recursionDesired - true if recursion is desired
        Returns:
        this
      • maxQueriesPerResolve

        public DnsNameResolverBuilder maxQueriesPerResolve​(int maxQueriesPerResolve)
        Sets the maximum allowed number of DNS queries to send when resolving a host name.
        Parameters:
        maxQueriesPerResolve - the max number of queries
        Returns:
        this
      • maxPayloadSize

        public DnsNameResolverBuilder maxPayloadSize​(int maxPayloadSize)
        Sets the capacity of the datagram packet buffer (in bytes). The default value is 4096 bytes.
        Parameters:
        maxPayloadSize - the capacity of the datagram packet buffer
        Returns:
        this
      • optResourceEnabled

        public DnsNameResolverBuilder optResourceEnabled​(boolean optResourceEnabled)
        Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response. Some DNSServer may not support this and so fail to answer queries. If you find problems you may want to disable this.
        Parameters:
        optResourceEnabled - if optional records inclusion is enabled
        Returns:
        this
      • hostsFileEntriesResolver

        public DnsNameResolverBuilder hostsFileEntriesResolver​(io.netty5.resolver.HostsFileEntriesResolver hostsFileEntriesResolver)
        Parameters:
        hostsFileEntriesResolver - the HostsFileEntriesResolver used to first check if the hostname is locally aliased.
        Returns:
        this
      • searchDomains

        public DnsNameResolverBuilder searchDomains​(Iterable<String> searchDomains)
        Set the list of search domains of the resolver.
        Parameters:
        searchDomains - the search domains
        Returns:
        this
      • ndots

        public DnsNameResolverBuilder ndots​(int ndots)
        Set the number of dots which must appear in a name before an initial absolute query is made. The default value is 1.
        Parameters:
        ndots - the ndots value
        Returns:
        this
      • decodeIdn

        public DnsNameResolverBuilder decodeIdn​(boolean decodeIdn)
        Set if domain / host names should be decoded to unicode when received. See rfc3492.
        Parameters:
        decodeIdn - if should get decoded
        Returns:
        this