use of de.measite.minidns.Record in project Conversations by siacs.
the class DNSHelper method fillSrvMaps.
private static void fillSrvMaps(final String qname, final InetAddress dnsServer, final Map<Integer, List<TlsSrv>> priorities, final Map<String, List<String>> ips4, final Map<String, List<String>> ips6, final boolean tls) throws IOException {
final DNSMessage message = client.query(qname, TYPE.SRV, CLASS.IN, dnsServer.getHostAddress());
for (Record[] rrset : new Record[][] { message.getAnswers(), message.getAdditionalResourceRecords() }) {
for (Record rr : rrset) {
Data d = rr.getPayload();
final String name = rr.getName() != null ? rr.getName().toLowerCase(Locale.US) : null;
if (d instanceof SRV && NameUtil.idnEquals(qname, name)) {
SRV srv = (SRV) d;
if (!priorities.containsKey(srv.getPriority())) {
priorities.put(srv.getPriority(), new ArrayList<TlsSrv>());
}
priorities.get(srv.getPriority()).add(new TlsSrv(srv, tls));
} else if (d instanceof SRV) {
Log.d(Config.LOGTAG, "found unrecognized SRV record with name: " + name);
}
if (d instanceof A) {
A a = (A) d;
if (!ips4.containsKey(name)) {
ips4.put(name, new ArrayList<String>());
}
ips4.get(name).add(a.toString());
}
if (d instanceof AAAA) {
AAAA aaaa = (AAAA) d;
if (!ips6.containsKey(name)) {
ips6.put(name, new ArrayList<String>());
}
ips6.get(name).add("[" + aaaa.toString() + "]");
}
}
}
}