class documentation

DNS protocol mixin shared by UDP and TCP implementations.

Method __init__ Undocumented
Method callLater Wrapper around reactor.callLater, mainly for test purpose.
Method pickID Return a unique ID for queries.
Class Variable liveMessages a dictionary mapping message-ID to the Deferred that will fire when it completes, and the pending timeout that will cause it to fail, for all outstanding queries that have not yet received a response.
Instance Variable controller Undocumented
Instance Variable id Undocumented
Method _clearFailed Clean the Deferred after a timeout.
Method _handleResponse Handle an incoming DNS message.
Method _query Send out a message with the given queries.
Instance Variable _reactor A IReactorTime and IReactorUDP provider which will be used to issue DNS queries and manage request timeouts.
def __init__(self, controller, reactor=None): (source)

Undocumented

def callLater(self, period, func, *args): (source)

Wrapper around reactor.callLater, mainly for test purpose.

def pickID(self) -> int: (source)

Return a unique ID for queries.

a dictionary mapping message-ID to the Deferred that will fire when it completes, and the pending timeout that will cause it to fail, for all outstanding queries that have not yet received a response.

controller = (source)

Undocumented

Undocumented

def _clearFailed(self, deferred: Deferred[Message], id: int): (source)

Clean the Deferred after a timeout.

def _handleResponse(self, data: bytes, messageSource: object, notifyController: Callable[[Message], None], validate: Callable[[Message], bool] = lambda m: True): (source)

Handle an incoming DNS message.

Parameters
data:bytesThe bytes of the message (just the payload; any length prefix removed)
messageSource:objectThe source of the message (the address from which it was received)
notifyController:Callable[[Message], None]The callable invoked when a message is not a response to a currently-pending query response.
validate:Callable[[Message], bool]The callable invoked to ensure that a message is a valid reply; the message is discarded if this returns False.
def _query(self, queries: list[Query], timeout: float, id: int, writeMessage: Callable[[Message], None]) -> Deferred[Message]: (source)

Send out a message with the given queries.

Parameters
queries:list[Query]The queries to transmit
timeout:floatHow long to wait before giving up
id:intUnique key for this request
writeMessage:Callable[[Message], None]One-parameter callback which writes the message
Returns
Deferred[Message]a Deferred which will be fired with the result of the query, or errbacked with any errors that could happen (exceptions during writing of the query, timeout errors, ...).
_reactor = (source)

A IReactorTime and IReactorUDP provider which will be used to issue DNS queries and manage request timeouts.