protected void initializeDefaults() throws UnknownHostException { if (m_ports.size() == 0) { m_ports.add(Integer.valueOf(53)); } if (m_addresses.size() == 0) { m_addresses.add(Address.getByAddress("0.0.0.0")); } }
/** * Determines the IP address of a host * @param name The hostname to look up * @return The first matching IP address * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress getByName(String name) throws UnknownHostException { try { return getByAddress(name); } catch (UnknownHostException e) { Record [] records = lookupHostName(name, false); return addrFromRecord(name, records[0]); } }
/** * Determines the IP address of a host * @param name The hostname to look up * @return The first matching IP address * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress getByName(String name) throws UnknownHostException { try { return getByAddress(name); } catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); } }
/** * Gets the next token from a tokenizer and converts it to an IP Address. * @param family The address family. * @return The next token in the stream, as an InetAddress * @throws TextParseException The input was invalid or not a valid address. * @throws IOException An I/O error occurred. * @see Address */ public InetAddress getAddress(int family) throws IOException { String next = _getIdentifier("an address"); try { return Address.getByAddress(next, family); } catch (UnknownHostException e) { throw exception(e.getMessage()); } }
/** * Gets the next token from a tokenizer and converts it to an IP Address. * @param family The address family. * @return The next token in the stream, as an InetAddress * @throws TextParseException The input was invalid or not a valid address. * @throws IOException An I/O error occurred. * @see Address */ public InetAddress getAddress(int family) throws IOException { String next = _getIdentifier("an address"); try { return Address.getByAddress(next, family); } catch (UnknownHostException e) { throw exception(e.getMessage()); } }
/** * Gets the next token from a tokenizer and converts it to an IP Address. * @param family The address family. * @return The next token in the stream, as an InetAddress * @throws TextParseException The input was invalid or not a valid address. * @throws IOException An I/O error occurred. * @see Address */ public InetAddress getAddress(int family) throws IOException { String next = _getIdentifier("an address"); try { return Address.getByAddress(next, family); } catch (UnknownHostException e) { throw exception(e.getMessage()); } }
/** * Gets the next token from a tokenizer and converts it to an IP Address. * @param family The address family. * @return The next token in the stream, as an InetAddress * @throws TextParseException The input was invalid or not a valid address. * @throws IOException An I/O error occurred. * @see Address */ public InetAddress getAddress(int family) throws IOException { String next = _getIdentifier("an address"); try { return Address.getByAddress(next, family); } catch (UnknownHostException e) { throw exception(e.getMessage()); } }
/** * Determines the IP address of a host * @param name The hostname to look up * @return The first matching IP address * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress getByName(String name) throws UnknownHostException { try { return getByAddress(name); } catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); } }
/** * Determines the IP address of a host * @param name The hostname to look up * @return The first matching IP address * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress getByName(String name) throws UnknownHostException { try { return getByAddress(name); } catch (UnknownHostException e) { Record [] records = lookupHostName(name); return addrFromRecord(name, records[0]); } }
/** * Determines all IP address of a host * @param name The hostname to look up * @return All matching IP addresses * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress [] getAllByName(String name) throws UnknownHostException { try { InetAddress addr = getByAddress(name); return new InetAddress[] {addr}; } catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; } }
/** * Determines all IP address of a host * @param name The hostname to look up * @return All matching IP addresses * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress [] getAllByName(String name) throws UnknownHostException { try { InetAddress addr = getByAddress(name); return new InetAddress[] {addr}; } catch (UnknownHostException e) { Record [] records = lookupHostName(name, true); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; } }
/** * Determines all IP address of a host * @param name The hostname to look up * @return All matching IP addresses * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress [] getAllByName(String name) throws UnknownHostException { try { InetAddress addr = getByAddress(name); return new InetAddress[] {addr}; } catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; } }
/** * Determines all IP address of a host * @param name The hostname to look up * @return All matching IP addresses * @exception UnknownHostException The hostname does not have any addresses */ public static InetAddress [] getAllByName(String name) throws UnknownHostException { try { InetAddress addr = getByAddress(name); return new InetAddress[] {addr}; } catch (UnknownHostException e) { Record [] records = lookupHostName(name); InetAddress [] addrs = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) addrs[i] = addrFromRecord(name, records[i]); return addrs; } }
@Override public InetAddress getByName(String host) throws UnknownHostException { TimeMetric timeMetric = metricFactory.timer("getByName"); String name = allowIPLiteral(host); try { // Check if its local if (name.equalsIgnoreCase(localHostName) || name.equalsIgnoreCase(localCanonicalHostName) || name.equals(localAddress)) { return getLocalHost(); } return org.xbill.DNS.Address.getByAddress(name); } catch (UnknownHostException e) { Record[] records = lookupNoException(name, Type.A, "A"); if (records != null && records.length >= 1) { ARecord a = (ARecord) records[0]; return InetAddress.getByAddress(name, a.getAddress().getAddress()); } else { throw e; } } finally { timeMetric.stopAndPublish(); } }
@Override public InetAddress getByName(String host) throws UnknownHostException { TimeMetric timeMetric = metricFactory.timer("getByName"); String name = allowIPLiteral(host); try { // Check if its local if (name.equalsIgnoreCase(localHostName) || name.equalsIgnoreCase(localCanonicalHostName) || name.equals(localAddress)) { return getLocalHost(); } return org.xbill.DNS.Address.getByAddress(name); } catch (UnknownHostException e) { Record[] records = lookupNoException(name, Type.A, "A"); if (records != null && records.length >= 1) { ARecord a = (ARecord) records[0]; return InetAddress.getByAddress(name, a.getAddress().getAddress()); } else { throw e; } } finally { timeMetric.stopAndPublish(); } }
@Nullable protected InetAddress toInetAddress(@Nonnull SRVRecord record) { final String name = record.getTarget().toString(); InetAddress address; try { address = getByAddress(name); } catch (final UnknownHostException ignored) { final Record [] records = createLookupFor(name, Type.A).run(); if (records != null && records.length > 0) { address = toInetAddress(name, (ARecord) records[0]); } else { address = null; } } return address; }
void rdataFromString(Tokenizer st, Name origin) throws IOException { prefixBits = st.getUInt8(); if (prefixBits > 128) { throw st.exception("prefix bits must be [0..128]"); } else if (prefixBits < 128) { String s = st.getString(); try { suffix = Address.getByAddress(s, Address.IPv6); } catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); } } if (prefixBits > 0) prefix = st.getName(origin); }
void rdataFromString(Tokenizer st, Name origin) throws IOException { prefixBits = st.getUInt8(); if (prefixBits > 128) { throw st.exception("prefix bits must be [0..128]"); } else if (prefixBits < 128) { String s = st.getString(); try { suffix = Address.getByAddress(s, Address.IPv6); } catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); } } if (prefixBits > 0) prefix = st.getName(origin); }
void rdataFromString(Tokenizer st, Name origin) throws IOException { prefixBits = st.getUInt8(); if (prefixBits > 128) { throw st.exception("prefix bits must be [0..128]"); } else if (prefixBits < 128) { String s = st.getString(); try { suffix = Address.getByAddress(s, Address.IPv6); } catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); } } if (prefixBits > 0) prefix = st.getName(origin); }
void rdataFromString(Tokenizer st, Name origin) throws IOException { prefixBits = st.getUInt8(); if (prefixBits > 128) { throw st.exception("prefix bits must be [0..128]"); } else if (prefixBits < 128) { String s = st.getString(); try { suffix = Address.getByAddress(s, Address.IPv6); } catch (UnknownHostException e) { throw st.exception("invalid IPv6 address: " + s); } } if (prefixBits > 0) prefix = st.getName(origin); }