Search in sources :

Example 1 with Data

use of de.measite.minidns.record.Data 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() + "]");
            }
        }
    }
}
Also used : AAAA(de.measite.minidns.record.AAAA) A(de.measite.minidns.record.A) SRV(de.measite.minidns.record.SRV) Record(de.measite.minidns.Record) Data(de.measite.minidns.record.Data) AAAA(de.measite.minidns.record.AAAA) DNSMessage(de.measite.minidns.DNSMessage)

Aggregations

DNSMessage (de.measite.minidns.DNSMessage)1 Record (de.measite.minidns.Record)1 A (de.measite.minidns.record.A)1 AAAA (de.measite.minidns.record.AAAA)1 Data (de.measite.minidns.record.Data)1 SRV (de.measite.minidns.record.SRV)1