mirror of https://github.com/http-rs/tide-rustls
add tcp_{nodelay,ttl} to Debug, example, tcp_ prefix
This commit is contained in:
parent
ae009b5d89
commit
bdfa6488d2
|
@ -1,10 +1,10 @@
|
|||
//! tide tls listener built on async-tls and rustls
|
||||
//! tide tls listener built on async-rustls and rustls
|
||||
//!
|
||||
//!
|
||||
//! # Example
|
||||
//! ```rust
|
||||
//! # use tide_rustls::TlsListener;
|
||||
//! fn main() -> tide::Result<()> { async_std::task::block_on(async {
|
||||
//! # fn main() -> tide::Result<()> { async_std::task::block_on(async {
|
||||
//! let mut app = tide::new();
|
||||
//! app.at("/").get(|_| async { Ok("Hello tls") });
|
||||
//! # if false {
|
||||
|
@ -15,8 +15,7 @@
|
|||
//! .key(std::env::var("TIDE_KEY_PATH").unwrap()),
|
||||
//! )
|
||||
//! .await?;
|
||||
//! # }
|
||||
//! # Ok(()) }) }
|
||||
//! # } Ok(()) }) }
|
||||
//! ```
|
||||
#![forbid(unsafe_code, future_incompatible)]
|
||||
#![deny(
|
||||
|
|
|
@ -44,12 +44,19 @@ impl<State> Debug for TlsListener<State> {
|
|||
&"None"
|
||||
},
|
||||
)
|
||||
.field("tcp_ttl", &self.tcp_ttl)
|
||||
.field("tcp_nodelay", &self.tcp_nodelay)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<State> TlsListener<State> {
|
||||
pub(crate) fn new(connection: TcpConnection, config: TlsListenerConfig, tcp_nodelay: Option<bool>, tcp_ttl: Option<u32>) -> Self {
|
||||
pub(crate) fn new(
|
||||
connection: TcpConnection,
|
||||
config: TlsListenerConfig,
|
||||
tcp_nodelay: Option<bool>,
|
||||
tcp_ttl: Option<u32>,
|
||||
) -> Self {
|
||||
Self {
|
||||
connection,
|
||||
config,
|
||||
|
|
|
@ -35,6 +35,18 @@ use std::sync::Arc;
|
|||
/// .config(rustls::ServerConfig::new(rustls::NoClientAuth::new()))
|
||||
/// .finish();
|
||||
/// ```
|
||||
///
|
||||
/// ```rust
|
||||
/// # use tide_rustls::TlsListener;
|
||||
/// let listener = TlsListener::<()>::build()
|
||||
/// .addrs("localhost:4433")
|
||||
/// .cert("./tls/localhost-4433.cert")
|
||||
/// .key("./tls/localhost-4433.key")
|
||||
/// .tcp_ttl(60)
|
||||
/// .tcp_nodelay(true)
|
||||
/// .finish();
|
||||
/// ```
|
||||
|
||||
pub struct TlsListenerBuilder<State> {
|
||||
key: Option<PathBuf>,
|
||||
cert: Option<PathBuf>,
|
||||
|
@ -86,6 +98,8 @@ impl<State> std::fmt::Debug for TlsListenerBuilder<State> {
|
|||
)
|
||||
.field("tcp", &self.tcp)
|
||||
.field("addrs", &self.addrs)
|
||||
.field("tcp_nodelay", &self.tcp_nodelay)
|
||||
.field("tcp_ttl", &self.tcp_ttl)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -153,13 +167,13 @@ impl<State> TlsListenerBuilder<State> {
|
|||
}
|
||||
|
||||
/// Provides a TCP_NODELAY option for this tls listener.
|
||||
pub fn nodelay(mut self, nodelay: bool) -> Self {
|
||||
pub fn tcp_nodelay(mut self, nodelay: bool) -> Self {
|
||||
self.tcp_nodelay = Some(nodelay);
|
||||
self
|
||||
}
|
||||
|
||||
/// Provides a TTL option for this tls listener.
|
||||
pub fn ttl(mut self, ttl: u32) -> Self {
|
||||
/// Provides a TTL option for this tls listener, in seconds.
|
||||
pub fn tcp_ttl(mut self, ttl: u32) -> Self {
|
||||
self.tcp_ttl = Some(ttl);
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue