Package tigase.util.dns

## Class DNSResolverDefault

- java.lang.Object
- - tigase.util.dns.DNSResolverDefault

- All Implemented Interfaces:
    `DNSResolverIfc`

      public class DNSResolverDefault
      extends java.lang.Object
      implements DNSResolverIfc

  DNSResolver class for handling DNS names

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.util.Map<java.lang.String,​DNSEntry>` | `ip_cache` |
    `static java.util.Map<java.lang.String,​DNSEntry[]>` | `srv_cache` |

    - ### Fields inherited from interface tigase.util.dns.DNSResolverIfc

      `rand, TIGASE_PRIMARY_ADDRESS, TIGASE_SECONDARY_ADDRESS`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `DNSResolverDefault()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.String` | `getDefaultHost()` | Method provides default host information for the installation.
    `java.lang.String[]` | `getDefaultHosts()` | Method provides an array of all local host informations, by default it contains defaultHost.
    `java.lang.String[]` | `getHostIPs​(java.lang.String hostname)` | Resolve all IP addresses for the given `hostname`
    `DNSEntry[]` | `getHostSRV_Entries​(java.lang.String hostname, java.lang.String service, int defPort)` | Retrieves list of DNS entries for given `hostname`.
    `java.lang.String` | `getPrimaryHost()` |
    `java.lang.String` | `getSecondaryHost()` | Method provides alternative host information for the current instance.
    `protected static boolean` | `isHostValid​(java.lang.String host)` |
    `static void` | `main​(java.lang.String[] args)` | `main` method outputting various information about hostnames
    `void` | `setPrimaryHost​(java.lang.String tigasePrimaryHost)` |
    `void` | `setSecondaryHost​(java.lang.String tigaseSecondaryHost)` |

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

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

    - ### Methods inherited from interface tigase.util.dns.DNSResolverIfc

      `getHostIP, getHostSRV_Entries, getHostSRV_Entry, getHostSRV_Entry, getHostSRV_IP`

- - ### Field Detail

    - #### ip_cache

          public static java.util.Map<java.lang.String,​DNSEntry> ip_cache

    - #### srv_cache

          public static java.util.Map<java.lang.String,​DNSEntry[]> srv_cache

  - ### Constructor Detail

    - #### DNSResolverDefault

          protected DNSResolverDefault()

  - ### Method Detail

    - #### isHostValid

          protected static boolean isHostValid​(java.lang.String host)

    - #### main

          public static void main​(java.lang.String[] args)
                           throws java.lang.Exception

      `main` method outputting various information about hostnames
      Parameters:
        `args` - a `String[]` containing domains to query, if none provided default one will be used
      Throws:
        `java.lang.Exception`

    - #### getDefaultHosts

          public java.lang.String[] getDefaultHosts()

      Description copied from interface: `DNSResolverIfc`
      Method provides an array of all local host informations, by default it contains defaultHost.
      Specified by:
        `getDefaultHosts` in interface `DNSResolverIfc`
      Returns:
        an array of all local hosts.

    - #### getDefaultHost

          public java.lang.String getDefaultHost()

      Description copied from interface: `DNSResolverIfc`
      Method provides default host information for the installation. It can be both hostname or IP address.
      Specified by:
        `getDefaultHost` in interface `DNSResolverIfc`
      Returns:
        a default host information.

    - #### getPrimaryHost

          public java.lang.String getPrimaryHost()

    - #### setPrimaryHost

          public void setPrimaryHost​(java.lang.String tigasePrimaryHost)

    - #### getSecondaryHost

          public java.lang.String getSecondaryHost()

      Description copied from interface: `DNSResolverIfc`
      Method provides alternative host information for the current instance. By default falls back to the default host information.
      Specified by:
        `getSecondaryHost` in interface `DNSResolverIfc`
      Returns:
        alternative host information.

    - #### setSecondaryHost

          public void setSecondaryHost​(java.lang.String tigaseSecondaryHost)

    - #### getHostIPs

          public java.lang.String[] getHostIPs​(java.lang.String hostname)
                                        throws java.net.UnknownHostException

      Resolve all IP addresses for the given `hostname`
      Specified by:
        `getHostIPs` in interface `DNSResolverIfc`
      Parameters:
        `hostname` - the domain name for which this record is valid
      Returns:
        Array of all `IP addresses` on which target host provide service.
      Throws:
        `java.net.UnknownHostException`

    - #### getHostSRV_Entries

          public DNSEntry[] getHostSRV_Entries​(java.lang.String hostname,
                                               java.lang.String service,
                                               int defPort)
                                        throws java.net.UnknownHostException

      Description copied from interface: `DNSResolverIfc`
      Retrieves list of DNS entries for given `hostname`. Allow specifying particular type of SRV record.
      Specified by:
        `getHostSRV_Entries` in interface `DNSResolverIfc`
      Parameters:
        `hostname` - the domain name for which this record is valid
        `service` - type of SRV records, for example `_xmpp-server._tcp`
        `defPort` - default port number in case DNS records is missing one.
      Returns:
        Array of the DNSEntry records
      Throws:
        `java.net.UnknownHostException`