Lookup lookup; try { lookup = new Lookup(host, type, DClass.IN); } catch (TextParseException e) { return Collections.emptyList();
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()); } } }
public LookupAdapter(Name name, int type){ lu = new org.xbill.DNS.Lookup(name, type); }
@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"); } }
@Override public Lookup forName(String fqdn) { try { return new Lookup(fqdn, Type.SRV, DClass.IN); } catch (TextParseException e) { throw new DnsException("unable to create lookup for name: " + fqdn, e); } } }
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 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; }
@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); } } }
/** * 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)); } }