Skip to content

Commit

Permalink
Always lookup DNS SRV RR on connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Mar 20, 2014
1 parent 363354f commit 1cf4681
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 10 additions & 3 deletions bosh/src/main/java/org/jivesoftware/smack/BOSHConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,16 @@ public URI getURI() throws URISyntaxException {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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
Expand Down Expand Up @@ -566,9 +560,7 @@ void setLoginInfo(String username, String password, String resource) {
}

void maybeResolveDns() throws Exception {
// Abort if we did already resolve the hosts successfully
if (hostAddresses != null)
return;
if (!useDnsSrvRr) return;
hostAddresses = DNSUtil.resolveXMPPDomain(serviceName);
}

Expand All @@ -577,5 +569,6 @@ private void initHostAddresses(String host, int port) {
HostAddress hostAddress;
hostAddress = new HostAddress(host, port);
hostAddresses.add(hostAddress);
useDnsSrvRr = false;
}
}

0 comments on commit 1cf4681

Please sign in to comment.