From 1cf468158138433152892dfa4a8f8a9819505069 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 20 Mar 2014 16:56:58 +0100 Subject: [PATCH] Always lookup DNS SRV RR on connect() --- .../org/jivesoftware/smack/BOSHConfiguration.java | 13 ++++++++++--- .../jivesoftware/smack/ConnectionConfiguration.java | 13 +++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bosh/src/main/java/org/jivesoftware/smack/BOSHConfiguration.java b/bosh/src/main/java/org/jivesoftware/smack/BOSHConfiguration.java index 6adcd0331..9d13850d8 100644 --- a/bosh/src/main/java/org/jivesoftware/smack/BOSHConfiguration.java +++ b/bosh/src/main/java/org/jivesoftware/smack/BOSHConfiguration.java @@ -113,9 +113,16 @@ public class BOSHConfiguration extends ConnectionConfiguration { if (file.charAt(0) != '/') { file = '/' + file; } - HostAddress hostAddress = hostAddresses.get(0); - String host = hostAddress.getFQDN(); - int port = hostAddress.getPort(); + String host; + int port; + if (hostAddresses != null) { + HostAddress hostAddress = hostAddresses.get(0); + host = hostAddress.getFQDN(); + port = hostAddress.getPort(); + } else { + host = getServiceName(); + port = 80; + } return new URI((ssl ? "https://" : "http://") + host + ":" + port + file); } } diff --git a/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java b/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java index ef345172c..63b66779b 100644 --- a/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java +++ b/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java @@ -77,6 +77,7 @@ public class ConnectionConfiguration implements Cloneable { private boolean sendPresence = true; private boolean rosterLoadedAtLogin = true; private boolean legacySessionDisabled = false; + private boolean useDnsSrvRr = true; private SecurityMode securityMode = SecurityMode.enabled; /** @@ -87,13 +88,6 @@ public class ConnectionConfiguration implements Cloneable { // Holds the proxy information (such as proxyhost, proxyport, username, password etc) protected ProxyInfo proxy; - /** - * Constructor used for subclassing ConnectionConfiguration - */ - ConnectionConfiguration() { - /* Does nothing */ - } - /** * Creates a new ConnectionConfiguration for the specified service name. * A DNS SRV lookup will be performed to find out the actual host address @@ -566,9 +560,7 @@ public class ConnectionConfiguration implements Cloneable { } void maybeResolveDns() throws Exception { - // Abort if we did already resolve the hosts successfully - if (hostAddresses != null) - return; + if (!useDnsSrvRr) return; hostAddresses = DNSUtil.resolveXMPPDomain(serviceName); } @@ -577,5 +569,6 @@ public class ConnectionConfiguration implements Cloneable { HostAddress hostAddress; hostAddress = new HostAddress(host, port); hostAddresses.add(hostAddress); + useDnsSrvRr = false; } }