torrust / torrust-tracker

A modern and feature-rich (private) BitTorrent tracker.
https://torrust.com
GNU Affero General Public License v3.0
370 stars 44 forks source link

Tracker API: Add a timeout to the TLS handshake, waiting for headers, and waiting for receiving headers #612

Open josecelano opened 10 months ago

josecelano commented 10 months ago

Parent issue: https://github.com/torrust/torrust-tracker/issues/603

Related to:

Adds a timeout to:

Recently we moved to axum-server and it allows setting TLS handshake timeout.

josecelano commented 7 months ago

I've opened a new issue on the axum-server repo: https://github.com/programatik29/axum-server/issues/116. It seems that feature was removed.

josecelano commented 7 months ago

I've also opened a discussion in the Actix-Web repo: https://github.com/actix/actix-web/discussions/3337

josecelano commented 6 months ago

I guess we can implement what I did here. That patch adds the timeout, but it does not send a 408 response to the client. Anyway, I think there is no other choice in this case.

josecelano commented 6 months ago

The TimeoutAcceptor I used to fix this issue does not work with TSL. See https://github.com/torrust/torrust-index/pull/584#issuecomment-2115499282. We have to remove it from the Axum server bootstrapping code for TSL, which means there is no timeout for TSL again until we find another solution, which makes it insecure again to use your own TSL configuration.

josecelano commented 6 months ago

I've converted the discussion in the Axun repo into a issue: https://github.com/tokio-rs/axum/issues/2741

josecelano commented 5 months ago

A PR has been merged in the hyper repo. It changes the http1_header_read_timeout timeout.

image

This could fix this issue. We can try when this change is published in a new release.

josecelano commented 4 months ago

A PR has been merged in the hyper repo. It changes the http1_header_read_timeout timeout.

image

This could fix this issue. We can try when this change is published in a new release.

hyper 1.4.0 has been released with server starting header read timeout immediately (#3185) (0eb1b6cf)

josecelano commented 4 months ago

We are already using hyper 1.4.0 but it seems it does not solve the problem. We still need the custom TimeAcceptor which is only working when TSL is not enabled.

josecelano commented 4 months ago

I've reopened the issue https://github.com/torrust/torrust-tracker/issues/324 to avoid duplicated comments on: