let dns library take care of no-srv style hosts as well
This commit is contained in:
parent
5373956e19
commit
a577ec7c31
|
@ -37,9 +37,6 @@ public class DNSHelper {
|
||||||
Bundle b = queryDNS(host, ip);
|
Bundle b = queryDNS(host, ip);
|
||||||
if (b.containsKey("values")) {
|
if (b.containsKey("values")) {
|
||||||
return b;
|
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) {
|
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;
|
return bundle;
|
||||||
}
|
}
|
||||||
ArrayList<Bundle> values = new ArrayList<>();
|
|
||||||
for (SRV srv : result) {
|
for (SRV srv : result) {
|
||||||
if (ips6.containsKey(srv.getName())) {
|
if (ips6.containsKey(srv.getName())) {
|
||||||
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips6));
|
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips6));
|
||||||
} else {
|
} else {
|
||||||
DNSMessage response = client.query(srv.getName(), TYPE.AAAA, CLASS.IN, dnsServer.getHostAddress());
|
DNSMessage response = client.query(srv.getName(), TYPE.AAAA, CLASS.IN, dnsServer.getHostAddress());
|
||||||
if (response.getAnswers().length >= 1) {
|
for(int i = 0; i < response.getAnswers().length; ++i) {
|
||||||
values.add(createNamePortBundle(srv.getName(),srv.getPort(),response.getAnswers()[0].getPayload()));
|
values.add(createNamePortBundle(host,5222,response.getAnswers()[i].getPayload()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ips4.containsKey(srv.getName())) {
|
if (ips4.containsKey(srv.getName())) {
|
||||||
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips4));
|
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips4));
|
||||||
} else {
|
} else {
|
||||||
DNSMessage response = client.query(srv.getName(), TYPE.A, CLASS.IN, dnsServer.getHostAddress());
|
DNSMessage response = client.query(srv.getName(), TYPE.A, CLASS.IN, dnsServer.getHostAddress());
|
||||||
if (response.getAnswers().length >= 1) {
|
for(int i = 0; i < response.getAnswers().length; ++i) {
|
||||||
values.add(createNamePortBundle(srv.getName(),srv.getPort(),response.getAnswers()[0].getPayload()));
|
values.add(createNamePortBundle(host,5222,response.getAnswers()[i].getPayload()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
values.add(createNamePortBundle(srv.getName(), srv.getPort()));
|
values.add(createNamePortBundle(srv.getName(), srv.getPort()));
|
||||||
|
@ -162,6 +168,7 @@ public class DNSHelper {
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
bundle.putString("error", "timeout");
|
bundle.putString("error", "timeout");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Log.d(Config.LOGTAG,e.getMessage());
|
||||||
bundle.putString("error", "unhandled");
|
bundle.putString("error", "unhandled");
|
||||||
}
|
}
|
||||||
return bundle;
|
return bundle;
|
||||||
|
|
|
@ -200,9 +200,6 @@ public class XmppConnection implements Runnable {
|
||||||
if (socketError) {
|
if (socketError) {
|
||||||
throw new UnknownHostException();
|
throw new UnknownHostException();
|
||||||
}
|
}
|
||||||
} else if (result.containsKey("error")
|
|
||||||
&& "nosrv".equals(result.getString("error", null))) {
|
|
||||||
socket = new Socket(account.getServer().getDomainpart(), 5222);
|
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("unhandled exception in DNS resolver");
|
throw new IOException("unhandled exception in DNS resolver");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue