Smack

org.jivesoftware.smack.util
Class DNSUtil

java.lang.Object
  extended by org.jivesoftware.smack.util.DNSUtil

public class DNSUtil
extends java.lang.Object

Utility class to perform DNS lookups for XMPP services.

Author:
Matt Tucker

Constructor Summary
DNSUtil()
           
 
Method Summary
static DNSResolver getDNSResolver()
          Returns the current DNS resolved used to perform DNS lookups.
static java.util.List<HostAddress> resolveXMPPDomain(java.lang.String domain)
          Returns a list of HostAddresses under which the specified XMPP server can be reached at for client-to-server communication.
static java.util.List<HostAddress> resolveXMPPServerDomain(java.lang.String domain)
          Returns a list of HostAddresses under which the specified XMPP server can be reached at for server-to-server communication.
static void setDNSResolver(DNSResolver resolver)
          Set the DNS resolver that should be used to perform DNS lookups.
protected static java.util.List<HostAddress> sortSRVRecords(java.util.List<SRVRecord> records)
          Sort a given list of SRVRecords as described in RFC 2782 Note that we follow the RFC with one exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DNSUtil

public DNSUtil()
Method Detail

setDNSResolver

public static void setDNSResolver(DNSResolver resolver)
Set the DNS resolver that should be used to perform DNS lookups.

Parameters:
resolver -

getDNSResolver

public static DNSResolver getDNSResolver()
Returns the current DNS resolved used to perform DNS lookups.

Returns:

resolveXMPPDomain

public static java.util.List<HostAddress> resolveXMPPDomain(java.lang.String domain)
Returns a list of HostAddresses under which the specified XMPP server can be reached at for client-to-server communication. A DNS lookup for a SRV record in the form "_xmpp-client._tcp.example.com" is attempted, according to section 14.4 of RFC 3920. If that lookup fails, a lookup in the older form of "_jabber._tcp.example.com" is attempted since servers that implement an older version of the protocol may be listed using that notation. If that lookup fails as well, it's assumed that the XMPP server lives at the host resolved by a DNS lookup at the specified domain on the default port of 5222.

As an example, a lookup for "example.com" may return "im.example.com:5269".

Parameters:
domain - the domain.
Returns:
List of HostAddress, which encompasses the hostname and port that the XMPP server can be reached at for the specified domain.

resolveXMPPServerDomain

public static java.util.List<HostAddress> resolveXMPPServerDomain(java.lang.String domain)
Returns a list of HostAddresses under which the specified XMPP server can be reached at for server-to-server communication. A DNS lookup for a SRV record in the form "_xmpp-server._tcp.example.com" is attempted, according to section 14.4 of RFC 3920. If that lookup fails, a lookup in the older form of "_jabber._tcp.example.com" is attempted since servers that implement an older version of the protocol may be listed using that notation. If that lookup fails as well, it's assumed that the XMPP server lives at the host resolved by a DNS lookup at the specified domain on the default port of 5269.

As an example, a lookup for "example.com" may return "im.example.com:5269".

Parameters:
domain - the domain.
Returns:
List of HostAddress, which encompasses the hostname and port that the XMPP server can be reached at for the specified domain.

sortSRVRecords

protected static java.util.List<HostAddress> sortSRVRecords(java.util.List<SRVRecord> records)
Sort a given list of SRVRecords as described in RFC 2782 Note that we follow the RFC with one exception. In a group of the same priority, only the first entry is calculated by random. The others are ore simply ordered by their priority.

Parameters:
records -
Returns:

Smack

Copyright © 2003-2007 Jive Software.