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()); } } }
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
public DNSRequest(final String hostname, final int recordType) throws NoneException { if (recordType == MX || recordType == A || recordType == AAAA) { try { Name.fromString(hostname); } catch (TextParseException e) { throw new NoneException(e.getMessage()); } } this.hostname = hostname; this.recordType = recordType; }
public DNSRequest(final String hostname, final int recordType) throws NoneException { if (recordType == MX || recordType == A || recordType == AAAA) { try { Name.fromString(hostname); } catch (TextParseException e) { throw new NoneException(e.getMessage()); } } this.hostname = hostname; this.recordType = recordType; }
private Record nextGenerated() throws IOException { try { return generator.nextRecord(); } catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); } catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); } }
private Record nextGenerated() throws IOException { try { return generator.nextRecord(); } catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); } catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); } }
private Record nextGenerated() throws IOException { try { return generator.nextRecord(); } catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); } catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); } }
private Record nextGenerated() throws IOException { try { return generator.nextRecord(); } catch (Tokenizer.TokenizerException e) { throw st.exception("Parsing $GENERATE: " + e.getBaseMessage()); } catch (TextParseException e) { throw st.exception("Parsing $GENERATE: " + e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { priority = st.getUInt16(); weight = st.getUInt16(); try { target = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { cpu = byteArrayFromString(st.getString()); os = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { cpu = byteArrayFromString(st.getString()); os = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { cpu = byteArrayFromString(st.getString()); os = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { try { cpu = byteArrayFromString(st.getString()); os = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { flags = st.getUInt8(); try { tag = byteArrayFromString(st.getString()); value = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { order = st.getUInt16(); preference = st.getUInt16(); try { flags = byteArrayFromString(st.getString()); service = byteArrayFromString(st.getString()); regexp = byteArrayFromString(st.getString()); } catch (TextParseException e) { throw st.exception(e.getMessage()); } replacement = st.getName(origin); }