public class DnsClient extends Object
Constructor and Description |
---|
DnsClient(long queryTimeout)
Creates a new DNS client with the given query timeout.
|
DnsClient(long queryTimeout,
long requestTimeout)
Creates a new DNS client with the given query and request timeout.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
allIpAddressesValid(String ipAddresses) |
String |
getInverseAddressFormat(String ipAddress) |
static boolean |
isHostName(String hostName) |
static boolean |
isIp4Address(String ipAddress) |
static boolean |
isIp6Address(String ipAddress) |
static void |
parseReverseLookupDomain(PtrDnsAnswer.Builder dnsAnswerBuilder,
String hostname)
Extract the domain name (without subdomain).
|
List<ADnsAnswer> |
resolveIPv4AddressForHostname(String hostName,
boolean includeIpVersion) |
List<ADnsAnswer> |
resolveIPv6AddressForHostname(String hostName,
boolean includeIpVersion) |
PtrDnsAnswer |
reverseLookup(String ipAddress) |
void |
start(String dnsServerIps) |
void |
stop() |
List<TxtDnsAnswer> |
txtLookup(String hostName) |
public DnsClient(long queryTimeout)
DEFAULT_REQUEST_TIMEOUT_INCREMENT
.queryTimeout
- the query timeoutDnsClient(long, long)
public DnsClient(long queryTimeout, long requestTimeout)
DnsNameResolver
is closed, and the event loop is shut down while
a resolver request is still running.queryTimeout
- the query timeoutrequestTimeout
- the request timeoutpublic void start(String dnsServerIps)
public void stop()
public List<ADnsAnswer> resolveIPv4AddressForHostname(String hostName, boolean includeIpVersion) throws InterruptedException, ExecutionException, UnknownHostException
public List<ADnsAnswer> resolveIPv6AddressForHostname(String hostName, boolean includeIpVersion) throws InterruptedException, ExecutionException, UnknownHostException
public PtrDnsAnswer reverseLookup(String ipAddress) throws InterruptedException, ExecutionException
public static void parseReverseLookupDomain(PtrDnsAnswer.Builder dnsAnswerBuilder, String hostname)
InternetDomainName
implementation
provides a method to correctly handle this (and handles special cases for TLDs with multiple
names. eg. for lb01.store.amazon.co.uk, only amazon.co.uk would be extracted).
It uses https://publicsuffix.org behind the scenes.
Some domains (eg. completely randomly defined PTR domains) are not considered to have a public suffix according to Guava. For those, the only option is to manually extract the domain with string operations. This should be a rare case.
public List<TxtDnsAnswer> txtLookup(String hostName) throws InterruptedException, ExecutionException
public static boolean isHostName(String hostName)
public static boolean isIp4Address(String ipAddress)
public static boolean isIp6Address(String ipAddress)
public static boolean allIpAddressesValid(String ipAddresses)
ipAddresses
- A comma-separated list of IP addressesCopyright © 2012–2021 Graylog, Inc.. All rights reserved.