Skip to main content

Catalog

Struct Catalog 

Source
pub struct Catalog { /* private fields */ }
Expand description

Set of zones and zone handlers available to this server.

Implementations§

Source§

impl Catalog

Source

pub fn new() -> Self

Constructs a new Catalog

Source

pub fn upsert(&mut self, name: LowerName, handlers: Vec<Arc<dyn ZoneHandler>>)

Insert or update the provided zone handlers

§Arguments
  • name - zone name, e.g. example.com.
  • handlers - a vec of zone handler objects
Source

pub fn remove(&mut self, name: &LowerName) -> Option<Vec<Arc<dyn ZoneHandler>>>

Remove a zone from the catalog

Source

pub fn set_nsid(&mut self, payload: Option<NSIDPayload>)

Set a specified name server identifier (NSID) in responses

The provided NSIDPayload will be included in responses to requests that specify the NSID option in EDNS. Set to None to disable NSID.

By default, no NSID is sent.

Source

pub fn nsid(&self) -> Option<&NSIDPayload>

Return the name server identifier (NSID) that is used for responses (if enabled)

See set_nsid() for more information.

Source

pub async fn update<R: ResponseHandler>( &self, update: &Request, response_edns: Option<&Edns>, now: u64, response_handle: R, ) -> ResponseInfo

Update the zone given the Update request.

RFC 2136, DNS Update, April 1997

3.1 - Process Zone Section

  3.1.1. The Zone Section is checked to see that there is exactly one
  RR therein and that the RR's ZTYPE is SOA, else signal FORMERR to the
  requestor.  Next, the ZNAME and ZCLASS are checked to see if the zone
  so named is one of this server's authority zones, else signal NOTAUTH
  to the requestor.  If the server is a zone Secondary, the request will be
  forwarded toward the Primary Zone Server.

  3.1.2 - Pseudocode For Zone Section Processing

     if (zcount != 1 || ztype != SOA)
          return (FORMERR)
     if (zone_type(zname, zclass) == SECONDARY)
          return forward()
     if (zone_type(zname, zclass) == PRIMARY)
          return update()
     return (NOTAUTH)

  Sections 3.2 through 3.8 describe the primary's behaviour,
  whereas Section 6 describes a forwarder's behaviour.

3.8 - Response

  At the end of UPDATE processing, a response code will be known.  A
  response message is generated by copying the ID and Opcode fields
  from the request, and either copying the ZOCOUNT, PRCOUNT, UPCOUNT,
  and ADCOUNT fields and associated sections, or placing zeros (0) in
  the these "count" fields and not including any part of the original
  update.  The QR bit is set to one (1), and the response is sent back
  to the requestor.  If the requestor used UDP, then the response will
  be sent to the requestor's source UDP port.  If the requestor used
  TCP, then the response will be sent back on the requestor's open TCP
  connection.

The “request” should be an update formatted message. The response will be in the alternate, all 0’s format described in RFC 2136 section 3.8 as this is more efficient.

§Arguments
  • request - an update message
  • response_edns an optional Edns value for the response message
  • response_handle - sink for the response message to be sent
Source

pub fn contains(&self, name: &LowerName) -> bool

Checks whether the Catalog contains DNS records for name

Use this when you know the exact LowerName that was used when adding a zone handler and you don’t care about the zone handler it contains. For public domain names, LowerName is usually the top level domain name like example.com..

If you do not know the exact domain name to use or you actually want to use the zone handler it contains, use find instead.

Source

pub async fn lookup<R: ResponseHandler>( &self, request: &Request, response_edns: Option<&Edns>, now: u64, response_handle: R, ) -> ResponseInfo

Given the requested query, lookup and return any matching results.

§Arguments
  • request - the query message.
  • response_edns an optional Edns value for the response message
  • response_handle - sink for the response message to be sent
Source

pub fn find( &self, name: &LowerName, ) -> Option<&Vec<Arc<dyn ZoneHandler + 'static>>>

Recursively searches the catalog for a matching zone handler

Trait Implementations§

Source§

impl Default for Catalog

Source§

fn default() -> Catalog

Returns the “default value” for a type. Read more
Source§

impl RequestHandler for Catalog

Source§

fn handle_request<'life0, 'life1, 'async_trait, R, T>( &'life0 self, request: &'life1 Request, response_handle: R, ) -> Pin<Box<dyn Future<Output = ResponseInfo> + Send + 'async_trait>>
where R: 'async_trait + ResponseHandler, T: 'async_trait + Time, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Determines what needs to happen given the type of request, i.e. Query or Update.

§Arguments
  • request - the requested action to perform.
  • response_handle - sink for the response message to be sent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more