pub struct DnsRequest { /* private fields */ }
Expand description
A DNS request object
This wraps a DNS Message for requests. It also has request options associated for controlling certain features of the DNS protocol handlers.
Implementations§
Source§impl DnsRequest
impl DnsRequest
Sourcepub fn new(message: Message, options: DnsRequestOptions) -> Self
pub fn new(message: Message, options: DnsRequestOptions) -> Self
Returns a new DnsRequest object
Sourcepub fn options(&self) -> &DnsRequestOptions
pub fn options(&self) -> &DnsRequestOptions
Get the set of request options associated with this request
Sourcepub fn into_parts(self) -> (Message, DnsRequestOptions)
pub fn into_parts(self) -> (Message, DnsRequestOptions)
Unwraps the raw message
Methods from Deref<Target = Message>§
Sourcepub fn truncate(&self) -> Self
pub fn truncate(&self) -> Self
Truncates a Message, this blindly removes all response fields and sets truncated to true
Sourcepub fn set_header(&mut self, header: Header) -> &mut Self
pub fn set_header(&mut self, header: Header) -> &mut Self
Sets the Header
with provided
Sourcepub fn set_message_type(&mut self, message_type: MessageType) -> &mut Self
pub fn set_message_type(&mut self, message_type: MessageType) -> &mut Self
see Header::set_message_type
Sourcepub fn set_op_code(&mut self, op_code: OpCode) -> &mut Self
pub fn set_op_code(&mut self, op_code: OpCode) -> &mut Self
see Header::set_op_code
see Header::set_authoritative
Sourcepub fn set_truncated(&mut self, truncated: bool) -> &mut Self
pub fn set_truncated(&mut self, truncated: bool) -> &mut Self
see Header::set_truncated
Sourcepub fn set_recursion_desired(&mut self, recursion_desired: bool) -> &mut Self
pub fn set_recursion_desired(&mut self, recursion_desired: bool) -> &mut Self
see Header::set_recursion_desired
Sourcepub fn set_recursion_available(
&mut self,
recursion_available: bool,
) -> &mut Self
pub fn set_recursion_available( &mut self, recursion_available: bool, ) -> &mut Self
see Header::set_recursion_available
Sourcepub fn set_authentic_data(&mut self, authentic_data: bool) -> &mut Self
pub fn set_authentic_data(&mut self, authentic_data: bool) -> &mut Self
see Header::set_authentic_data
Sourcepub fn set_checking_disabled(&mut self, checking_disabled: bool) -> &mut Self
pub fn set_checking_disabled(&mut self, checking_disabled: bool) -> &mut Self
see Header::set_checking_disabled
Sourcepub fn set_response_code(&mut self, response_code: ResponseCode) -> &mut Self
pub fn set_response_code(&mut self, response_code: ResponseCode) -> &mut Self
see Header::set_response_code
Sourcepub fn set_query_count(&mut self, query_count: u16) -> &mut Self
pub fn set_query_count(&mut self, query_count: u16) -> &mut Self
see Header::set_query_count
this count will be ignored during serialization, where the length of the associated records will be used instead.
Sourcepub fn set_answer_count(&mut self, answer_count: u16) -> &mut Self
pub fn set_answer_count(&mut self, answer_count: u16) -> &mut Self
see Header::set_answer_count
this count will be ignored during serialization, where the length of the associated records will be used instead.
Sourcepub fn set_name_server_count(&mut self, name_server_count: u16) -> &mut Self
pub fn set_name_server_count(&mut self, name_server_count: u16) -> &mut Self
see Header::set_name_server_count
this count will be ignored during serialization, where the length of the associated records will be used instead.
Sourcepub fn set_additional_count(&mut self, additional_count: u16) -> &mut Self
pub fn set_additional_count(&mut self, additional_count: u16) -> &mut Self
see Header::set_additional_count
this count will be ignored during serialization, where the length of the associated records will be used instead.
Sourcepub fn add_query(&mut self, query: Query) -> &mut Self
pub fn add_query(&mut self, query: Query) -> &mut Self
Add a query to the Message, either the query response from the server, or the request Query.
Sourcepub fn add_queries<Q, I>(&mut self, queries: Q) -> &mut Self
pub fn add_queries<Q, I>(&mut self, queries: Q) -> &mut Self
Adds an iterator over a set of Queries to be added to the message
Sourcepub fn add_answer(&mut self, record: Record) -> &mut Self
pub fn add_answer(&mut self, record: Record) -> &mut Self
Add an answer to the Message
Sourcepub fn add_answers<R, I>(&mut self, records: R) -> &mut Self
pub fn add_answers<R, I>(&mut self, records: R) -> &mut Self
Add all the records from the iterator to the answers section of the Message
Sourcepub fn insert_answers(&mut self, records: Vec<Record>)
pub fn insert_answers(&mut self, records: Vec<Record>)
Sets the answers to the specified set of Records.
§Panics
Will panic if answer records are already associated to the message.
Sourcepub fn add_name_server(&mut self, record: Record) -> &mut Self
pub fn add_name_server(&mut self, record: Record) -> &mut Self
Add a name server record to the Message
Sourcepub fn add_name_servers<R, I>(&mut self, records: R) -> &mut Self
pub fn add_name_servers<R, I>(&mut self, records: R) -> &mut Self
Add all the records in the Iterator to the name server section of the message
Sourcepub fn insert_name_servers(&mut self, records: Vec<Record>)
pub fn insert_name_servers(&mut self, records: Vec<Record>)
Sets the name_servers to the specified set of Records.
§Panics
Will panic if name_servers records are already associated to the message.
Sourcepub fn add_additional(&mut self, record: Record) -> &mut Self
pub fn add_additional(&mut self, record: Record) -> &mut Self
Add an additional Record to the message
Sourcepub fn add_additionals<R, I>(&mut self, records: R) -> &mut Self
pub fn add_additionals<R, I>(&mut self, records: R) -> &mut Self
Add all the records from the iterator to the additionals section of the Message
Sourcepub fn insert_additionals(&mut self, records: Vec<Record>)
pub fn insert_additionals(&mut self, records: Vec<Record>)
Sets the additional to the specified set of Records.
§Panics
Will panic if additional records are already associated to the message.
Sourcepub fn add_sig0(&mut self, record: Record) -> &mut Self
Available on crate feature dnssec
only.
pub fn add_sig0(&mut self, record: Record) -> &mut Self
dnssec
only.Add a SIG0 record, i.e. sign this message
This must be used only after all records have been associated. Generally this will be handled by the client and not need to be used directly
Sourcepub fn add_tsig(&mut self, record: Record) -> &mut Self
Available on crate feature dnssec
only.
pub fn add_tsig(&mut self, record: Record) -> &mut Self
dnssec
only.Add a TSIG record, i.e. authenticate this message
This must be used only after all records have been associated. Generally this will be handled by the client and not need to be used directly
Sourcepub fn message_type(&self) -> MessageType
pub fn message_type(&self) -> MessageType
see Header::message_type()
see Header::authoritative()
Sourcepub fn recursion_desired(&self) -> bool
pub fn recursion_desired(&self) -> bool
see Header::recursion_desired()
Sourcepub fn recursion_available(&self) -> bool
pub fn recursion_available(&self) -> bool
see Header::recursion_available()
Sourcepub fn authentic_data(&self) -> bool
pub fn authentic_data(&self) -> bool
see Header::authentic_data()
Sourcepub fn checking_disabled(&self) -> bool
pub fn checking_disabled(&self) -> bool
see Header::checking_disabled()
Sourcepub fn response_code(&self) -> ResponseCode
pub fn response_code(&self) -> ResponseCode
§Return value
The ResponseCode
, if this is an EDNS message then this will join the section from the OPT
record to create the EDNS ResponseCode
Sourcepub fn query(&self) -> Option<&Query>
pub fn query(&self) -> Option<&Query>
Returns the query from this Message.
In almost all cases, a Message will only contain one query. This is a convenience function to get the single query.
See the alternative queries*
methods for the raw set of queries in the Message
Sourcepub fn queries_mut(&mut self) -> &mut Vec<Query>
pub fn queries_mut(&mut self) -> &mut Vec<Query>
Provides mutable access to queries
Sourcepub fn take_queries(&mut self) -> Vec<Query>
pub fn take_queries(&mut self) -> Vec<Query>
Removes all the answers from the Message
Sourcepub fn answers_mut(&mut self) -> &mut Vec<Record>
pub fn answers_mut(&mut self) -> &mut Vec<Record>
Provides mutable access to answers
Sourcepub fn take_answers(&mut self) -> Vec<Record>
pub fn take_answers(&mut self) -> Vec<Record>
Removes all the answers from the Message
Sourcepub fn name_servers(&self) -> &[Record]
pub fn name_servers(&self) -> &[Record]
Authority Carries RRs which describe other authoritative servers.
May optionally carry the SOA RR for the authoritative
data in the answer section.
Sourcepub fn name_servers_mut(&mut self) -> &mut Vec<Record>
pub fn name_servers_mut(&mut self) -> &mut Vec<Record>
Provides mutable access to name_servers
Sourcepub fn take_name_servers(&mut self) -> Vec<Record>
pub fn take_name_servers(&mut self) -> Vec<Record>
Remove the name servers from the Message
Sourcepub fn additionals(&self) -> &[Record]
pub fn additionals(&self) -> &[Record]
Additional Carries RRs which may be helpful in using the RRs in the
other sections.
Sourcepub fn additionals_mut(&mut self) -> &mut Vec<Record>
pub fn additionals_mut(&mut self) -> &mut Vec<Record>
Provides mutable access to additionals
Sourcepub fn take_additionals(&mut self) -> Vec<Record>
pub fn take_additionals(&mut self) -> Vec<Record>
Remove the additional Records from the Message
Sourcepub fn all_sections(&self) -> impl Iterator<Item = &Record>
pub fn all_sections(&self) -> impl Iterator<Item = &Record>
All sections chained
Sourcepub fn edns(&self) -> Option<&Edns>
👎Deprecated: Please use extensions()
pub fn edns(&self) -> Option<&Edns>
extensions()
RFC 6891, EDNS(0) Extensions, April 2013
6.1.1. Basic Elements
An OPT pseudo-RR (sometimes called a meta-RR) MAY be added to the
additional data section of a request.
The OPT RR has RR type 41.
If an OPT record is present in a received request, compliant
responders MUST include an OPT record in their respective responses.
An OPT record does not carry any DNS data. It is used only to
contain control information pertaining to the question-and-answer
sequence of a specific transaction. OPT RRs MUST NOT be cached,
forwarded, or stored in or loaded from Zone Files.
The OPT RR MAY be placed anywhere within the additional data section.
When an OPT RR is included within any DNS message, it MUST be the
only OPT RR in that message. If a query message with more than one
OPT RR is received, a FORMERR (RCODE=1) MUST be returned. The
placement flexibility for the OPT RR does not override the need for
the TSIG or SIG(0) RRs to be the last in the additional section
whenever they are present.
§Return value
Optionally returns a reference to EDNS section
Sourcepub fn edns_mut(&mut self) -> &mut Edns
👎Deprecated: Please use extensions_mut()
. You can chain .get_or_insert_with(Edns::new)
to recover original behavior of adding Edns if not present
pub fn edns_mut(&mut self) -> &mut Edns
extensions_mut()
. You can chain .get_or_insert_with(Edns::new)
to recover original behavior of adding Edns if not presentOptionally returns mutable reference to EDNS section
Sourcepub fn extensions(&self) -> &Option<Edns>
pub fn extensions(&self) -> &Option<Edns>
Returns reference of Edns section
Sourcepub fn extensions_mut(&mut self) -> &mut Option<Edns>
pub fn extensions_mut(&mut self) -> &mut Option<Edns>
Returns mutable reference of Edns section
Sourcepub fn max_payload(&self) -> u16
pub fn max_payload(&self) -> u16
§Return value
the max payload value as it’s defined in the EDNS section.
Sourcepub fn sig0(&self) -> &[Record]
pub fn sig0(&self) -> &[Record]
RFC 2535, Domain Name System Security Extensions, March 1999
A DNS request may be optionally signed by including one or more SIGs
at the end of the query. Such SIGs are identified by having a "type
covered" field of zero. They sign the preceding DNS request message
including DNS header but not including the IP header or any request
SIGs at the end and before the request RR counts have been adjusted
for the inclusions of any request SIG(s).
§Return value
The sig0 and tsig, i.e. signed record, for verifying the sending and package integrity
Sourcepub fn signature(&self) -> &[Record]
pub fn signature(&self) -> &[Record]
RFC 2535, Domain Name System Security Extensions, March 1999
A DNS request may be optionally signed by including one or more SIGs
at the end of the query. Such SIGs are identified by having a "type
covered" field of zero. They sign the preceding DNS request message
including DNS header but not including the IP header or any request
SIGs at the end and before the request RR counts have been adjusted
for the inclusions of any request SIG(s).
§Return value
The sig0 and tsig, i.e. signed record, for verifying the sending and package integrity
Sourcepub fn take_signature(&mut self) -> Vec<Record>
pub fn take_signature(&mut self) -> Vec<Record>
Remove signatures from the Message
Sourcepub fn finalize(
&mut self,
finalizer: &dyn MessageFinalizer,
inception_time: u32,
) -> Result<Option<MessageVerifier>, ProtoError>
pub fn finalize( &mut self, finalizer: &dyn MessageFinalizer, inception_time: u32, ) -> Result<Option<MessageVerifier>, ProtoError>
Finalize the message prior to sending.
Subsequent to calling this, the Message should not change.
Methods from Deref<Target = Header>§
Sourcepub fn id(&self) -> u16
pub fn id(&self) -> u16
ID A 16 bit identifier assigned by the program that
generates any kind of query. This identifier is copied
the corresponding reply and can be used by the requester
to match up replies to outstanding queries.
Sourcepub fn message_type(&self) -> MessageType
pub fn message_type(&self) -> MessageType
QR A one bit field that specifies whether this message is a
query (0), or a response (1).
Sourcepub fn op_code(&self) -> OpCode
pub fn op_code(&self) -> OpCode
OPCODE A four bit field that specifies kind of query in this
message. This value is set by the originator of a query
and copied into the response. The values are: <see super::op_code>
AA Authoritative Answer - this bit is valid in responses,
and specifies that the responding name server is an
authority for the domain name in question section.
Note that the contents of the answer section may have
multiple owner names because of aliases. The AA bit
corresponds to the name which matches the query name, or
the first owner name in the answer section.
Sourcepub fn truncated(&self) -> bool
pub fn truncated(&self) -> bool
TC TrunCation - specifies that this message was truncated
due to length greater than that permitted on the
transmission channel.
Sourcepub fn recursion_desired(&self) -> bool
pub fn recursion_desired(&self) -> bool
RD Recursion Desired - this bit may be set in a query and
is copied into the response. If RD is set, it directs
the name server to pursue the query recursively.
Recursive query support is optional.
Sourcepub fn recursion_available(&self) -> bool
pub fn recursion_available(&self) -> bool
RA Recursion Available - this be is set or cleared in a
response, and denotes whether recursive query support is
available in the name server.
Sourcepub fn authentic_data(&self) -> bool
pub fn authentic_data(&self) -> bool
RFC 4035, DNSSEC Resource Records, March 2005
3.1.6. The AD and CD Bits in an Authoritative Response
The CD and AD bits are designed for use in communication between
security-aware resolvers and security-aware recursive name servers.
These bits are for the most part not relevant to query processing by
security-aware authoritative name servers.
A security-aware name server does not perform signature validation
for authoritative data during query processing, even when the CD bit
is clear. A security-aware name server SHOULD clear the CD bit when
composing an authoritative response.
A security-aware name server MUST NOT set the AD bit in a response
unless the name server considers all RRsets in the Answer and
Authority sections of the response to be authentic. A security-aware
name server's local policy MAY consider data from an authoritative
zone to be authentic without further validation. However, the name
server MUST NOT do so unless the name server obtained the
authoritative zone via secure means (such as a secure zone transfer
mechanism) and MUST NOT do so unless this behavior has been
configured explicitly.
A security-aware name server that supports recursion MUST follow the
rules for the CD and AD bits given in Section 3.2 when generating a
response that involves data obtained via recursion.
Sourcepub fn checking_disabled(&self) -> bool
pub fn checking_disabled(&self) -> bool
see is_authentic_data()
Sourcepub fn response_code(&self) -> ResponseCode
pub fn response_code(&self) -> ResponseCode
RCODE Response code - this 4 bit field is set as part of
responses. The values have the following
interpretation: <see super::response_code>
Sourcepub fn query_count(&self) -> u16
pub fn query_count(&self) -> u16
QDCOUNT an unsigned 16 bit integer specifying the number of
entries in the question section.
§Return value
If this is a query, this will return the number of queries in the query section of the
Sourcepub fn answer_count(&self) -> u16
pub fn answer_count(&self) -> u16
ANCOUNT an unsigned 16 bit integer specifying the number of
resource records in the answer section.
§Return value
For query responses this is the number of records in the answer section, should be 0 for requests, for updates this is the count of prerequisite records.
Sourcepub fn name_server_count(&self) -> u16
pub fn name_server_count(&self) -> u16
for queries this is the nameservers which are authorities for the SOA of the Record for updates this is the update record count
NSCOUNT an unsigned 16 bit integer specifying the number of name
server resource records in the authority records
section.
§Return value
For query responses this is the number of authorities, or nameservers, in the name server section, for updates this is the number of update records being sent.
Sourcepub fn additional_count(&self) -> u16
pub fn additional_count(&self) -> u16
ARCOUNT an unsigned 16 bit integer specifying the number of
resource records in the additional records section.
§Return value
This is the additional record section count, this section may include EDNS options.
Trait Implementations§
Source§impl Clone for DnsRequest
impl Clone for DnsRequest
Source§fn clone(&self) -> DnsRequest
fn clone(&self) -> DnsRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Deref for DnsRequest
impl Deref for DnsRequest
Source§impl DerefMut for DnsRequest
impl DerefMut for DnsRequest
Source§impl From<Message> for DnsRequest
impl From<Message> for DnsRequest
Source§impl PartialEq for DnsRequest
impl PartialEq for DnsRequest
impl Eq for DnsRequest
impl StructuralPartialEq for DnsRequest
Auto Trait Implementations§
impl Freeze for DnsRequest
impl RefUnwindSafe for DnsRequest
impl Send for DnsRequest
impl Sync for DnsRequest
impl Unpin for DnsRequest
impl UnwindSafe for DnsRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.