pub struct ServerFuture<T: RequestHandler> { /* private fields */ }
Expand description

A Futures based implementation of a DNS server

Implementations§

source§

impl<T: RequestHandler> ServerFuture<T>

source

pub fn new(handler: T) -> Self

Creates a new ServerFuture with the specified Handler.

source

pub fn register_socket(&mut self, socket: UdpSocket)

Register a UDP socket. Should be bound before calling this function.

source

pub fn register_socket_std(&mut self, socket: UdpSocket) -> Result<()>

Register a UDP socket. Should be bound before calling this function.

source

pub fn register_listener(&mut self, listener: TcpListener, timeout: Duration)

Register a TcpListener to the Server. This should already be bound to either an IPv6 or an IPv4 address.

To make the server more resilient to DOS issues, there is a timeout. Care should be taken to not make this too low depending on use cases.

Arguments
  • listener - a bound TCP socket
  • timeout - timeout duration of incoming requests, any connection that does not send requests within this time period will be closed. In the future it should be possible to create long-lived queries, but these should be from trusted sources only, this would require some type of whitelisting.
source

pub fn register_listener_std( &mut self, listener: TcpListener, timeout: Duration ) -> Result<()>

Register a TcpListener to the Server. This should already be bound to either an IPv6 or an IPv4 address.

To make the server more resilient to DOS issues, there is a timeout. Care should be taken to not make this too low depending on use cases.

Arguments
  • listener - a bound TCP socket
  • timeout - timeout duration of incoming requests, any connection that does not send requests within this time period will be closed. In the future it should be possible to create long-lived queries, but these should be from trusted sources only, this would require some type of whitelisting.
source

pub fn register_tls_listener( &mut self, listener: TcpListener, timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey) ) -> Result<()>

Available on crate feature dns-over-rustls only.

Register a TlsListener to the Server. The TlsListener should already be bound to either an IPv6 or an IPv4 address.

To make the server more resilient to DOS issues, there is a timeout. Care should be taken to not make this too low depending on use cases.

Arguments
  • listener - a bound TCP (needs to be on a different port from standard TCP connections) socket
  • timeout - timeout duration of incoming requests, any connection that does not send requests within this time period will be closed. In the future it should be possible to create long-lived queries, but these should be from trusted sources only, this would require some type of whitelisting.
  • pkcs12 - certificate used to announce to clients
source

pub fn register_https_listener( &mut self, listener: TcpListener, _timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey), dns_hostname: Option<String> ) -> Result<()>

Available on crate feature dns-over-https-rustls only.

Register a TcpListener for HTTPS (h2) to the Server for supporting DoH (dns-over-https). The TcpListener should already be bound to either an IPv6 or an IPv4 address.

To make the server more resilient to DOS issues, there is a timeout. Care should be taken to not make this too low depending on use cases.

Arguments
  • listener - a bound TCP (needs to be on a different port from standard TCP connections) socket
  • timeout - timeout duration of incoming requests, any connection that does not send requests within this time period will be closed. In the future it should be possible to create long-lived queries, but these should be from trusted sources only, this would require some type of whitelisting.
  • certificate_and_key - certificate and key used to announce to clients
source

pub fn register_quic_listener( &mut self, socket: UdpSocket, _timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey), dns_hostname: Option<String> ) -> Result<()>

Available on crate feature dns-over-quic only.

Register a UdpSocket to the Server for supporting DoQ (dns-over-quic). The UdpSocket should already be bound to either an IPv6 or an IPv4 address.

To make the server more resilient to DOS issues, there is a timeout. Care should be taken to not make this too low depending on use cases.

Arguments
  • listener - a bound TCP (needs to be on a different port from standard TCP connections) socket
  • timeout - timeout duration of incoming requests, any connection that does not send requests within this time period will be closed. In the future it should be possible to create long-lived queries, but these should be from trusted sources only, this would require some type of whitelisting.
  • pkcs12 - certificate used to announce to clients
source

pub fn graceful( self ) -> (ShutdownSignal, impl Future<Output = Result<(), ProtoError>>)

Returns a signal used for initiating a graceful shutdown of the server and the future used for awaiting completion of the shutdown.

This allows the application to have separate code paths that are responsible for triggering shutdown and awaiting application completion.

source

pub async fn shutdown_gracefully(self) -> Result<(), ProtoError>

Triggers a graceful shutdown the server. All background tasks will stop accepting new connections and the returned future will complete once all tasks have terminated.

This is equivalent to calling Self::graceful, then triggering the graceful shutdown (via [ShutdownSignal::shutdown]) and awaiting completion of the server.

source

pub async fn block_until_done(self) -> Result<(), ProtoError>

This will run until all background tasks complete. If one or more tasks return an error, one will be chosen as the returned error for this future.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ServerFuture<T>

§

impl<T> Send for ServerFuture<T>

§

impl<T> Sync for ServerFuture<T>

§

impl<T> Unpin for ServerFuture<T>

§

impl<T> !UnwindSafe for ServerFuture<T>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

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

§

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