use of org.xbill.DNS.ExtLookup in project xabber-android by redsolution.
the class ExtDNSJavaResolver method lookupSRVRecords0.
@Override
protected List<SRVRecord> lookupSRVRecords0(String name, List<HostAddress> failedAddresses, ConnectionConfiguration.DnssecMode dnssecMode) {
List<SRVRecord> res = new ArrayList<SRVRecord>();
org.xbill.DNS.ResolverConfig.refresh();
ExtLookup lookup;
String[] servers = getDNSServersListForOreo();
try {
lookup = new ExtLookup(name, Type.SRV);
if (servers != null && servers.length > 0)
lookup.setResolver(new ExtendedResolver(servers));
else
lookup.setResolver(new ExtendedResolver());
} catch (TextParseException e) {
throw new IllegalStateException(e);
} catch (UnknownHostException e) {
throw new RuntimeException("Failed to initialize resolver");
}
Record[] recs = lookup.run();
if (recs == null)
return res;
for (Record record : recs) {
org.xbill.DNS.SRVRecord srvRecord = (org.xbill.DNS.SRVRecord) record;
if (srvRecord != null && srvRecord.getTarget() != null) {
String host = srvRecord.getTarget().toString();
int port = srvRecord.getPort();
int priority = srvRecord.getPriority();
int weight = srvRecord.getWeight();
List<InetAddress> hostAddresses = lookupHostAddress0(host, failedAddresses, dnssecMode);
if (hostAddresses == null) {
continue;
}
SRVRecord r = new SRVRecord(host, port, priority, weight, hostAddresses);
res.add(r);
}
}
return res;
}
Aggregations