本文整理了Java中org.xbill.DNS.Address.getByAddress()
方法的一些代码示例,展示了Address.getByAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getByAddress()
方法的具体详情如下:
包路径:org.xbill.DNS.Address
类名称:Address
方法名:getByAddress
暂无
代码示例来源:origin: OpenNMS/opennms
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"));
}
}
代码示例来源:origin: dnsjava/dnsjava
/**
* 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]);
}
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
/**
* 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]);
}
}
代码示例来源:origin: tiandawu/IotXmpp
/**
* 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());
}
}
代码示例来源:origin: dnsjava/dnsjava
/**
* 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());
}
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
/**
* 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());
}
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* 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());
}
}
代码示例来源:origin: tiandawu/IotXmpp
/**
* 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]);
}
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* 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]);
}
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
/**
* 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;
}
}
代码示例来源:origin: dnsjava/dnsjava
/**
* 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;
}
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* 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;
}
}
代码示例来源:origin: tiandawu/IotXmpp
/**
* 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;
}
}
代码示例来源:origin: apache/james-project
@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();
}
}
代码示例来源:origin: org.apache.james/james-server-dnsservice-dnsjava
@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();
}
}
代码示例来源:origin: org.echocat.jomon.net/common
@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;
}
代码示例来源:origin: dnsjava/dnsjava
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);
}
代码示例来源:origin: org.littleshoot/dnsjava
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);
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
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);
}
代码示例来源:origin: tiandawu/IotXmpp
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);
}
内容来源于网络,如有侵权,请联系作者删除!