org.xbill.DNS.Lookup.getResult()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(248)

本文整理了Java中org.xbill.DNS.Lookup.getResult()方法的一些代码示例,展示了Lookup.getResult()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lookup.getResult()方法的具体详情如下:
包路径:org.xbill.DNS.Lookup
类名称:Lookup
方法名:getResult

Lookup.getResult介绍

暂无

代码示例

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

records = lookup.run();
  retryCount++;
} while (lookup.getResult() == Lookup.TRY_AGAIN && retryCount < DNS_NETWORK_FAILURE_RETRY_COUNT);

代码示例来源:origin: dnsjava/dnsjava

public static void
printAnswer(String name, Lookup lookup) {
  System.out.print(name + ":");
  int result = lookup.getResult();
  if (result != Lookup.SUCCESSFUL)
    System.out.print(" " + lookup.getErrorString());
  System.out.println();
  Name [] aliases = lookup.getAliases();
  if (aliases.length > 0) {
    System.out.print("# aliases: ");
    for (int i = 0; i < aliases.length; i++) {
      System.out.print(aliases[i]);
      if (i < aliases.length - 1)
        System.out.print(" ");
    }
    System.out.println();
  }
  if (lookup.getResult() == Lookup.SUCCESSFUL) {
    Record [] answers = lookup.getAnswers();
    for (int i = 0; i < answers.length; i++)
      System.out.println(answers[i]);
  }
}

代码示例来源:origin: com.spotify/dns

@Override
public List<LookupResult> resolve(final String fqdn) {
 Lookup lookup = lookupFactory.forName(fqdn);
 Record[] queryResult = lookup.run();
 switch (lookup.getResult()) {
  case Lookup.SUCCESSFUL:
   return toLookupResults(queryResult);
  case Lookup.HOST_NOT_FOUND:
   // fallthrough
  case Lookup.TYPE_NOT_FOUND:
   LOG.warn("No results returned for query '{}'; result from XBill: {} - {}",
     fqdn, lookup.getResult(), lookup.getErrorString());
   return ImmutableList.of();
  default:
   throw new DnsException(
     String.format("Lookup of '%s' failed with code: %d - %s ",
       fqdn, lookup.getResult(), lookup.getErrorString()));
 }
}

代码示例来源:origin: spotify/dns-java

@Override
public List<LookupResult> resolve(final String fqdn) {
 Lookup lookup = lookupFactory.forName(fqdn);
 Record[] queryResult = lookup.run();
 switch (lookup.getResult()) {
  case Lookup.SUCCESSFUL:
   return toLookupResults(queryResult);
  case Lookup.HOST_NOT_FOUND:
   // fallthrough
  case Lookup.TYPE_NOT_FOUND:
   LOG.warn("No results returned for query '{}'; result from XBill: {} - {}",
     fqdn, lookup.getResult(), lookup.getErrorString());
   return ImmutableList.of();
  default:
   throw new DnsException(
     String.format("Lookup of '%s' failed with code: %d - %s ",
       fqdn, lookup.getResult(), lookup.getErrorString()));
 }
}

代码示例来源:origin: org.echocat.jomon.net/common

protected void checkResult(@Nonnull String query, @Nonnull Lookup lookup) throws NoSuchSrvRecordException, UnknownHostException, SocketException {
  final int result = lookup.getResult();
  if (result == HOST_NOT_FOUND) {
    throw new NoSuchSrvRecordException("Could not find srv entry for query '" + query + "' on remote " + toStringOfResolver(lookup) + ".");
  } else if (result == TYPE_NOT_FOUND) {
    throw new UnknownHostException("Could not find the host that should contain the srv entry for query '" + query + "' on remote " + toStringOfResolver(lookup) + ".");
  } else if (result == TRY_AGAIN) {
    throw new ServiceTemporaryUnavailableException("Could not get information from remote " + toStringOfResolver(lookup) + ".");
  } else if (result != 0) {
    throw new RuntimeException("Could not get information from remote " + toStringOfResolver(lookup) + ". Got: " + lookup.getErrorString());
  }
}

代码示例来源:origin: net.lightbody.bmp/browsermob-core

records = lookup.run();
  retryCount++;
} while (lookup.getResult() == Lookup.TRY_AGAIN && retryCount < DNS_NETWORK_FAILURE_RETRY_COUNT);

代码示例来源:origin: misakuo/Dream-Catcher

records = lookup.run();
  retryCount++;
} while (lookup.getResult() == Lookup.TRY_AGAIN && retryCount < DNS_NETWORK_FAILURE_RETRY_COUNT);

代码示例来源:origin: dnsjava/dnsjava

private static Record []
lookupHostName(String name, boolean all) throws UnknownHostException {
  try {
    Lookup lookup = new Lookup(name, Type.A);
    Record [] a = lookup.run();
    if (a == null) {
      if (lookup.getResult() == Lookup.TYPE_NOT_FOUND) {
        Record [] aaaa = new Lookup(name, Type.AAAA).run();
        if (aaaa != null)
          return aaaa;
      }
      throw new UnknownHostException("unknown host");
    }
    if (! all)
      return a;
    Record [] aaaa = new Lookup(name, Type.AAAA).run();
    if (aaaa == null)
      return a;
    Record [] merged = new Record[a.length + aaaa.length];
    System.arraycopy(a, 0, merged, 0, a.length);
    System.arraycopy(aaaa, 0, merged, a.length, aaaa.length);
    return merged;
  }
  catch (TextParseException e) {
    throw new UnknownHostException("invalid name");
  }
}

代码示例来源:origin: spotify/ffwd

private List<Server> lookup() {
    final Lookup lookup;
    try {
      lookup = new Lookup(record, Type.SRV, DClass.IN);
    } catch (TextParseException e) {
      throw new RuntimeException(e);
    }

    final Record[] result = lookup.run();

    if (lookup.getResult() != Lookup.SUCCESSFUL) {
      throw new RuntimeException(
        "DNS lookup failed: " + lookup.getErrorString() + ": " + record);
    }

    final ImmutableList.Builder<Server> results = ImmutableList.builder();

    if (result != null) {
      for (final Record a : result) {
        final SRVRecord srv = (SRVRecord) a;
        results.add(new Server(srv.getTarget().canonicalize().toString(), srv.getPort()));
      }
    }

    return results.build();
  }
}

代码示例来源:origin: org.mil-oss/fgsms-discovery-dns

if (up.getResult() != 0) {
  log.log(Level.ERROR, "Unable to discovery endpoints for " + value + " via DNS error: " + up.getErrorString());

代码示例来源: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.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: org.apache.james/james-server-dnsservice-dnsjava

if (l.getResult() == Lookup.TRY_AGAIN) {
  throw new TemporaryResolutionException("DNSService is temporary not reachable");
} else {

代码示例来源:origin: apache/james-project

if (l.getResult() == Lookup.TRY_AGAIN) {
  throw new TemporaryResolutionException("DNSService is temporary not reachable");
} else {

代码示例来源:origin: com.helger/peppol-commons

} while (aLookup.getResult () == Lookup.TRY_AGAIN && nLeft >= 0);
if (aLookup.getResult () == Lookup.TRY_AGAIN)
 } while (aLookup.getResult () == Lookup.TRY_AGAIN && nLeft >= 0);
if (aLookup.getResult () != Lookup.SUCCESSFUL)

代码示例来源:origin: org.apache.james.jspf/apache-jspf-resolver

int queryResult = query.getResult();

代码示例来源:origin: org.apache.james/apache-jspf

int queryResult = query.getResult();

相关文章