more patches for dns helper
This commit is contained in:
parent
50410dad33
commit
5cbae25808
|
@ -140,23 +140,17 @@ public class DNSHelper {
|
||||||
}
|
}
|
||||||
ArrayList<Bundle> values = new ArrayList<>();
|
ArrayList<Bundle> values = new ArrayList<>();
|
||||||
for (SRV srv : result) {
|
for (SRV srv : result) {
|
||||||
Bundle namePort = new Bundle();
|
boolean added = false;
|
||||||
namePort.putString("name", srv.getName());
|
|
||||||
namePort.putInt("port", srv.getPort());
|
|
||||||
if (ips6.containsKey(srv.getName())) {
|
if (ips6.containsKey(srv.getName())) {
|
||||||
ArrayList<String> ip = ips6.get(srv.getName());
|
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips6));
|
||||||
Collections.shuffle(ip, rnd);
|
added = true;
|
||||||
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());
|
values.add(createNamePortBundle(srv.getName(),srv.getPort(),ips4));
|
||||||
Collections.shuffle(ip, rnd);
|
added = true;
|
||||||
namePort.putString("ip", ip.get(0));
|
|
||||||
values.add(namePort);
|
|
||||||
}
|
}
|
||||||
if (!ips6.containsKey(srv.getName()) && !ips4.containsKey(srv.getName())) {
|
if (!added) {
|
||||||
values.add(namePort);
|
values.add(createNamePortBundle(srv.getName(),srv.getPort(),null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bundle.putParcelableArrayList("values", values);
|
bundle.putParcelableArrayList("values", values);
|
||||||
|
@ -168,6 +162,18 @@ public class DNSHelper {
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Bundle createNamePortBundle(String name, int port, TreeMap<String, ArrayList<String>> ips) {
|
||||||
|
Bundle namePort = new Bundle();
|
||||||
|
namePort.putString("name", name);
|
||||||
|
namePort.putInt("port", port);
|
||||||
|
if (ips!=null) {
|
||||||
|
ArrayList<String> ip = ips.get(name);
|
||||||
|
Collections.shuffle(ip, new Random());
|
||||||
|
namePort.putString("ip", ip.get(0));
|
||||||
|
}
|
||||||
|
return namePort;
|
||||||
|
}
|
||||||
|
|
||||||
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||||
|
|
||||||
public static String bytesToHex(byte[] bytes) {
|
public static String bytesToHex(byte[] bytes) {
|
||||||
|
|
Loading…
Reference in a new issue