Skip to content

Commit

Permalink
feat: [torrust#426] disable TimeoutAccceptor when TSL is enabled
Browse files Browse the repository at this point in the history
TSL does work with the TimeoutAccetor.

How to enabled TSL for development with:

```
[net]
port = 3001

[net.tsl]
ssl_cert_path = "./storage/index/lib/tls/localhost.crt"
ssl_key_path = "./storage/index/lib/tls/localhost.key"
```

You can fin the certificates in `./share/tsl`.

This means there is no timeout for the first client request when you use
TSL. The way to test tiemouts is:

1. Open a connection using telnet: `telnet 127.0.0.1 3001`
2. Wait 5 seconds.

The connection should be closed after 5 seconds. That's what the
TimeoutAcceptor does. Without the TimeoutAcceptor the connection will
remain open until the client closes it.
  • Loading branch information
josecelano committed May 16, 2024
1 parent 284d235 commit 5d9e068
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions share/default/config/index.development.sqlite3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ url = "udp://localhost:6969"
[net]
port = 3001

# Uncomment if you want to enable TSL for development
#[net.tsl]
#ssl_cert_path = "./storage/index/lib/tls/localhost.crt"
#ssl_key_path = "./storage/index/lib/tls/localhost.key"
Expand Down
4 changes: 3 additions & 1 deletion src/web/api/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ async fn start_server(
match tls {
Some(tls) => custom_axum::from_tcp_rustls_with_timeouts(socket, tls)
.handle(handle)
.acceptor(TimeoutAcceptor)
// The TimeoutAcceptor is commented because it does not with TSL.
// See: https://github.com/torrust/torrust-index/issues/204
//.acceptor(TimeoutAcceptor)
.serve(router.into_make_service_with_connect_info::<std::net::SocketAddr>())
.await
.expect("API server should be running"),
Expand Down

0 comments on commit 5d9e068

Please sign in to comment.