aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-05-28 17:31:46 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-05-28 17:31:46 +0200
commita577ec7c318d734de3ed8c2dc5ab1dd4b773b78a (patch)
treef1f6eacbbaae473757a051788250884a825a2cc8 /src/main/java/eu/siacs
parent5373956e19f318551841d59885f4c2567ffd46a3 (diff)
let dns library take care of no-srv style hosts as well
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/utils/DNSHelper.java25
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java3
2 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java
index 5135acf7..e91005a1 100644
--- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java
@@ -37,9 +37,6 @@ public class DNSHelper {
Bundle b = queryDNS(host, ip);
if (b.containsKey("values")) {
return b;
- } else if (b.containsKey("error")
- && "nosrv".equals(b.getString("error", null))) {
- return b;
}
}
}
@@ -134,26 +131,35 @@ public class DNSHelper {
}
+ ArrayList<Bundle> values = new ArrayList<>();
if (result.size() == 0) {
- bundle.putString("error", "nosrv");
+ DNSMessage response;
+ response = client.query(host, TYPE.A, CLASS.IN, dnsServer.getHostAddress());
+ for(int i = 0; i < response.getAnswers().length; ++i) {
+ values.add(createNamePortBundle(host,5222,response.getAnswers()[i].getPayload()));
+ }
+ response = client.query(host, TYPE.AAAA, CLASS.IN, dnsServer.getHostAddress());
+ for(int i = 0; i < response.getAnswers().length; ++i) {
+ values.add(createNamePortBundle(host,5222,response.getAnswers()[i].getPayload()));
+ }
+ bundle.putParcelableArrayList("values", values);
return bundle;
}
- ArrayList<Bundle> values = new ArrayList<>();
for (SRV srv : result) {
if (ips6.containsKey(srv.getName())) {
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips6));
} else {
DNSMessage response = client.query(srv.getName(), TYPE.AAAA, CLASS.IN, dnsServer.getHostAddress());
- if (response.getAnswers().length >= 1) {
- values.add(createNamePortBundle(srv.getName(),srv.getPort(),response.getAnswers()[0].getPayload()));
+ for(int i = 0; i < response.getAnswers().length; ++i) {
+ values.add(createNamePortBundle(host,5222,response.getAnswers()[i].getPayload()));
}
}
if (ips4.containsKey(srv.getName())) {
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips4));
} else {
DNSMessage response = client.query(srv.getName(), TYPE.A, CLASS.IN, dnsServer.getHostAddress());
- if (response.getAnswers().length >= 1) {
- values.add(createNamePortBundle(srv.getName(),srv.getPort(),response.getAnswers()[0].getPayload()));
+ for(int i = 0; i < response.getAnswers().length; ++i) {
+ values.add(createNamePortBundle(host,5222,response.getAnswers()[i].getPayload()));
}
}
values.add(createNamePortBundle(srv.getName(), srv.getPort()));
@@ -162,6 +168,7 @@ public class DNSHelper {
} catch (SocketTimeoutException e) {
bundle.putString("error", "timeout");
} catch (Exception e) {
+ Log.d(Config.LOGTAG,e.getMessage());
bundle.putString("error", "unhandled");
}
return bundle;
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index d52ebee5..f6e0bfdc 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -200,9 +200,6 @@ public class XmppConnection implements Runnable {
if (socketError) {
throw new UnknownHostException();
}
- } else if (result.containsKey("error")
- && "nosrv".equals(result.getString("error", null))) {
- socket = new Socket(account.getServer().getDomainpart(), 5222);
} else {
throw new IOException("unhandled exception in DNS resolver");
}