com.jscape.inet.dns

## Class Dns

- java.lang.Object
- - com.jscape.inet.dns.Dns

-     public final class Dns
      extends java.lang.Object

  Implements the basic functionality of a DNS client.

  Example Usage:

       // create new instance
       Dns dns = new Dns();
        // creates DNS request with nameserver and domain as arguments
       DnsRequest request = new DnsRequest("ns.myserver.com","myserver.com");
       // retrieve only MX (mail exchanger) records
       request.setRecordType(Dns.TYPE_MX);
        // gets DNS response
       DnsResponse response = dns.getResponse(request);
        // print out records for response to console
        Enumeration e = response.getAnswers();
       while(e.hasMoreElements()) {
         DnsRecord record = (DnsRecord) e.nextElement();
         System.out.println(record);
       }

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CLASS_ANY` Indicates any Domain Records.
    `static int` | `CLASS_CH` Indicates CHAOS domain records.
    `static int` | `CLASS_CS` Indicates CSNET domain records.
    `static int` | `CLASS_HS` Indicates HESIOD domain records.
    `static int` | `CLASS_IN` Indicates Internet domain records.
    `static int` | `DEFAULT_PORT` Default Dns port.
    `static int` | `OPCODE_IQUERY` Indicates an Internet Query operation.
    `static int` | `OPCODE_QUERY` Indicates a Query operation.
    `static int` | `OPCODE_STATUS` Indicates a Status Query operation.
    `static int` | `SHIFT_AUTHORITATIVE` Indicates that response is an authoritative answer.
    `static int` | `SHIFT_OPCODE`
    `static int` | `SHIFT_QUERY`
    `static int` | `SHIFT_RECURSE_AVAILABLE` Indicates that recursion is available.
    `static int` | `SHIFT_RECURSE_PLEASE` Indicates that recursion is requested.
    `static int` | `SHIFT_RESERVED`
    `static int` | `SHIFT_RESPONSE_CODE` Indicates that no error occured in query.
    `static int` | `SHIFT_TRUNCATED` Indicates that response is truncated.
    `static int` | `TYPE_A` Indicates a host address record.
    `static int` | `TYPE_ANY` Indicates Any record.
    `static int` | `TYPE_AXFR` Indicates a request for zone transfer record.
    `static int` | `TYPE_CNAME` Indicates a canonical name for an alias record.
    `static int` | `TYPE_HINFO` Indicates a host information record.
    `static int` | `TYPE_IXFR` Indicates a request for incremental zone transfer record.
    `static int` | `TYPE_MAILA` Indicates a request for mail agent record.
    `static int` | `TYPE_MAILB` Indicates a request for mailbox-related records record.
    `static int` | `TYPE_MB` Indicates a mailbox domain record.
    `static int` | `TYPE_MD` Indicates a mail destination record.
    `static int` | `TYPE_MF` Indicates a mail forwarder record.
    `static int` | `TYPE_MG` Indicates a mail group member record.
    `static int` | `TYPE_MINFO` Indicates a mailbox or list information record.
    `static int` | `TYPE_MR` Indicates a mail rename domain name record.
    `static int` | `TYPE_MX` Indicates a mail exchange record.
    `static int` | `TYPE_NS` Indicates an authoritative name server record.
    `static int` | `TYPE_NULL` Indicates a null record.
    `static int` | `TYPE_PTR` Indicates a domain name pointer record.
    `static int` | `TYPE_SOA` Indicates a start of authority record.
    `static int` | `TYPE_TXT` Indicates a text record.
    `static int` | `TYPE_WKS` Indicates a well known service description record.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Dns()` Constructs a new `Dns` instance.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearProxySettings()` Clears proxy server values.
    `DnsResponse` | `getResponse(DnsRequest request)` Gets response from a DNS server based on arguments defined in `request`.
    `DnsResponse` | `getResponse(DnsRequest request, boolean ignoreLength)` Gets response from a DNS server based on arguments defined in `request`.
    `void` | `setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)` Sets the username and password to use when for authentication with proxy server.
    `void` | `setProxyHost(java.lang.String proxyHostname, int proxyPort)` Sets the proxy hostname and port for this connection.
    `void` | `setProxyType(java.lang.String proxyType)` Sets the proxy type will be used for this connection.
    `static java.lang.Class` | `typeName(int type)` Gets descriptive name for a given Dns record `type`.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_PORT

          public static final int DEFAULT_PORT

      Default Dns port.
      See Also:
        Constant Field Values

    - #### TYPE_A

          public static final int TYPE_A

      Indicates a host address record.
      See Also:
        Constant Field Values

    - #### TYPE_NS

          public static final int TYPE_NS

      Indicates an authoritative name server record.
      See Also:
        Constant Field Values

    - #### TYPE_MD

          public static final int TYPE_MD

      Indicates a mail destination record. Obsolete use mail exchange record `Dns.TYPE_MX`.
      See Also:
        Constant Field Values

    - #### TYPE_MF

          public static final int TYPE_MF

      Indicates a mail forwarder record. Obsolete use mail exchange record `Dns.TYPE_MX`.
      See Also:
        Constant Field Values

    - #### TYPE_CNAME

          public static final int TYPE_CNAME

      Indicates a canonical name for an alias record.
      See Also:
        Constant Field Values

    - #### TYPE_SOA

          public static final int TYPE_SOA

      Indicates a start of authority record.
      See Also:
        Constant Field Values

    - #### TYPE_MB

          public static final int TYPE_MB

      Indicates a mailbox domain record. Experimental per RFC 1035.
      See Also:
        Constant Field Values

    - #### TYPE_MG

          public static final int TYPE_MG

      Indicates a mail group member record. Experimental per RFC 1035.
      See Also:
        Constant Field Values

    - #### TYPE_MR

          public static final int TYPE_MR

      Indicates a mail rename domain name record. Experimental per RFC 1035.
      See Also:
        Constant Field Values

    - #### TYPE_NULL

          public static final int TYPE_NULL

      Indicates a null record. Experimental per RFC 1035.
      See Also:
        Constant Field Values

    - #### TYPE_WKS

          public static final int TYPE_WKS

      Indicates a well known service description record.
      See Also:
        Constant Field Values

    - #### TYPE_PTR

          public static final int TYPE_PTR

      Indicates a domain name pointer record.
      See Also:
        Constant Field Values

    - #### TYPE_HINFO

          public static final int TYPE_HINFO

      Indicates a host information record.
      See Also:
        Constant Field Values

    - #### TYPE_MINFO

          public static final int TYPE_MINFO

      Indicates a mailbox or list information record.
      See Also:
        Constant Field Values

    - #### TYPE_MX

          public static final int TYPE_MX

      Indicates a mail exchange record.
      See Also:
        Constant Field Values

    - #### TYPE_TXT

          public static final int TYPE_TXT

      Indicates a text record.
      See Also:
        Constant Field Values

    - #### TYPE_IXFR

          public static final int TYPE_IXFR

      Indicates a request for incremental zone transfer record.
      See Also:
        Constant Field Values

    - #### TYPE_AXFR

          public static final int TYPE_AXFR

      Indicates a request for zone transfer record.
      See Also:
        Constant Field Values

    - #### TYPE_MAILB

          public static final int TYPE_MAILB

      Indicates a request for mailbox-related records record.
      See Also:
        Constant Field Values

    - #### TYPE_MAILA

          public static final int TYPE_MAILA

      Indicates a request for mail agent record. Obsolete use mail exchange record `Dns.TYPE_MX`.
      See Also:
        Constant Field Values

    - #### TYPE_ANY

          public static final int TYPE_ANY

      Indicates Any record.
      See Also:
        Constant Field Values

    - #### CLASS_IN

          public static final int CLASS_IN

      Indicates Internet domain records.
      See Also:
        Constant Field Values

    - #### CLASS_CS

          public static final int CLASS_CS

      Indicates CSNET domain records. Obsolete - used only for examples in some obsolete RFCs.
      See Also:
        Constant Field Values

    - #### CLASS_CH

          public static final int CLASS_CH

      Indicates CHAOS domain records.
      See Also:
        Constant Field Values

    - #### CLASS_HS

          public static final int CLASS_HS

      Indicates HESIOD domain records.
      See Also:
        Constant Field Values

    - #### CLASS_ANY

          public static final int CLASS_ANY

      Indicates any Domain Records.
      See Also:
        Constant Field Values

    - #### SHIFT_QUERY

          public static final int SHIFT_QUERY

      See Also:
        Constant Field Values

    - #### SHIFT_OPCODE

          public static final int SHIFT_OPCODE

      See Also:
        Constant Field Values

    - #### SHIFT_AUTHORITATIVE

          public static final int SHIFT_AUTHORITATIVE

      Indicates that response is an authoritative answer.
      See Also:
        Constant Field Values

    - #### SHIFT_TRUNCATED

          public static final int SHIFT_TRUNCATED

      Indicates that response is truncated.
      See Also:
        Constant Field Values

    - #### SHIFT_RECURSE_PLEASE

          public static final int SHIFT_RECURSE_PLEASE

      Indicates that recursion is requested. Recursion is requested if the query should be forwarded to another nameserver.
      See Also:
        Constant Field Values

    - #### SHIFT_RECURSE_AVAILABLE

          public static final int SHIFT_RECURSE_AVAILABLE

      Indicates that recursion is available.
      See Also:
        Constant Field Values

    - #### SHIFT_RESERVED

          public static final int SHIFT_RESERVED

      See Also:
        Constant Field Values

    - #### SHIFT_RESPONSE_CODE

          public static final int SHIFT_RESPONSE_CODE

      Indicates that no error occured in query.
      See Also:
        Constant Field Values

    - #### OPCODE_QUERY

          public static final int OPCODE_QUERY

      Indicates a Query operation.
      See Also:
        Constant Field Values

    - #### OPCODE_IQUERY

          public static final int OPCODE_IQUERY

      Indicates an Internet Query operation.
      See Also:
        Constant Field Values

    - #### OPCODE_STATUS

          public static final int OPCODE_STATUS

      Indicates a Status Query operation.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Dns

          public Dns()

      Constructs a new `Dns` instance.

  - ### Method Detail

    - #### typeName

          public static java.lang.Class typeName(int type)

      Gets descriptive name for a given Dns record `type`.
      Parameters:
        `type` - a DNS record type
      Returns:
        a `DnsRecord`
      See Also:
        `DnsRecord`

    - #### setProxyAuthentication

          public void setProxyAuthentication(java.lang.String proxyUsername,
                                             java.lang.String proxyPassword)

      Sets the username and password to use when for authentication with proxy server. To clear these settings invoke the `#clearProxySettings` method.
      Parameters:
        `proxyUsername` - the proxy username
        `proxyPassword` - the proxy password
      See Also:
        `clearProxySettings()`

    - #### setProxyHost

          public void setProxyHost(java.lang.String proxyHostname,
                                   int proxyPort)

      Sets the proxy hostname and port for this connection. To clear these settings invoke the `#clearProxySettings` method.
      Parameters:
        `proxyHostname` - the hostname or ip address of the proxy server
        `proxyPort` - the port of the proxy server
      See Also:
        `clearProxySettings()`

    - #### setProxyType

          public void setProxyType(java.lang.String proxyType)

      Sets the proxy type will be used for this connection.
      Parameters:
        `proxyType` - The proxy type. Valid values: HTTP, SOCKS5

    - #### clearProxySettings

          public void clearProxySettings()

      Clears proxy server values.

    - #### getResponse

          public DnsResponse getResponse(DnsRequest request,
                                         boolean ignoreLength)
                                  throws DnsException

      Gets response from a DNS server based on arguments defined in `request`.
      Parameters:
        `request` - a `DnsRequest`
        `ignoreLength` - `true` if length field of DnsResponse should be ignored and read until EOF, `false` otherwise, for performance reasons this parameter should be set to true only when returning very large DNS responses.
      Returns:
        a `DnsResponse`
      Throws:
        `DnsException` - if an I/O or DNS related error occurs
      See Also:
        `DnsResponse`, `DnsRequest`

    - #### getResponse

          public DnsResponse getResponse(DnsRequest request)
                                  throws DnsException

      Gets response from a DNS server based on arguments defined in `request`.
      Parameters:
        `request` - a `DnsRequest`
      Returns:
        a `DnsResponse`
      Throws:
        `DnsException` - if an I/O or DNS related error occurs
      See Also:
        `DnsResponse`, `DnsRequest`

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved