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 it's 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()
Gets the
Executor for HTTP/2 requests. |
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.
|
void |
setEDNS(int version,
int payloadSize,
int flags,
List<EDNSOption> options)
Sets the EDNS information on outgoing messages.
|
void |
setExecutor(Executor executor)
Gets the
Executor for HTTP/2 requests. |
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, waitsend, sendAsync, setEDNS, setEDNS, setTimeout, setTimeoutpublic DohResolver(String uriTemplate)
uriTemplate - the URI to use for resolving, e.g. https://dns.google/dns-querypublic DohResolver(String uriTemplate, int maxConcurrentRequests, Duration idleConnectionTimeout)
uriTemplate - the URI to use for resolving, e.g. https://dns.google/dns-querymaxConcurrentRequests - 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 Resolverflag - Indicates whether truncated responses should be ignored.public void setEDNS(int version,
int payloadSize,
int flags,
List<EDNSOption> options)
public void setTSIGKey(TSIG key)
ResolversetTSIGKey in interface Resolverkey - The keypublic void setTimeout(Duration timeout)
ResolversetTimeout in interface Resolvertimeout - The amount of time to wait.public Duration getTimeout()
ResolvergetTimeout in interface ResolverResolver.setTimeout(Duration)public CompletionStage<Message> sendAsync(Message query)
ResolverThe 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-querypublic Executor getExecutor()
Executor for HTTP/2 requests. Only applicable on Java 11+ and default to
ForkJoinPool.commonPool().public void setExecutor(Executor executor)
Executor for HTTP/2 requests. Only applicable on Java 11+executor - The new Executor, can be null to restore the HttpClient default
behavior.Copyright © 2021 dnsjava.org. All rights reserved.