本文整理了Java中org.xbill.DNS.Lookup.setResolver()
方法的一些代码示例,展示了Lookup.setResolver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lookup.setResolver()
方法的具体详情如下:
包路径:org.xbill.DNS.Lookup
类名称:Lookup
方法名:setResolver
暂无
代码示例来源:origin: yuliskov/SmartYouTubeTV
public List<InetAddress> resolve(String host) {
List<InetAddress> hostIPs = new ArrayList<>();
try {
Lookup lookup = new Lookup(host, Type.A);
lookup.setResolver(resolver);
Record[] records = lookup.run();
if (records == null) {
return hostIPs;
}
for (Record record : records) {
hostIPs.add(((ARecord) record).getAddress());
}
} catch (TextParseException ex) {
Log.e(TAG, ex.getMessage(), ex);
throw new IllegalStateException(ex);
}
return hostIPs;
}
代码示例来源:origin: org.nhind/agent
@Override
public void setResolver(Resolver res) {
lu.setResolver(res);
}
代码示例来源:origin: github/elasticsearch-srv-discovery
protected List<Record> lookupRecords(String query, int type) throws TextParseException {
Lookup lookup = new Lookup(query, type);
if (this.resolver != null) {
lookup.setResolver(this.resolver);
}
Record[] records = lookup.run();
return records == null ? new ArrayList<Record>() : Arrays.asList(records);
}
代码示例来源:origin: org.echocat.jomon.net/common
@Nonnull
protected Lookup createLookupFor(@Nonnull String query, @Nonnegative int type) {
final Lookup lookup;
try {
lookup = new Lookup(query, type);
} catch (final TextParseException e) {
throw new IllegalArgumentException("Could not parse query: " + query, e);
}
final Resolver resolver = _resolver;
lookup.setResolver(resolver != null ? resolver : getDefaultResolver());
lookup.setCache(null);
return lookup;
}
代码示例来源:origin: spotify/dns-java
@Override
public Lookup forName(String fqdn) {
try {
final Lookup lookup = new Lookup(fqdn, Type.SRV, DClass.IN);
if (resolver != null) {
lookup.setResolver(resolver);
}
return lookup;
} catch (TextParseException e) {
throw new DnsException("unable to create lookup for name: " + fqdn, e);
}
}
}
代码示例来源:origin: com.helger/ph-httpclient
@Nonnull
protected Lookup createLookup (@Nonnull final String sHost) throws TextParseException
{
final Lookup aDNSLookup = new Lookup (sHost, Type.ANY);
try
{
aDNSLookup.setResolver (new SimpleResolver ());
}
catch (final UnknownHostException ex)
{
// Shit happens - no special resolver needed
}
// No cache!
aDNSLookup.setCache (null);
return aDNSLookup;
}
代码示例来源:origin: OpenNMS/opennms
private static boolean resolve(final Name name,
final Resolver resolver,
final int type) {
final Lookup lookup = new Lookup(name, type);
// NMS-9238: Do not use a cache when looking up the record,
// that kind of defeats the purpose of this monitor :)
lookup.setCache(null);
lookup.setResolver(resolver);
final Record[] records = lookup.run();
if (records == null) {
return false;
}
return Arrays.stream(records)
.filter(r -> r.getType() == type)
.count() > 0;
}
}
代码示例来源:origin: sir-barchable/barchomat
public List<InetAddress> getAllAddresses(String hostName) throws UnknownHostException {
Lookup lookup;
try {
lookup = new Lookup(hostName, Type.A);
lookup.setCache(null);
lookup.setResolver(new SimpleResolver(server));
} catch (TextParseException e) {
throw new UnknownHostException(hostName);
}
List<InetAddress> addresses = new ArrayList<>();
Record[] a = lookup.run();
if (a == null || a.length == 0) {
throw new UnknownHostException(hostName);
}
for (Record record : a) {
addresses.add(((ARecord) record).getAddress());
}
return addresses;
}
}
代码示例来源:origin: org.nhind/agent
lu.setResolver(createExResolver(dnsServers.toArray(new String[dnsServers.size()]), 0, 6));
lu.setSearchPath((String[])null);
代码示例来源:origin: org.nhind/gateway
lu.setResolver(dnsResolver);
lu.setSearchPath((String[])null);
lu.setResolver(dnsResolver);
lu.setSearchPath((String[])null);
代码示例来源:origin: optimaize/webcrawler-verifier
/**
* Performs a reverse DNS lookup.
*
* @param addr The ip address to lookup.
* @return The host name found for the ip address.
* Absent if the ip is not mapped, or something.
* @throws IOException on a possibly temporary network error.
*/
private Optional<String> getHostByAddr(byte[] addr) throws IOException {
Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
Record[] records;
Lookup lookup;
if (dnsServers!=null) {
final Resolver res = new ExtendedResolver(dnsServers);
lookup = new Lookup(name, Type.PTR);
lookup.setResolver(res);
records = lookup.run();
} else {
lookup = new Lookup(name, Type.PTR);
records = lookup.run();
}
int result = lookup.getResult();
if (result==Lookup.TRY_AGAIN) {
throw new IOException("Network error when trying to look up "+ Arrays.toString(addr) +", try again.");
}
if (result != Lookup.SUCCESSFUL || records == null) {
return Optional.absent();
}
return Optional.of(((PTRRecord) records[0]).getTarget().toString());
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_http
resolver.setTimeout(timeoutMs / 1000, timeoutMs % 1000);
lookup.setResolver(resolver);
Record[] records = lookup.run();
if (records == null || records.length == 0) {
代码示例来源:origin: org.apache.james.jdkim/apache-jdkim-library
/**
* @see org.apache.james.jdkim.api.PublicKeyRecordRetriever#getRecords(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence)
*/
public List<String> getRecords(CharSequence methodAndOptions,
CharSequence selector, CharSequence token)
throws TempFailException, PermFailException {
if (!"dns/txt".equals(methodAndOptions))
throw new PermFailException("Only dns/txt is supported: "
+ methodAndOptions + " options unsupported.");
try {
Lookup query = new Lookup(selector + "._domainkey." + token,
Type.TXT);
query.setResolver(resolver);
Record[] rr = query.run();
int queryResult = query.getResult();
if (queryResult == Lookup.TRY_AGAIN) {
throw new TempFailException(query.getErrorString());
}
List<String> records = convertRecordsToList(rr);
return records;
} catch (TextParseException e) {
// TODO log
return null;
}
}
代码示例来源:origin: apache/james-project
l.setResolver(resolver);
l.setCredibility(dnsCredibility);
l.setSearchPath(searchPaths);
代码示例来源:origin: org.apache.james/james-server-dnsservice-dnsjava
l.setResolver(resolver);
l.setCredibility(dnsCredibility);
l.setSearchPath(searchPaths);
代码示例来源:origin: org.nhind/agent
lu.setResolver(createExResolver(servers.toArray(new String[servers.size()]), retries, timeout)); // default retries is 3, limite to 2
lu.setSearchPath((String[])null);
lu.setResolver(createExResolver(servers.toArray(new String[servers.size()]), retries, timeout));
lu.setSearchPath((String[])null);
lu.setResolver(createExResolver(servers.toArray(new String[servers.size()]), retries, timeout));
lu.setSearchPath((String[])null);
retRecords = lu.run();
ExtendedResolver remoteResolver = createExResolver(remoteServers, 2, 3);
if (remoteResolver.getResolvers().length > 0) {
lu.setResolver(remoteResolver);
lu.setSearchPath((String[])null);
代码示例来源:origin: com.helger/peppol-commons
aLookup.setResolver (aNewResolver);
代码示例来源:origin: org.apache.james.jspf/apache-jspf-resolver
query.setResolver(resolver);
内容来源于网络,如有侵权,请联系作者删除!