possible dns fixes

This commit is contained in:
iNPUTmice 2014-12-14 18:31:52 +01:00
parent de06cb38d1
commit 50410dad33
2 changed files with 12 additions and 3 deletions

View file

@ -143,12 +143,21 @@ public class DNSHelper {
Bundle namePort = new Bundle(); Bundle namePort = new Bundle();
namePort.putString("name", srv.getName()); namePort.putString("name", srv.getName());
namePort.putInt("port", srv.getPort()); namePort.putInt("port", srv.getPort());
if (ips6.containsKey(srv.getName())) {
ArrayList<String> ip = ips6.get(srv.getName());
Collections.shuffle(ip, rnd);
namePort.putString("ip", ip.get(0));
values.add(namePort);
}
if (ips4.containsKey(srv.getName())) { if (ips4.containsKey(srv.getName())) {
ArrayList<String> ip = ips4.get(srv.getName()); ArrayList<String> ip = ips4.get(srv.getName());
Collections.shuffle(ip, rnd); Collections.shuffle(ip, rnd);
namePort.putString("ipv4", ip.get(0)); namePort.putString("ip", ip.get(0));
values.add(namePort);
}
if (!ips6.containsKey(srv.getName()) && !ips4.containsKey(srv.getName())) {
values.add(namePort);
} }
values.add(namePort);
} }
bundle.putParcelableArrayList("values", values); bundle.putParcelableArrayList("values", values);
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {

View file

@ -171,7 +171,7 @@ public class XmppConnection implements Runnable {
srvRecordServer = ""; srvRecordServer = "";
} }
int srvRecordPort = namePort.getInt("port"); int srvRecordPort = namePort.getInt("port");
String srvIpServer = namePort.getString("ipv4"); String srvIpServer = namePort.getString("ip");
InetSocketAddress addr; InetSocketAddress addr;
if (srvIpServer != null) { if (srvIpServer != null) {
addr = new InetSocketAddress(srvIpServer, srvRecordPort); addr = new InetSocketAddress(srvIpServer, srvRecordPort);