mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-01 05:02:21 -05:00
rewrote dns fallback
This commit is contained in:
parent
e5fae429fa
commit
9c94c9ad8f
@ -38,17 +38,14 @@ public class DNSHelper {
|
|||||||
public static Bundle getSRVRecord(final Jid jid) throws IOException {
|
public static Bundle getSRVRecord(final Jid jid) throws IOException {
|
||||||
final String host = jid.getDomainpart();
|
final String host = jid.getDomainpart();
|
||||||
String dns[] = client.findDNS();
|
String dns[] = client.findDNS();
|
||||||
|
for (int i = 0; i < dns.length; ++i) {
|
||||||
if (dns != null) {
|
InetAddress ip = InetAddress.getByName(dns[i]);
|
||||||
for (String dnsserver : dns) {
|
Bundle b = queryDNS(host, ip);
|
||||||
InetAddress ip = InetAddress.getByName(dnsserver);
|
if (b.containsKey("values") || i == dns.length - 1) {
|
||||||
Bundle b = queryDNS(host, ip);
|
return b;
|
||||||
if (b.containsKey("values")) {
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return queryDNS(host, InetAddress.getByName("8.8.8.8"));
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bundle queryDNS(String host, InetAddress dnsServer) {
|
public static Bundle queryDNS(String host, InetAddress dnsServer) {
|
||||||
|
@ -164,6 +164,9 @@ public class XmppConnection implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Bundle result = DNSHelper.getSRVRecord(account.getServer());
|
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");
|
final ArrayList<Parcelable> values = result.getParcelableArrayList("values");
|
||||||
if ("timeout".equals(result.getString("error"))) {
|
if ("timeout".equals(result.getString("error"))) {
|
||||||
throw new IOException("timeout in dns");
|
throw new IOException("timeout in dns");
|
||||||
|
Loading…
Reference in New Issue
Block a user