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; }
private static TextParseException parseException(String str, String message) { return new TextParseException("'" + str + "': " + message); }
public void receiveRecord(final Object id, final Record record) { if (record.getTTL() > 0) { if (record.getType() == Type.PTR) { String value = ((PTRRecord) record).getTarget().toString(); if (!value.endsWith(".")) { value += "."; } // Check if domain is already in the list, add if not, otherwise manipulate booleans. try { domains.add(new Domain(new Name(value))); } catch (TextParseException e) { e.printStackTrace(System.err); } } } } });
public static boolean isWildCard(String domain) { if (domain != null && !domain.isEmpty()) { try { String subDomain = String.format("%s.%s", ConfigSettings.getWildCardSubdomain(), domain); if (ForwardLookupHelper.getARecord(subDomain, domain) == null) { return false; } } catch (TextParseException ex) { Log.debug(ex.toString()); } } return true; } }
Log.debug("Exception EX1: [" + domainName + "] : " + ex.toString());
/** * 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()); } }
private static TextParseException parseException(String str, String message) { return new TextParseException("'" + str + "': " + message); }
/** * 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 static TextParseException parseException(String str, String message) { return new TextParseException("'" + str + "': " + message); }
protected TXTBase(Name name, int type, int dclass, long ttl, List strings) { super(name, type, dclass, ttl); if (strings == null) throw new IllegalArgumentException("strings must not be null"); this.strings = new ArrayList(strings.size()); Iterator it = strings.iterator(); try { while (it.hasNext()) { String s = (String) it.next(); this.strings.add(byteArrayFromString(s)); } } catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
private static TextParseException parseException(String str, String message) { return new TextParseException("'" + str + "': " + message); }
protected TXTBase(Name name, int type, int dclass, long ttl, List strings) { super(name, type, dclass, ttl); if (strings == null) throw new IllegalArgumentException("strings must not be null"); this.strings = new ArrayList(strings.size()); Iterator it = strings.iterator(); try { while (it.hasNext()) { String s = (String) it.next(); this.strings.add(byteArrayFromString(s)); } } catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
throw new TextParseException("text string too long"); intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long");
protected TXTBase(Name name, int type, int dclass, long ttl, List strings) { super(name, type, dclass, ttl); if (strings == null) throw new IllegalArgumentException("strings must not be null"); this.strings = new ArrayList(strings.size()); Iterator it = strings.iterator(); try { while (it.hasNext()) { String s = (String) it.next(); this.strings.add(byteArrayFromString(s)); } } catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
throw new TextParseException("text string too long"); intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long");
protected TXTBase(Name name, int type, int dclass, long ttl, List strings) { super(name, type, dclass, ttl); if (strings == null) throw new IllegalArgumentException("strings must not be null"); this.strings = new ArrayList(strings.size()); Iterator it = strings.iterator(); try { while (it.hasNext()) { String s = (String) it.next(); this.strings.add(byteArrayFromString(s)); } } catch (TextParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
throw new TextParseException("text string too long"); intval += (b - '0'); if (intval > 255) throw new TextParseException ("bad escape"); if (digits < 3) throw new TextParseException("bad escape"); os.write(b); escaped = false; throw new TextParseException("bad escape"); array = os.toByteArray(); if (array.length > 255) { throw new TextParseException("text string too long");
private Name parseName(String s, Name origin) throws TextParseException { try { return Name.fromString(s, origin); } catch (TextParseException e) { throw st.exception(e.getMessage()); } }