Struct DnsResponse
pub struct DnsResponse { /* private fields */ }Expand description
A DNS response object
For Most DNS requests, only one response is expected, the exception is a multicast request.
Implementations§
§impl DnsResponse
impl DnsResponse
pub fn from_message(message: Message) -> Result<DnsResponse, ProtoError>
pub fn from_message(message: Message) -> Result<DnsResponse, ProtoError>
Constructs a new DnsResponse with a buffer synthesized from the message
pub fn from_buffer(buffer: Vec<u8>) -> Result<DnsResponse, ProtoError>
pub fn from_buffer(buffer: Vec<u8>) -> Result<DnsResponse, ProtoError>
Constructs a new DnsResponse by parsing a message from a buffer.
Returns an error if the response message cannot be decoded.
pub fn soa(&self) -> Option<RecordRef<'_, SOA>>
pub fn soa(&self) -> Option<RecordRef<'_, SOA>>
Retrieves the SOA from the response. This will only exist if it was an authoritative response.
pub fn negative_ttl(&self) -> Option<u32>
pub fn negative_ttl(&self) -> Option<u32>
Looks in the authority section for an SOA record from the response, and returns the negative_ttl, None if not available.
[RFC 2308](https://tools.ietf.org/html/rfc2308#section-5) DNS NCACHE March 1998
5 - Caching Negative Answers
Like normal answers negative answers have a time to live (TTL). As
there is no record in the answer section to which this TTL can be
applied, the TTL must be carried by another method. This is done by
including the SOA record from the zone in the authority section of
the reply. When the authoritative server creates this record its TTL
is taken from the minimum of the SOA.MINIMUM field and SOA's TTL.
This TTL decrements in a similar manner to a normal cached answer and
upon reaching zero (0) indicates the cached negative answer MUST NOT
be used again.
A negative answer that resulted from a name error (NXDOMAIN) should
be cached such that it can be retrieved and returned in response to
another query for the same <QNAME, QCLASS> that resulted in the
cached negative response.
A negative answer that resulted from a no data error (NODATA) should
be cached such that it can be retrieved and returned in response to
another query for the same <QNAME, QTYPE, QCLASS> that resulted in
the cached negative response.
The NXT record, if it exists in the authority section of a negative
answer received, MUST be stored such that it can be be located and
returned with SOA record in the authority section, as should any SIG
records in the authority section. For NXDOMAIN answers there is no
"necessary" obvious relationship between the NXT records and the
QNAME. The NXT record MUST have the same owner name as the query
name for NODATA responses.
Negative responses without SOA records SHOULD NOT be cached as there
is no way to prevent the negative responses looping forever between a
pair of servers even with a short TTL.
Despite the DNS forming a tree of servers, with various mis-
configurations it is possible to form a loop in the query graph, e.g.
two servers listing each other as forwarders, various lame server
configurations. Without a TTL count down a cache negative response
when received by the next server would have its TTL reset. This
negative indication could then live forever circulating between the
servers involved.
As with caching positive responses it is sensible for a resolver to
limit for how long it will cache a negative response as the protocol
supports caching for up to 68 years. Such a limit should not be
greater than that applied to positive answers and preferably be
tunable. Values of one to three hours have been found to work well
and would make sensible a default. Values exceeding one day have
been found to be problematic.pub fn contains_answer(&self) -> bool
pub fn contains_answer(&self) -> bool
Does the response contain any records matching the query name and type?
pub fn into_buffer(self) -> Vec<u8> ⓘ
pub fn into_buffer(self) -> Vec<u8> ⓘ
Take the inner buffer from the response
pub fn into_message(self) -> Message
pub fn into_message(self) -> Message
Take the inner Message from the response
pub fn into_parts(self) -> (Message, Vec<u8>)
pub fn into_parts(self) -> (Message, Vec<u8>)
Take the inner Message and buffer from the response
Methods from Deref<Target = Message>§
pub fn truncate(&self) -> Message
pub fn truncate(&self) -> Message
Truncates a Message, this blindly removes all response fields and sets truncated to true
pub fn add_query(&mut self, query: Query) -> &mut Message
pub fn add_query(&mut self, query: Query) -> &mut Message
Add a query to the Message, either the query response from the server, or the request Query.
pub fn add_queries<Q, I>(&mut self, queries: Q) -> &mut Message
pub fn add_queries<Q, I>(&mut self, queries: Q) -> &mut Message
Adds an iterator over a set of Queries to be added to the message
pub fn add_answer(&mut self, record: Record) -> &mut Message
pub fn add_answer(&mut self, record: Record) -> &mut Message
Add a record to the Answer section.
pub fn add_answers<R, I>(&mut self, records: R) -> &mut Message
pub fn add_answers<R, I>(&mut self, records: R) -> &mut Message
Add all the records from the iterator to the Answer section of the message.
pub fn insert_answers(&mut self, records: Vec<Record>)
pub fn insert_answers(&mut self, records: Vec<Record>)
Sets the Answer section to the specified set of records.
§Panics
Will panic if the Answer section is already non-empty.
Add a record to the Authority section.
Add all the records from the Iterator to the Authority section of the message.
Sets the Authority section to the specified set of records.
§Panics
Will panic if the Authority section is already non-empty.
pub fn add_additional(&mut self, record: Record) -> &mut Message
pub fn add_additional(&mut self, record: Record) -> &mut Message
Add a record to the Additional section.
pub fn add_additionals<R, I>(&mut self, records: R) -> &mut Message
pub fn add_additionals<R, I>(&mut self, records: R) -> &mut Message
Add all the records from the iterator to the Additional section of the message.
pub 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.
pub fn take_all_sections(&mut self) -> impl Iterator<Item = Record>
pub fn take_all_sections(&mut self) -> impl Iterator<Item = Record>
Consume the message, returning an iterator over records from all sections
pub fn all_sections(&self) -> impl Iterator<Item = &Record>
pub fn all_sections(&self) -> impl Iterator<Item = &Record>
All sections chained
pub fn max_payload(&self) -> u16
pub fn max_payload(&self) -> u16
§Return value
the max payload value as it’s defined in the EDNS OPT pseudo-RR.
pub fn signature(&self) -> Option<&Record<TSIG>>
pub fn signature(&self) -> Option<&Record<TSIG>>
§Return value
the signature over the message, if any
pub fn take_signature(&mut self) -> Option<Box<Record<TSIG>>>
pub fn take_signature(&mut self) -> Option<Box<Record<TSIG>>>
Remove signatures from the Message
pub fn to_vec(&self) -> Result<Vec<u8>, ProtoError>
pub fn to_vec(&self) -> Result<Vec<u8>, ProtoError>
Encodes the Message into a buffer
Trait Implementations§
§impl Clone for DnsResponse
impl Clone for DnsResponse
§fn clone(&self) -> DnsResponse
fn clone(&self) -> DnsResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for DnsResponse
impl Debug for DnsResponse
§impl Deref for DnsResponse
impl Deref for DnsResponse
§impl DerefMut for DnsResponse
impl DerefMut for DnsResponse
§fn deref_mut(&mut self) -> &mut <DnsResponse as Deref>::Target
fn deref_mut(&mut self) -> &mut <DnsResponse as Deref>::Target
§impl<'de> Deserialize<'de> for DnsResponse
impl<'de> Deserialize<'de> for DnsResponse
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DnsResponse, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DnsResponse, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl From<DnsResponse> for Message
impl From<DnsResponse> for Message
§fn from(response: DnsResponse) -> Message
fn from(response: DnsResponse) -> Message
§impl Serialize for DnsResponse
impl Serialize for DnsResponse
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for DnsResponse
impl RefUnwindSafe for DnsResponse
impl Send for DnsResponse
impl Sync for DnsResponse
impl Unpin for DnsResponse
impl UnsafeUnpin for DnsResponse
impl UnwindSafe for DnsResponse
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more