Skip to content

Commit

Permalink
feat: disable TimeoutAcceptor when TSL is enabled
Browse files Browse the repository at this point in the history
The TimeoutAcceptor es a custom acceptor for Axum that sets a timeput
for making a request after openning a connection.

It does not work when TSL is enabled.

This commit disables it, therefore the app does not have any way to
avoid a DDos attacks where clients just open connections without making
any request.
  • Loading branch information
josecelano committed Aug 7, 2024
1 parent 0a04dde commit 222fa42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/servers/apis/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ impl Launcher {
match tls {
Some(tls) => custom_axum_server::from_tcp_rustls_with_timeouts(socket, tls)
.handle(handle)
.acceptor(TimeoutAcceptor)
// The TimeoutAcceptor is commented because TSL does not work with it.
// See: https://github.com/torrust/torrust-index/issues/204#issuecomment-2115529214
//.acceptor(TimeoutAcceptor)
.serve(router.into_make_service_with_connect_info::<std::net::SocketAddr>())
.await
.expect("Axum server for tracker API crashed."),
Expand Down
4 changes: 3 additions & 1 deletion src/servers/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ impl Launcher {
match tls {
Some(tls) => custom_axum_server::from_tcp_rustls_with_timeouts(socket, tls)
.handle(handle)
.acceptor(TimeoutAcceptor)
// The TimeoutAcceptor is commented because TSL does not work with it.
// See: https://github.com/torrust/torrust-index/issues/204#issuecomment-2115529214
//.acceptor(TimeoutAcceptor)
.serve(app.into_make_service_with_connect_info::<std::net::SocketAddr>())
.await
.expect("Axum server crashed."),
Expand Down

0 comments on commit 222fa42

Please sign in to comment.