Skip to content

Commit bdfa648

Browse files
committed
add tcp_{nodelay,ttl} to Debug, example, tcp_ prefix
1 parent ae009b5 commit bdfa648

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//! tide tls listener built on async-tls and rustls
1+
//! tide tls listener built on async-rustls and rustls
22
//!
33
//!
44
//! # Example
55
//! ```rust
66
//! # use tide_rustls::TlsListener;
7-
//! fn main() -> tide::Result<()> { async_std::task::block_on(async {
7+
//! # fn main() -> tide::Result<()> { async_std::task::block_on(async {
88
//! let mut app = tide::new();
99
//! app.at("/").get(|_| async { Ok("Hello tls") });
1010
//! # if false {
@@ -15,8 +15,7 @@
1515
//! .key(std::env::var("TIDE_KEY_PATH").unwrap()),
1616
//! )
1717
//! .await?;
18-
//! # }
19-
//! # Ok(()) }) }
18+
//! # } Ok(()) }) }
2019
//! ```
2120
#![forbid(unsafe_code, future_incompatible)]
2221
#![deny(

src/tls_listener.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ impl<State> Debug for TlsListener<State> {
4444
&"None"
4545
},
4646
)
47+
.field("tcp_ttl", &self.tcp_ttl)
48+
.field("tcp_nodelay", &self.tcp_nodelay)
4749
.finish()
4850
}
4951
}
5052

5153
impl<State> TlsListener<State> {
52-
pub(crate) fn new(connection: TcpConnection, config: TlsListenerConfig, tcp_nodelay: Option<bool>, tcp_ttl: Option<u32>) -> Self {
54+
pub(crate) fn new(
55+
connection: TcpConnection,
56+
config: TlsListenerConfig,
57+
tcp_nodelay: Option<bool>,
58+
tcp_ttl: Option<u32>,
59+
) -> Self {
5360
Self {
5461
connection,
5562
config,

src/tls_listener_builder.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ use std::sync::Arc;
3535
/// .config(rustls::ServerConfig::new(rustls::NoClientAuth::new()))
3636
/// .finish();
3737
/// ```
38+
///
39+
/// ```rust
40+
/// # use tide_rustls::TlsListener;
41+
/// let listener = TlsListener::<()>::build()
42+
/// .addrs("localhost:4433")
43+
/// .cert("./tls/localhost-4433.cert")
44+
/// .key("./tls/localhost-4433.key")
45+
/// .tcp_ttl(60)
46+
/// .tcp_nodelay(true)
47+
/// .finish();
48+
/// ```
49+
3850
pub struct TlsListenerBuilder<State> {
3951
key: Option<PathBuf>,
4052
cert: Option<PathBuf>,
@@ -86,6 +98,8 @@ impl<State> std::fmt::Debug for TlsListenerBuilder<State> {
8698
)
8799
.field("tcp", &self.tcp)
88100
.field("addrs", &self.addrs)
101+
.field("tcp_nodelay", &self.tcp_nodelay)
102+
.field("tcp_ttl", &self.tcp_ttl)
89103
.finish()
90104
}
91105
}
@@ -153,13 +167,13 @@ impl<State> TlsListenerBuilder<State> {
153167
}
154168

155169
/// Provides a TCP_NODELAY option for this tls listener.
156-
pub fn nodelay(mut self, nodelay: bool) -> Self {
170+
pub fn tcp_nodelay(mut self, nodelay: bool) -> Self {
157171
self.tcp_nodelay = Some(nodelay);
158172
self
159173
}
160174

161-
/// Provides a TTL option for this tls listener.
162-
pub fn ttl(mut self, ttl: u32) -> Self {
175+
/// Provides a TTL option for this tls listener, in seconds.
176+
pub fn tcp_ttl(mut self, ttl: u32) -> Self {
163177
self.tcp_ttl = Some(ttl);
164178
self
165179
}

0 commit comments

Comments
 (0)