Modifier and Type | Field and Description |
---|---|
private java.net.InetSocketAddress |
address |
static int |
DEFAULT_EDNS_PAYLOADSIZE
The default EDNS payload size
|
static int |
DEFAULT_PORT
The default port to send queries to
|
private static short |
DEFAULT_UDPSIZE |
private static java.net.InetSocketAddress |
defaultResolver |
private boolean |
ignoreTruncation |
private java.net.InetSocketAddress |
localAddress |
private OPTRecord |
queryOPT |
private java.time.Duration |
timeoutValue |
private TSIG |
tsig |
private boolean |
useTCP |
Constructor and Description |
---|
SimpleResolver()
Creates a SimpleResolver.
|
SimpleResolver(java.net.InetAddress host)
Creates a SimpleResolver that will query the specified host
|
SimpleResolver(java.net.InetSocketAddress host)
Creates a SimpleResolver that will query the specified host
|
SimpleResolver(java.lang.String hostname)
Creates a SimpleResolver that will query the specified host
|
Modifier and Type | Method and Description |
---|---|
private void |
applyEDNS(Message query) |
java.net.InetSocketAddress |
getAddress()
Gets the destination address associated with this SimpleResolver.
|
OPTRecord |
getEDNS()
Gets the EDNS information on outgoing messages.
|
boolean |
getIgnoreTruncation()
Gets whether truncated responses will be ignored.
|
int |
getPort()
Gets the port to communicate with on the server
|
boolean |
getTCP()
Gets whether TCP connections will be used by default
|
java.time.Duration |
getTimeout()
Gets the amount of time to wait for a response before giving up.
|
TSIG |
getTSIGKey()
Get the TSIG key that messages will be signed with.
|
private int |
maxUDPSize(Message query) |
private Message |
parseMessage(byte[] b) |
java.util.concurrent.CompletionStage<Message> |
sendAsync(Message query)
Asynchronously sends a message to a single server.
|
(package private) java.util.concurrent.CompletableFuture<Message> |
sendAsync(Message query,
boolean forceTcp,
java.util.concurrent.Executor executor) |
java.util.concurrent.CompletionStage<Message> |
sendAsync(Message query,
java.util.concurrent.Executor executor)
Asynchronously sends a message to a single server.
|
private Message |
sendAXFR(Message query) |
void |
setAddress(java.net.InetAddress addr)
Sets the address of the server to communicate with (on the default DNS port)
|
void |
setAddress(java.net.InetSocketAddress addr)
Sets the address of the server to communicate with.
|
static void |
setDefaultResolver(java.net.InetSocketAddress hostname)
Sets the default host (initially localhost) to query
|
static void |
setDefaultResolver(java.lang.String hostname)
Sets the default host (initially localhost) to query
|
void |
setEDNS(int version,
int payloadSize,
int flags,
java.util.List<EDNSOption> options)
Sets the EDNS information on outgoing messages.
|
void |
setEDNS(OPTRecord optRecord)
Sets the EDNS information on outgoing messages.
|
void |
setIgnoreTruncation(boolean flag)
Sets whether truncated responses will be ignored.
|
void |
setLocalAddress(java.net.InetAddress addr)
Sets the local address to bind to when sending messages.
|
void |
setLocalAddress(java.net.InetSocketAddress addr)
Sets the local address to bind to when sending messages.
|
void |
setPort(int port)
Sets the port to communicate with on the server
|
void |
setTCP(boolean flag)
Sets whether TCP connections will be used by default
|
void |
setTimeout(java.time.Duration timeout)
Sets the amount of time to wait for a response before giving up.
|
void |
setTSIGKey(TSIG key)
Specifies the TSIG key that messages will be signed with
|
java.lang.String |
toString() |
private void |
verifyTSIG(Message query,
Message response,
byte[] b) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
send, sendAsync, setEDNS, setEDNS, setTimeout, setTimeout
public static final int DEFAULT_PORT
public static final int DEFAULT_EDNS_PAYLOADSIZE
private java.net.InetSocketAddress address
private java.net.InetSocketAddress localAddress
private boolean useTCP
private boolean ignoreTruncation
private OPTRecord queryOPT
private TSIG tsig
private java.time.Duration timeoutValue
private static final short DEFAULT_UDPSIZE
private static java.net.InetSocketAddress defaultResolver
public SimpleResolver() throws java.net.UnknownHostException
java.net.UnknownHostException
- Failure occurred while finding the hostResolverConfig
public SimpleResolver(java.lang.String hostname) throws java.net.UnknownHostException
java.net.UnknownHostException
- Failure occurred while finding the hostpublic SimpleResolver(java.net.InetSocketAddress host)
public SimpleResolver(java.net.InetAddress host)
public java.net.InetSocketAddress getAddress()
public static void setDefaultResolver(java.net.InetSocketAddress hostname)
public static void setDefaultResolver(java.lang.String hostname)
public int getPort()
public void setPort(int port)
Resolver
public void setAddress(java.net.InetSocketAddress addr)
addr
- The address of the DNS serverpublic void setAddress(java.net.InetAddress addr)
addr
- The address of the DNS serverpublic void setLocalAddress(java.net.InetSocketAddress addr)
addr
- The local address to send messages from.public void setLocalAddress(java.net.InetAddress addr)
addr
- The local address to send messages from.public boolean getTCP()
public void setTCP(boolean flag)
Resolver
public boolean getIgnoreTruncation()
public void setIgnoreTruncation(boolean flag)
Resolver
setIgnoreTruncation
in interface Resolver
flag
- Indicates whether truncated responses should be ignored.public OPTRecord getEDNS()
OPTRecord
for EDNS or null
if EDNS is disabled.public void setEDNS(OPTRecord optRecord)
optRecord
- the OPTRecord
for EDNS options or null to disable EDNS.setEDNS(int, int, int, List)
public void setEDNS(int version, int payloadSize, int flags, java.util.List<EDNSOption> options)
Resolver
setEDNS
in interface Resolver
version
- The EDNS version to use. 0 indicates EDNS0 and -1 indicates no EDNS.payloadSize
- The maximum DNS packet size that this host is capable of receiving over UDP.
If 0 is specified, the default (1280) is used.flags
- EDNS extended flags to be set in the OPT record.options
- EDNS options to be set in the OPT record, specified as a List of
OPTRecord.Option elements.OPTRecord
public TSIG getTSIGKey()
null
if not specified.public void setTSIGKey(TSIG key)
Resolver
setTSIGKey
in interface Resolver
key
- The keypublic void setTimeout(java.time.Duration timeout)
Resolver
setTimeout
in interface Resolver
timeout
- The amount of time to wait.public java.time.Duration getTimeout()
Resolver
getTimeout
in interface Resolver
Resolver.setTimeout(Duration)
private Message parseMessage(byte[] b) throws WireParseException
WireParseException
private void applyEDNS(Message query)
private int maxUDPSize(Message query)
public java.util.concurrent.CompletionStage<Message> sendAsync(Message query)
public java.util.concurrent.CompletionStage<Message> sendAsync(Message query, java.util.concurrent.Executor executor)
java.util.concurrent.CompletableFuture<Message> sendAsync(Message query, boolean forceTcp, java.util.concurrent.Executor executor)
private Message sendAXFR(Message query) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object