aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-07-24 19:06:47 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-07-24 19:06:47 +0200
commit9c94c9ad8fe10aa1ffeb122b1db114680a7d95a2 (patch)
treef6da244678536b0654fa3fe090e3be6f6ec61b1e /src/main/java/eu
parente5fae429fa45a065979103eaf95f0c8b1edc4ab4 (diff)
rewrote dns fallback
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/utils/DNSHelper.java15
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java3
2 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java
index 36d03b30..60e1f0be 100644
--- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java
@@ -38,17 +38,14 @@ public class DNSHelper {
public static Bundle getSRVRecord(final Jid jid) throws IOException {
final String host = jid.getDomainpart();
String dns[] = client.findDNS();
-
- if (dns != null) {
- for (String dnsserver : dns) {
- InetAddress ip = InetAddress.getByName(dnsserver);
- Bundle b = queryDNS(host, ip);
- if (b.containsKey("values")) {
- return b;
- }
+ for (int i = 0; i < dns.length; ++i) {
+ InetAddress ip = InetAddress.getByName(dns[i]);
+ Bundle b = queryDNS(host, ip);
+ if (b.containsKey("values") || i == dns.length - 1) {
+ return b;
}
}
- return queryDNS(host, InetAddress.getByName("8.8.8.8"));
+ return null;
}
public static Bundle queryDNS(String host, InetAddress dnsServer) {
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 7c81d988..c41c5174 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -164,6 +164,9 @@ public class XmppConnection implements Runnable {
}
} else {
final Bundle result = DNSHelper.getSRVRecord(account.getServer());
+ if (result == null) {
+ throw new IOException("unhandled exception in DNS resolver");
+ }
final ArrayList<Parcelable> values = result.getParcelableArrayList("values");
if ("timeout".equals(result.getString("error"))) {
throw new IOException("timeout in dns");