Class DnsQueryContext
java.lang.Object
io.netty.resolver.dns.DnsQueryContext
- Direct Known Subclasses:
DatagramDnsQueryContext, TcpDnsQueryContext
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DnsRecord[]private final Channelprivate final byte[]private final booleanprivate intprivate static final longprivate static final InternalLoggerprivate final InetSocketAddressprivate final DnsRecordprivate final Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> private final DnsQueryProtectionprivate final DnsQueryContextManagerprivate final longprivate final DnsQuestionprivate final booleanprivate final booleanprivate final Bootstrapprivate static final TcpDnsQueryEncoderprivate Future<?> private final DnsQuestion -
Constructor Summary
ConstructorsConstructorDescriptionDnsQueryContext(Channel channel, InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsQuestion wireQuestion, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout, DnsQueryProtection protection) -
Method Summary
Modifier and TypeMethodDescription(package private) final booleanfinishFailure(String message, Throwable cause, boolean timeout) Notifies the originalPromisethat the query completes because of an failure.private voidfinishOriginal(Object originalResult, Future<?> future) (package private) voidfinishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated) Notifies the originalPromisethat the response for the query was received.private voidfinishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated, boolean validateCookie) private static booleanhasOptRecord(DnsRecord[] additionals) (package private) final booleanisDone()Returnstrueif the query was completed already.private booleanmatchesQuestion(Object responseQuestion) protected abstract DnsQuerynewQuery(int id, InetSocketAddress nameServerAddr) Creates and returns a newDnsQuery.private voidonQueryWriteCompletion(long queryTimeoutMillis, ChannelFuture writeFuture) protected abstract Stringprotocol()Returns the protocol that is used for the query.(package private) final DnsQuestionquestion()Returns theDnsQuestionthat will be written as part of theDnsQuery.private voidremoveFromContextManager(InetSocketAddress nameServerAddr) private booleanretryWithTcp(Object originalResult) Retry the original query with TCP if possible.private ChannelFutureprivate booleantrySuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope) private boolean(package private) final DnsQuestionReturns theDnsQuestionthat is written to the wire.(package private) final ChannelFuturewriteQuery(boolean flush) Write the query and return theChannelFuturethat is completed once the write completes.private voidwriteQuery(DnsQuery query, boolean flush, ChannelPromise promise)
-
Field Details
-
logger
-
ID_REUSE_ON_TIMEOUT_DELAY_MILLIS
private static final long ID_REUSE_ON_TIMEOUT_DELAY_MILLIS -
TCP_ENCODER
-
channel
-
nameServerAddr
-
queryContextManager
-
promise
-
question
-
wireQuestion
-
exactCaseMatch
private final boolean exactCaseMatch -
additionals
-
optResource
-
protection
-
clientCookie
private final byte[] clientCookie -
recursionDesired
private final boolean recursionDesired -
socketBootstrap
-
retryWithTcpOnTimeout
private final boolean retryWithTcpOnTimeout -
queryTimeoutMillis
private final long queryTimeoutMillis -
timeoutFuture
-
id
private int id
-
-
Constructor Details
-
DnsQueryContext
DnsQueryContext(Channel channel, InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsQuestion wireQuestion, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise, Bootstrap socketBootstrap, boolean retryWithTcpOnTimeout, DnsQueryProtection protection)
-
-
Method Details
-
hasOptRecord
-
isDone
final boolean isDone()Returnstrueif the query was completed already.- Returns:
trueif done.
-
question
Returns theDnsQuestionthat will be written as part of theDnsQuery.- Returns:
- the question.
-
wireQuestion
Returns theDnsQuestionthat is written to the wire. This may differ in case fromquestion().- Returns:
- the question.
-
newQuery
Creates and returns a newDnsQuery.- Parameters:
id- the transaction id to use.nameServerAddr- the nameserver to which the query will be send.- Returns:
- the new query.
-
protocol
Returns the protocol that is used for the query.- Returns:
- the protocol.
-
writeQuery
Write the query and return theChannelFuturethat is completed once the write completes.- Parameters:
flush-trueifChannel.flush()should be called as well.- Returns:
- the
ChannelFuturethat is notified once once the write completes.
-
removeFromContextManager
-
sendQuery
-
writeQuery
-
onQueryWriteCompletion
-
finishSuccess
void finishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated) Notifies the originalPromisethat the response for the query was received. This method takes ownership of passedAddressedEnvelope. -
finishSuccess
private void finishSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope, boolean truncated, boolean validateCookie) - Parameters:
validateCookie-falseif the response was received via a different, already authenticated, transport (like TCP) and so does not carry a cookie that belongs to this query.
-
matchesQuestion
-
validateCookie
-
trySuccess
-
finishFailure
-
retryWithTcp
Retry the original query with TCP if possible.- Parameters:
originalResult- the result of the originalDnsQueryContext.- Returns:
trueif retry via TCP is supported and so the ownership oforiginalResultwas transferred,falseotherwise.
-
finishOriginal
-