pub struct ServerFuture<T: RequestHandler> { /* private fields */ }Expand description
A Futures based implementation of a DNS server
Implementations§
Source§impl<T: RequestHandler> ServerFuture<T>
impl<T: RequestHandler> ServerFuture<T>
Sourcepub fn register_socket(&mut self, socket: UdpSocket)
pub fn register_socket(&mut self, socket: UdpSocket)
Register a UDP socket. Should be bound before calling this function.
Sourcepub fn register_socket_std(&mut self, socket: UdpSocket) -> Result<()>
pub fn register_socket_std(&mut self, socket: UdpSocket) -> Result<()>
Register a UDP socket. Should be bound before calling this function.
Sourcepub fn register_listener(&mut self, listener: TcpListener, timeout: Duration)
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 sockettimeout- 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.
Sourcepub fn register_listener_std(
&mut self,
listener: TcpListener,
timeout: Duration,
) -> Result<()>
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 sockettimeout- 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.
Sourcepub fn register_tls_listener_with_tls_config(
&mut self,
listener: TcpListener,
timeout: Duration,
tls_config: Arc<ServerConfig>,
) -> Result<()>
Available on crate feature dns-over-rustls only.
pub fn register_tls_listener_with_tls_config( &mut self, listener: TcpListener, timeout: Duration, tls_config: Arc<ServerConfig>, ) -> Result<()>
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) sockettimeout- 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.tls_config- rustls server config
Sourcepub 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.
pub fn register_tls_listener( &mut self, listener: TcpListener, timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey), ) -> Result<()>
dns-over-rustls only.Register a TlsListener to the Server by providing a pkcs12 certificate and key. 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) sockettimeout- 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
Sourcepub 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.
pub fn register_https_listener( &mut self, listener: TcpListener, _timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey), dns_hostname: Option<String>, ) -> Result<()>
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) sockettimeout- 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
Sourcepub 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.
pub fn register_quic_listener( &mut self, socket: UdpSocket, _timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey), dns_hostname: Option<String>, ) -> Result<()>
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) sockettimeout- 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
Sourcepub fn register_h3_listener(
&mut self,
socket: UdpSocket,
_timeout: Duration,
certificate_and_key: (Vec<Certificate>, PrivateKey),
dns_hostname: Option<String>,
) -> Result<()>
Available on crate feature dns-over-h3 only.
pub fn register_h3_listener( &mut self, socket: UdpSocket, _timeout: Duration, certificate_and_key: (Vec<Certificate>, PrivateKey), dns_hostname: Option<String>, ) -> Result<()>
dns-over-h3 only.Register a UdpSocket to the Server for supporting DoH3 (dns-over-h3). 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) sockettimeout- 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
Sourcepub async fn shutdown_gracefully(&mut self) -> Result<(), ProtoError>
pub async fn shutdown_gracefully(&mut 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.
Sourcepub async fn block_until_done(&mut self) -> Result<(), ProtoError>
pub async fn block_until_done(&mut 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.