use of net.sf.ivmaidns.dns.DNSRecord 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);
}
}
use of net.sf.ivmaidns.dns.DNSRecord 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);
}
}
use of net.sf.ivmaidns.dns.DNSRecord in project fqrouter by fqrouter.
the class DnsUtils method toIps.
private static List<Inet4Address> toIps(byte[] buffer) {
DNSRecord[] records = DNSConnection.decode(buffer);
List<Inet4Address> ips = new ArrayList<Inet4Address>();
for (DNSRecord record : records) {
if (DNSRecord.A == record.getRType()) {
if (record.getRData().length > 0) {
ips.add((Inet4Address) record.getRData()[0]);
}
}
}
return ips;
}
Aggregations