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

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

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

Lookup.getErrorString介绍

暂无

代码示例

代码示例来源: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: 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: 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: 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: net.sf.dnsjava-osgi/dnsjava-osgi

if (ns == null) {
  System.out.println("failed to look up NS record: " +
        l.getErrorString());
  System.exit(1);

代码示例来源:origin: tiandawu/IotXmpp

if (ns == null) {
  System.out.println("failed to look up NS record: " +
        l.getErrorString());
  System.exit(1);

代码示例来源:origin: org.littleshoot/dnsjava

if (ns == null) {
  System.out.println("failed to look up NS record: " +
        l.getErrorString());
  System.exit(1);

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

log.log(Level.ERROR, "Unable to discovery endpoints for " + value + " via DNS error: " + up.getErrorString());

代码示例来源: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: com.helger/peppol-commons

LOGGER.warn ("Error looking up '" + sDNSName + "': " + aLookup.getErrorString ());
return null;

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

throw new TimeoutException(query.getErrorString());

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

throw new TimeoutException(query.getErrorString());

相关文章