public final class DohResolver extends Object implements Resolver
Resolver
using e.g. OkHttp.
On Java 8, it uses HTTP/1.1, which is against the recommendation of RFC 8484 to use HTTP/2 and thus slower. On Java 11 or newer, HTTP/2 is always used, but the built-in HttpClient has its own issues with connection handling.
As of 2020-09-13, the following limits of public resolvers for HTTP/2 were observed:
Constructor and Description |
---|
DohResolver(String uriTemplate)
Creates a new DoH resolver that performs lookups with HTTP GET and the default timeout (5s).
|
DohResolver(String uriTemplate,
int maxConcurrentRequests,
Duration idleConnectionTimeout)
Creates a new DoH resolver that performs lookups with HTTP GET and the default timeout (5s).
|
Modifier and Type | Method and Description |
---|---|
Executor |
getExecutor()
Deprecated.
not applicable if
sendAsync(Message, Executor) is used. |
Duration |
getTimeout()
Gets the amount of time to wait for a response before giving up.
|
String |
getUriTemplate()
Gets the current URI used for resolving.
|
boolean |
isUsePost()
Returns
true if the HTTP method POST to resolve, false if GET is used. |
CompletionStage<Message> |
sendAsync(Message query)
Asynchronously sends a message using the default
ForkJoinPool.commonPool() . |
CompletionStage<Message> |
sendAsync(Message query,
Executor executor)
Asynchronously sends a message.
|
void |
setEDNS(int version,
int payloadSize,
int flags,
List<EDNSOption> options)
Sets the EDNS information on outgoing messages.
|
void |
setExecutor(Executor executor)
Deprecated.
|
void |
setIgnoreTruncation(boolean flag)
Not implemented.
|
void |
setPort(int port)
Not implemented.
|
void |
setTCP(boolean flag)
Not implemented.
|
void |
setTimeout(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
|
void |
setUriTemplate(String uriTemplate)
Sets the URI to use for resolving, e.g.
|
void |
setUsePost(boolean usePost)
Sets the HTTP method to use for resolving.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
send, sendAsync, setEDNS, setEDNS, setTimeout, setTimeout
public DohResolver(String uriTemplate)
uriTemplate
- the URI to use for resolving, e.g. https://dns.google/dns-query
public DohResolver(String uriTemplate, int maxConcurrentRequests, Duration idleConnectionTimeout)
uriTemplate
- the URI to use for resolving, e.g. https://dns.google/dns-query
maxConcurrentRequests
- Maximum concurrent HTTP/2 streams for Java 11+ or HTTP/1.1
connections for Java 8. On Java 8 this cannot exceed the system property http.maxConnections
.idleConnectionTimeout
- Max. idle time for HTTP/2 connections until a request is
serialized. Applies to Java 11+ only.public void setPort(int port)
setUriTemplate(String)
if required.public void setTCP(boolean flag)
public void setIgnoreTruncation(boolean flag)
setIgnoreTruncation
in interface Resolver
flag
- Indicates whether truncated responses should be ignored.public void setEDNS(int version, int payloadSize, int flags, List<EDNSOption> options)
public void setTSIGKey(TSIG key)
Resolver
setTSIGKey
in interface Resolver
key
- The keypublic void setTimeout(Duration timeout)
Resolver
setTimeout
in interface Resolver
timeout
- The amount of time to wait.public Duration getTimeout()
Resolver
getTimeout
in interface Resolver
Resolver.setTimeout(Duration)
public CompletionStage<Message> sendAsync(Message query)
Resolver
ForkJoinPool.commonPool()
.
The default implementation calls the deprecated Resolver.sendAsync(Message,
ResolverListener)
. Implementors must override at least one of the sendAsync
methods or
a stack overflow will occur.
public CompletionStage<Message> sendAsync(Message query, Executor executor)
Resolver
The default implementation calls the deprecated Resolver.sendAsync(Message,
ResolverListener)
. Implementors must override at least one of the sendAsync
methods or
a stack overflow will occur.
public boolean isUsePost()
true
if the HTTP method POST to resolve, false
if GET is used.public void setUsePost(boolean usePost)
usePost
- true
to use POST, false
to use GET (the default).public String getUriTemplate()
public void setUriTemplate(String uriTemplate)
https://dns.google/dns-query
@Deprecated public Executor getExecutor()
sendAsync(Message, Executor)
is used.Executor
for request handling, defaults to ForkJoinPool.commonPool()
.@Deprecated public void setExecutor(Executor executor)
sendAsync(Message, Executor)
.Executor
for request handling.executor
- The new Executor
, can be null
(which is equivalent to ForkJoinPool.commonPool()
).Copyright © 2022 dnsjava.org. All rights reserved.