Permalink
Browse files

Always lookup DNS SRV RR on connect()

  • Loading branch information...
1 parent 363354f commit 1cf468158138433152892dfa4a8f8a9819505069 @Flowdalic Flowdalic committed Mar 20, 2014
@@ -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);
}
}
@@ -77,6 +77,7 @@
private boolean sendPresence = true;
private boolean rosterLoadedAtLogin = true;
private boolean legacySessionDisabled = false;
+ private boolean useDnsSrvRr = true;
private SecurityMode securityMode = SecurityMode.enabled;
/**
@@ -88,13 +89,6 @@
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
* and port to use for the connection.
@@ -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);
}
@@ -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.