Search in sources :

Example 1 with DNSMsgHeader

use of net.sf.ivmaidns.dns.DNSMsgHeader in project fqrouter by fqrouter.

the class DnsUtils method resolveA.

public static List<Inet4Address> resolveA(String domain, InetSocketAddress dnsServer) throws Exception {
    DNSMsgHeader qHeader = DNSMsgHeader.construct(DNSMsgHeader.QUERY, true, 1, 0, 0, 0, false);
    DNSRecord[] records = new DNSRecord[1];
    records[0] = new DNSRecord(new DNSName(domain, null), DNSRecord.A, DNSRecord.IN);
    byte[] query = DNSConnection.encode(qHeader, records);
    try {
        return resolveAOverUdp(dnsServer, query);
    } catch (Exception e) {
        LogUtils.e("failed to resolve over udp", e);
        return resolveAOverTcp(dnsServer, query);
    }
}
Also used : DNSMsgHeader(net.sf.ivmaidns.dns.DNSMsgHeader) DNSRecord(net.sf.ivmaidns.dns.DNSRecord) DNSName(net.sf.ivmaidns.dns.DNSName) IOException(java.io.IOException)

Example 2 with DNSMsgHeader

use of net.sf.ivmaidns.dns.DNSMsgHeader in project fqrouter by fqrouter.

the class DnsUtils method resolveTXT.

public static String resolveTXT(String domain, InetSocketAddress dnsServer) throws Exception {
    DNSMsgHeader qHeader = DNSMsgHeader.construct(DNSMsgHeader.QUERY, true, 1, 0, 0, 0, false);
    DNSRecord[] records = new DNSRecord[1];
    records[0] = new DNSRecord(new DNSName(domain, null), DNSRecord.TXT, DNSRecord.IN);
    byte[] request = DNSConnection.encode(qHeader, records);
    try {
        return resolveTXTOverUdp(dnsServer, request);
    } catch (Exception e) {
        LogUtils.e("failed to resolve txt over udp at " + dnsServer, e);
        return resolveTXTOverTcp(dnsServer, request);
    }
}
Also used : DNSMsgHeader(net.sf.ivmaidns.dns.DNSMsgHeader) DNSRecord(net.sf.ivmaidns.dns.DNSRecord) DNSName(net.sf.ivmaidns.dns.DNSName) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 DNSMsgHeader (net.sf.ivmaidns.dns.DNSMsgHeader)2 DNSName (net.sf.ivmaidns.dns.DNSName)2 DNSRecord (net.sf.ivmaidns.dns.DNSRecord)2