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

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

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

Lookup.run介绍

暂无

代码示例

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

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

代码示例来源:origin: internetarchive/heritrix3

rrecordSet = (new Lookup(lookupName, TypeType, ClassType)).run();
} catch (TextParseException e) {
  rrecordSet = null;

代码示例来源:origin: igniterealtime/Smack

@Override
protected List<SRVRecord> lookupSRVRecords0(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
  List<SRVRecord> res = new ArrayList<>();
  Lookup lookup;
  try {
    lookup = new Lookup(name.ace, Type.SRV);
  }
  catch (TextParseException e) {
    throw new IllegalStateException(e);
  }
  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) {
      DnsName host = DnsName.from(srvRecord.getTarget().toString());
      int port = srvRecord.getPort();
      int priority = srvRecord.getPriority();
      int weight = srvRecord.getWeight();
      List<InetAddress> hostAddresses = lookupHostAddress0(host, failedAddresses, dnssecMode);
      if (shouldContinue(name, host, hostAddresses)) {
        continue;
      }
      SRVRecord r = new SRVRecord(host, port, priority, weight, hostAddresses);
      res.add(r);
    }
  }
  return res;
}

代码示例来源: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: naver/ngrinder

/**
 * Finds A records (ip addresses) for the host name.
 *
 * @param name host name to resolve.
 * @return All the ip addresses found for the host name.
 * @throws UnknownHostException occurs when name is not available in DNS
 */
public InetAddress[] lookupAllHostAddr(String name) throws UnknownHostException {
  try {
    final Lookup lookup = new Lookup(name, Type.A);
    Record[] records = lookup.run();
    if (records == null) {
      throw new UnknownHostException(name);
    }
    InetAddress[] array = new InetAddress[records.length];
    for (int i = 0; i < records.length; i++) {
      ARecord a = (ARecord) records[i];
      array[i] = a.getAddress();
    }
    return array;
  } catch (TextParseException e) {
    throw new UnknownHostException(e.getMessage());
  }
}

代码示例来源:origin: naver/ngrinder

/**
   * Finds PTR records (reverse dns lookups) for the ip address.
   *
   * @param ip ip address to lookup.
   * @return The host name found for the ip address.
   * @throws UnknownHostException occurs when id is not available in DNS
   */
  public String getHostByAddr(byte[] ip) throws UnknownHostException {
    try {
      String addr = DnsUtils.numericToTextFormat(ip);
      Record[] records = new Lookup(addr, Type.PTR).run();
      if (records == null) {
        throw new UnknownHostException(addr);
      }
      PTRRecord ptr = (PTRRecord) records[0];
      return ptr.getTarget().toString();
    } catch (TextParseException e) {
      throw new UnknownHostException(e.getMessage());
    }
  }
}

代码示例来源:origin: org.nhind/agent

@Override
public Record[] run() {
  return lu.run();
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry

@Override
 public Record[] call() throws Exception {
  return new Lookup(name, type).run();
 }
}

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

private static Record []
lookupHostName(String name) throws UnknownHostException {
  try {
    Record [] records = new Lookup(name).run();
    if (records == null)
      throw new UnknownHostException("unknown host");
    return records;
  }
  catch (TextParseException e) {
    throw new UnknownHostException("invalid name");
  }
}

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

private static Record []
lookupHostName(String name) throws UnknownHostException {
  try {
    Record [] records = new Lookup(name).run();
    if (records == null)
      throw new UnknownHostException("unknown host");
    return records;
  }
  catch (TextParseException e) {
    throw new UnknownHostException("invalid name");
  }
}

代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi

private static Record []
lookupHostName(String name) throws UnknownHostException {
  try {
    Record [] records = new Lookup(name).run();
    if (records == null)
      throw new UnknownHostException("unknown host");
    return records;
  }
  catch (TextParseException e) {
    throw new UnknownHostException("invalid name");
  }
}

代码示例来源:origin: sensepost/yeti

public static List<String> getIpFromHost(String hostname) throws TextParseException {
  List<String> result = new ArrayList<>();
  Record[] recs = new Lookup(hostname, Type.A).run();
  if (recs != null) {
    if (recs.length > 0) {
      for (Record rec : recs) {
        String ipAddress = ((ARecord) rec).getAddress().toString();
        result.add(ipAddress.replace("/", ""));
      }
    }
  }
  return result;
}

代码示例来源: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
public List<HostService> lookup(@Nonnull String query) throws NoSuchSrvRecordException, UnknownHostException, SocketException {
  final Lookup lookup = createLookupFor(query, SRV);
  lookup.run();
  checkResult(query, lookup);
  final SRVRecord[] records = getSrvRecordsOf(lookup);
  final List<HostService> result = new ArrayList<>();
  for (final SRVRecord record : records) {
    final HostService service = toHostService(record);
    if (service != null) {
      result.add(service);
    }
  }
  return unmodifiableList(result);
}

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

/**
 * Performs a reverse DNS lookup.
 * @param addr The ip address to lookup.
 * @return The host name found for the ip address.
 */
public String
getHostByAddr(byte [] addr) throws UnknownHostException {
  Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
  Record [] records = new Lookup(name, Type.PTR).run();
  if (records == null)
    throw new UnknownHostException();
  return ((PTRRecord) records[0]).getTarget().toString();
}
}

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

/**
 * Performs a reverse DNS lookup.
 * @param addr The ip address to lookup.
 * @return The host name found for the ip address.
 */
public String
getHostByAddr(byte [] addr) throws UnknownHostException {
  Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
  Record [] records = new Lookup(name, Type.PTR).run();
  if (records == null)
    throw new UnknownHostException();
  return ((PTRRecord) records[0]).getTarget().toString();
}
}

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

/**
 * Performs a reverse DNS lookup.
 * @param addr The ip address to lookup.
 * @return The host name found for the ip address.
 */
public String
getHostByAddr(byte [] addr) throws UnknownHostException {
  Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
  Record [] records = new Lookup(name, Type.PTR).run();
  if (records == null)
    throw new UnknownHostException();
  return ((PTRRecord) records[0]).getTarget().toString();
}
}

代码示例来源:origin: no.difi.vefa/peppol-lookup

@Override
  public URI lookup(ParticipantIdentifier participantIdentifier) throws LookupException {
    // Create hostname for participant identifier.
    String hostname = hostnameGenerator.generate(participantIdentifier);

    try {
      if (new Lookup(hostname).run() == null)
        throw new LookupException(
            String.format("Identifier '%s' is not registered in SML.", participantIdentifier.getIdentifier()));
    } catch (TextParseException e) {
      throw new LookupException(e.getMessage(), e);
    }

    return URI.create(String.format("http://%s", hostname));
  }
}

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

/**
 * Determines the hostname for an address
 * @param addr The address to look up
 * @return The associated host name
 * @exception UnknownHostException There is no hostname for the address
 */
public static String
getHostName(InetAddress addr) throws UnknownHostException {
  Name name = ReverseMap.fromAddress(addr);
  Record [] records = new Lookup(name, Type.PTR).run();
  if (records == null)
    throw new UnknownHostException("unknown address");
  PTRRecord ptr = (PTRRecord) records[0];
  return ptr.getTarget().toString();
}

代码示例来源:origin: OpenNMS/opennms

/**
 * Make sure this test is FIRST.
 */
@Test
@Ignore
public void testOrderingOfLookups() throws Exception {
  //String lookup = "www.opennms.org";
  String lookup = "www.facebook.com";
  Record[] fb = new Lookup(lookup, Type.AAAA).run();
  fb = new Lookup(lookup, Type.A).run();
  assertNotNull(fb);
}

相关文章