Package org.xbill.DNS

Interface Resolver

All Known Implementing Classes:
DohResolver, ExtendedResolver, SimpleResolver, ValidatingResolver

public interface Resolver
Interface describing a resolver.
Author:
Brian Wellington
  • Method Details

    • setPort

      void setPort(int port)
      Sets the port to communicate with on the server
      Parameters:
      port - The port to send messages to
    • setTCP

      void setTCP(boolean flag)
      Sets whether TCP connections will be used by default
      Parameters:
      flag - Indicates whether TCP connections are made
    • setIgnoreTruncation

      void setIgnoreTruncation(boolean flag)
      Sets whether truncated responses will be ignored. If not, a truncated response over UDP will cause a retransmission over TCP.
      Parameters:
      flag - Indicates whether truncated responses should be ignored.
    • setEDNS

      default void setEDNS(int version)
      Sets the EDNS version used on outgoing messages.
      Parameters:
      version - The EDNS level to use. 0 indicates EDNS0 and -1 indicates no EDNS.
      Throws:
      IllegalArgumentException - An invalid level was indicated.
    • setEDNS

      void setEDNS(int version, int payloadSize, int flags, List<EDNSOption> options)
      Sets the EDNS information on outgoing messages.
      Parameters:
      version - The EDNS version to use. 0 indicates EDNS0 and -1 indicates no EDNS.
      payloadSize - The maximum DNS packet size that this host is capable of receiving over UDP. If 0 is specified, the default (1280) is used.
      flags - EDNS extended flags to be set in the OPT record.
      options - EDNS options to be set in the OPT record, specified as a List of OPTRecord.Option elements.
      Throws:
      IllegalArgumentException - An invalid field was specified.
      See Also:
    • setEDNS

      default void setEDNS(int version, int payloadSize, int flags, EDNSOption... options)
      Sets the EDNS information on outgoing messages.
      Parameters:
      version - The EDNS version to use. 0 indicates EDNS0 and -1 indicates no EDNS.
      payloadSize - The maximum DNS packet size that this host is capable of receiving over UDP. If 0 is specified, the default (1280) is used.
      flags - EDNS extended flags to be set in the OPT record.
      options - EDNS options to be set in the OPT record, specified as a List of OPTRecord.Option elements.
      Throws:
      IllegalArgumentException - An invalid field was specified.
      See Also:
    • setTSIGKey

      void setTSIGKey(TSIG key)
      Specifies the TSIG key that messages will be signed with
      Parameters:
      key - The key
    • setTimeout

      @Deprecated default void setTimeout(int secs, int msecs)
      Deprecated.
      Sets the amount of time to wait for a response before giving up.
      Parameters:
      secs - The number of seconds to wait.
      msecs - The number of milliseconds to wait.
    • setTimeout

      @Deprecated default void setTimeout(int secs)
      Deprecated.
      Sets the amount of time to wait for a response before giving up.
      Parameters:
      secs - The number of seconds to wait.
    • setTimeout

      void setTimeout(Duration timeout)
      Sets the amount of time to wait for a response before giving up.
      Parameters:
      timeout - The amount of time to wait.
    • getTimeout

      default Duration getTimeout()
      Gets the amount of time to wait for a response before giving up.
      See Also:
    • send

      default Message send(Message query) throws IOException
      Sends a message and waits for a response.

      The waiting is done on the calling thread. Do not call this method from async code, and especially not from tasks running on ForkJoinPool.commonPool(), use sendAsync(Message) or sendAsync(Message, Executor) instead.

      Parameters:
      query - The query to send.
      Returns:
      The response
      Throws:
      IOException - An error occurred while sending or receiving.
    • sendAsync

      default CompletionStage<Message> sendAsync(Message query)
      Asynchronously sends a message using the default ForkJoinPool.commonPool().

      The default implementation calls the deprecated sendAsync(Message, ResolverListener). Implementors must override at least one of the sendAsync methods or a stack overflow will occur.

      Parameters:
      query - The query to send.
      Returns:
      A future that completes when the query is finished.
    • sendAsync

      default CompletionStage<Message> sendAsync(Message query, Executor executor)
      Asynchronously sends a message.

      The default implementation calls the deprecated sendAsync(Message, ResolverListener). Implementors must override at least one of the sendAsync methods or a stack overflow will occur.

      Parameters:
      query - The query to send.
      executor - The service to use for async operations.
      Returns:
      A future that completes when the query is finished.
    • sendAsync

      @Deprecated default Object sendAsync(Message query, ResolverListener listener)
      Deprecated.
      Asynchronously sends a message registering a listener to receive a callback on success or exception. Multiple asynchronous lookups can be performed in parallel. The callback may be invoked from any thread.

      The default implementation calls sendAsync(Message). Implementors must override at least one of the sendAsync methods or a stack overflow will occur.

      Parameters:
      query - The query to send
      listener - The object containing the callbacks.
      Returns:
      An identifier, which is also a parameter in the callback