Package org.jivesoftware.openfire.net
Class DNSUtil
java.lang.Object
org.jivesoftware.openfire.net.DNSUtil
Utility class to perform DNS lookups for XMPP services.
- Author:
- Matt Tucker
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Deprecated, for removal: This API element is subject to removal in a future version.static class
Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the internal DNS that allows to specify target IP addresses and ports to use for domains.static boolean
isNameCoveredByPattern
(String name, String pattern) Checks if the provided DNS pattern matches the provided name.static List<DNSUtil.WeightedHostAddress>
prioritize
(DNSUtil.WeightedHostAddress[] records) Deprecated, for removal: This API element is subject to removal in a future version.Replaced bySrvRecord.prioritize(SrvRecord[])
resolveXMPPDomain
(String domain, int defaultPort) Returns a collection of host names and ports that the specified XMPP domain can be reached at for server-to-server communication.static void
setDnsOverride
(Map<String, SrvRecord> dnsOverride) Sets the internal DNS that allows to specify target IP addresses and ports to use for domains.Performs a DNS SRV lookup.
-
Constructor Details
-
DNSUtil
public DNSUtil()
-
-
Method Details
-
resolveXMPPDomain
Returns a collection of host names and ports that the specified XMPP domain can be reached at for server-to-server communication. DNS lookups for a SRV records in the form "_xmpp-server._tcp.example.com" and "_xmpps-server._tcp.example.com" are attempted, in line with section 3.2 of XMPP Core and XEP-0368. If those lookup fail to provide any records, 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 A lookup at the specified domain on the specified default port. As an example, a lookup for "example.com" may return "im.example.com:5269". The returned collection is a list of sets of host names. The 'inner' collection, the sets of host names, are grouping host names that have an equal 'priority' SRV value. The 'outer' collection, the list, defines the order that's defined by the 'priority' value (lowest first). Generally speaking, all values from the first set of the outer list should be processed, before elements from the next set of that list are to be processed. The Sets that are returned as elements of the list have a predictable iteration order. This order is based on a randomization based on the SRV 'weight' value of each host. -
getDnsOverride
Returns the internal DNS that allows to specify target IP addresses and ports to use for domains. The internal DNS will be checked up before performing an actual DNS SRV lookup.- Returns:
- the internal DNS that allows to specify target IP addresses and ports to use for domains.
-
setDnsOverride
Sets the internal DNS that allows to specify target IP addresses and ports to use for domains. The internal DNS will be checked up before performing an actual DNS SRV lookup.- Parameters:
dnsOverride
- the internal DNS that allows to specify target IP addresses and ports to use for domains.
-
srvLookup
public static List<SrvRecord> srvLookup(@Nonnull String service, @Nonnull String proto, @Nonnull String name) Performs a DNS SRV lookup. Does not take into account any DNS overrides configured in this class. The results returned by this method are ordered by priority (ascending), and order of equal priority entries is randomized by weight, as defined in the DNS SRV specification.- Parameters:
service
- the symbolic name of the desired service.proto
- the transport protocol of the desired service; this is usually either TCP or UDP.name
- the domain name for which this record is valid.- Returns:
- An ordered list of results (possibly empty, never null).
-
isNameCoveredByPattern
Checks if the provided DNS pattern matches the provided name. For example, this method will: return true for name:xmpp.example.org
, pattern:*.example.org
return false for name:xmpp.example.org
, pattern:example.org
This method is not case sensitive.- Parameters:
name
- The name to check against a pattern (cannot be null or empty).pattern
- the pattern (cannot be null or empty).- Returns:
- true when the name is covered by the pattern, otherwise false.
-
prioritize
@Deprecated(since="5.0.0", forRemoval=true) public static List<DNSUtil.WeightedHostAddress> prioritize(DNSUtil.WeightedHostAddress[] records) Deprecated, for removal: This API element is subject to removal in a future version.Replaced bySrvRecord.prioritize(SrvRecord[])
-
SrvRecord