Package org.xbill.DNS

Class DohResolverCommon

java.lang.Object
org.xbill.DNS.DohResolverCommon
All Implemented Interfaces:
Resolver
Direct Known Subclasses:
DohResolver

abstract class DohResolverCommon extends Object implements Resolver
  • Field Details

    • maxConcurrentRequests

      protected final AsyncSemaphore maxConcurrentRequests
      Maximum concurrent HTTP/2 streams or HTTP/1.1 connections.

      rfc7540#section-6.5.2 recommends a minimum of 100 streams for HTTP/2.

    • lastRequest

      protected final AtomicLong lastRequest
    • APPLICATION_DNS_MESSAGE

      protected static final String APPLICATION_DNS_MESSAGE
      See Also:
    • usePost

      protected boolean usePost
    • timeout

      protected Duration timeout
    • uriTemplate

      protected String uriTemplate
    • queryOPT

      protected OPTRecord queryOPT
    • tsig

      protected TSIG tsig
    • defaultExecutor

      protected Executor defaultExecutor
  • Constructor Details

    • DohResolverCommon

      protected DohResolverCommon(String uriTemplate, int maxConcurrentRequests)
      Creates a new DoH resolver that performs lookups with HTTP GET and the default timeout (5s).
      Parameters:
      uriTemplate - the URI to use for resolving, e.g. https://dns.google/dns-query
      maxConcurrentRequests - Maximum concurrent HTTP/2 streams for Java 11+ or HTTP/1.1 connections for Java 8. On Java 8 this cannot exceed the system property http.maxConnections.
  • Method Details

    • getNanoTime

      long getNanoTime()
    • setPort

      public void setPort(int port)
      Not implemented. Specify the port in setUriTemplate(String) if required.
      Specified by:
      setPort in interface Resolver
      Parameters:
      port - The port to send messages to
    • setTCP

      public void setTCP(boolean flag)
      Not implemented.
      Specified by:
      setTCP in interface Resolver
      Parameters:
      flag - Indicates whether TCP connections are made
    • setIgnoreTruncation

      public void setIgnoreTruncation(boolean flag)
      Not implemented.
      Specified by:
      setIgnoreTruncation in interface Resolver
      Parameters:
      flag - Indicates whether truncated responses should be ignored.
    • setEDNS

      public void setEDNS(int version, int payloadSize, int flags, List<EDNSOption> options)
      Sets the EDNS information on outgoing messages.
      Specified by:
      setEDNS in interface Resolver
      Parameters:
      version - The EDNS version to use. 0 indicates EDNS0 and -1 indicates no EDNS.
      payloadSize - ignored
      flags - EDNS extended flags to be set in the OPT record.
      options - EDNS options to be set in the OPT record
      See Also:
    • setTSIGKey

      public void setTSIGKey(TSIG key)
      Description copied from interface: Resolver
      Specifies the TSIG key that messages will be signed with
      Specified by:
      setTSIGKey in interface Resolver
      Parameters:
      key - The key
    • setTimeout

      public void setTimeout(Duration timeout)
      Description copied from interface: Resolver
      Sets the amount of time to wait for a response before giving up.
      Specified by:
      setTimeout in interface Resolver
      Parameters:
      timeout - The amount of time to wait.
    • getTimeout

      public Duration getTimeout()
      Description copied from interface: Resolver
      Gets the amount of time to wait for a response before giving up.
      Specified by:
      getTimeout in interface Resolver
      See Also:
    • getUrl

      protected String getUrl(byte[] queryBytes)
    • prepareQuery

      protected Message prepareQuery(Message query)
    • verifyTSIG

      protected void verifyTSIG(Message query, Message response, byte[] b, TSIG tsig)
    • isUsePost

      public boolean isUsePost()
      Returns true if the HTTP method POST to resolve, false if GET is used.
    • setUsePost

      public void setUsePost(boolean usePost)
      Sets the HTTP method to use for resolving.
      Parameters:
      usePost - true to use POST, false to use GET (the default).
    • getUriTemplate

      public String getUriTemplate()
      Gets the current URI used for resolving.
    • setUriTemplate

      public void setUriTemplate(String uriTemplate)
      Sets the URI to use for resolving, e.g. https://dns.google/dns-query
    • getExecutor

      @Deprecated public Executor getExecutor()
      Deprecated.
      not applicable if Resolver.sendAsync(Message, Executor) is used.
      Gets the default Executor for request handling, defaults to ForkJoinPool.commonPool().
      Since:
      3.3
    • setExecutor

      @Deprecated public void setExecutor(Executor executor)
      Sets the default Executor for request handling.
      Parameters:
      executor - The new Executor, can be null (which is equivalent to ForkJoinPool.commonPool()).
      Since:
      3.3
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • failedFuture

      protected abstract <T> CompletableFuture<T> failedFuture(Throwable e)
    • timeoutFailedFuture

      protected final <T> CompletableFuture<T> timeoutFailedFuture(Message query, Throwable inner)
    • timeoutFailedFuture

      protected final <T> CompletableFuture<T> timeoutFailedFuture(Message query, String message, Throwable inner)