records = lookup.run(); retryCount++; } while (lookup.getResult() == Lookup.TRY_AGAIN && retryCount < DNS_NETWORK_FAILURE_RETRY_COUNT);
rrecordSet = (new Lookup(lookupName, TypeType, ClassType)).run(); } catch (TextParseException e) { rrecordSet = null;
@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; }
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; }
/** * 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()); } }
/** * 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()); } } }
@Override public Record[] run() { return lu.run(); }
@Override public Record[] call() throws Exception { return new Lookup(name, type).run(); } }
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"); } }
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"); } }
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"); } }
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; }
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); }
@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); }
/** * 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(); } }
/** * 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(); } }
/** * 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(); } }
@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)); } }
/** * 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(); }