Package org.xbill.DNS
Class SimpleResolver
java.lang.Object
org.xbill.DNS.SimpleResolver
- All Implemented Interfaces:
Resolver
An implementation of Resolver that sends one query to one server. SimpleResolver handles TCP
retries, transaction security (TSIG), and EDNS 0.
- Author:
- Brian Wellington
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default EDNS payload sizestatic final intThe default port to send queries to -
Constructor Summary
ConstructorsConstructorDescriptionCreates a SimpleResolver.SimpleResolver(String hostname) Creates a SimpleResolver that will query the specified hostSimpleResolver(InetAddress host) Creates a SimpleResolver that will query the specified hostCreates a SimpleResolver that will query the specified host -
Method Summary
Modifier and TypeMethodDescriptionGets the destination address associated with this SimpleResolver.getEDNS()Gets the EDNS information on outgoing messages.booleanGets whether truncated responses will be ignored.Gets or sets the factory that creates clients for sending messages to the wire.intgetPort()Gets the port to communicate with on the serverbooleangetTCP()Gets whether TCP connections will be used by defaultGets the amount of time to wait for a response before giving up.Get the TSIG key that messages will be signed with.Asynchronously sends a message to a single server.Asynchronously sends a message to a single server.voidsetAddress(InetAddress addr) Sets the address of the server to communicate with (on the default DNS port)voidsetAddress(InetSocketAddress addr) Sets the address of the server to communicate with.static voidsetDefaultResolver(String hostname) Sets the default host (initially localhost) to querystatic voidsetDefaultResolver(InetSocketAddress hostname) Sets the default host (initially localhost) to queryvoidsetEDNS(int version, int payloadSize, int flags, List<EDNSOption> options) Sets the EDNS information on outgoing messages.voidSets the EDNS information on outgoing messages.voidsetIgnoreTruncation(boolean flag) Sets whether truncated responses will be ignored.voidsetIoClientFactory(IoClientFactory ioClientFactory) Gets or sets the factory that creates clients for sending messages to the wire.voidsetLocalAddress(InetAddress addr) Sets the local address to bind to when sending messages.voidSets the local address to bind to when sending messages.voidsetPort(int port) Sets the port to communicate with on the servervoidsetTCP(boolean flag) Sets whether TCP connections will be used by defaultvoidsetTimeout(Duration timeout) Sets the amount of time to wait for a response before giving up.voidsetTSIGKey(TSIG key) Specifies the TSIG key that messages will be signed withtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.xbill.DNS.Resolver
send, sendAsync, setEDNS, setEDNS, setTimeout, setTimeout
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default port to send queries to- See Also:
-
DEFAULT_EDNS_PAYLOADSIZE
public static final int DEFAULT_EDNS_PAYLOADSIZEThe default EDNS payload size- See Also:
-
-
Constructor Details
-
SimpleResolver
Creates a SimpleResolver. The host to query is either found by using ResolverConfig, or the default host is used.- Throws:
UnknownHostException- Failure occurred while finding the host- See Also:
-
SimpleResolver
Creates a SimpleResolver that will query the specified host- Throws:
UnknownHostException- Failure occurred while finding the host
-
SimpleResolver
Creates a SimpleResolver that will query the specified host -
SimpleResolver
Creates a SimpleResolver that will query the specified host
-
-
Method Details
-
getAddress
Gets the destination address associated with this SimpleResolver. Messages sent using this SimpleResolver will be sent to this address.- Returns:
- The destination address associated with this SimpleResolver.
-
setDefaultResolver
Sets the default host (initially localhost) to query -
setDefaultResolver
Sets the default host (initially localhost) to query -
getPort
public int getPort()Gets the port to communicate with on the server- Since:
- 3.2
-
setPort
public void setPort(int port) Description copied from interface:ResolverSets the port to communicate with on the server -
setAddress
Sets the address of the server to communicate with.- Parameters:
addr- The address of the DNS server
-
setAddress
Sets the address of the server to communicate with (on the default DNS port)- Parameters:
addr- The address of the DNS server
-
setLocalAddress
Sets the local address to bind to when sending messages.- Parameters:
addr- The local address to send messages from.
-
setLocalAddress
Sets the local address to bind to when sending messages. A random port will be used.- Parameters:
addr- The local address to send messages from.
-
getTCP
public boolean getTCP()Gets whether TCP connections will be used by default- Since:
- 3.2
-
setTCP
public void setTCP(boolean flag) Description copied from interface:ResolverSets whether TCP connections will be used by default -
getIgnoreTruncation
public boolean getIgnoreTruncation()Gets whether truncated responses will be ignored.- Since:
- 3.2
-
setIgnoreTruncation
public void setIgnoreTruncation(boolean flag) Description copied from interface:ResolverSets whether truncated responses will be ignored. If not, a truncated response over UDP will cause a retransmission over TCP.- Specified by:
setIgnoreTruncationin interfaceResolver- Parameters:
flag- Indicates whether truncated responses should be ignored.
-
getEDNS
Gets the EDNS information on outgoing messages.- Returns:
- The current
OPTRecordfor EDNS ornullif EDNS is disabled. - Since:
- 3.2
-
setEDNS
Sets the EDNS information on outgoing messages.- Parameters:
optRecord- theOPTRecordfor EDNS options or null to disable EDNS.- Since:
- 3.2
- See Also:
-
setEDNS
Description copied from interface:ResolverSets the EDNS information on outgoing messages.- Specified by:
setEDNSin interfaceResolver- Parameters:
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.- See Also:
-
getTSIGKey
Get the TSIG key that messages will be signed with.- Returns:
- the TSIG signature for outgoing messages or
nullif not specified. - Since:
- 3.2
-
setTSIGKey
Description copied from interface:ResolverSpecifies the TSIG key that messages will be signed with- Specified by:
setTSIGKeyin interfaceResolver- Parameters:
key- The key
-
setTimeout
Description copied from interface:ResolverSets the amount of time to wait for a response before giving up.- Specified by:
setTimeoutin interfaceResolver- Parameters:
timeout- The amount of time to wait.
-
getTimeout
Description copied from interface:ResolverGets the amount of time to wait for a response before giving up.- Specified by:
getTimeoutin interfaceResolver- See Also:
-
sendAsync
Asynchronously sends a message to a single server. -
sendAsync
Asynchronously sends a message to a single server. -
toString
-
getIoClientFactory
Gets or sets the factory that creates clients for sending messages to the wire.- Since:
- 3.6
-
setIoClientFactory
Gets or sets the factory that creates clients for sending messages to the wire.- Since:
- 3.6
-