programatik29 / axum-server

High level server designed to be used with axum framework.
MIT License
168 stars 56 forks source link

TLS handshake timeout (Fix #37) #39

Closed finnbear closed 2 years ago

finnbear commented 2 years ago

This PR adds a timeout to the TLS handshake, to guard against TCP connection leaks arising from poor connections or malicious activity. This type of connection leak can seriously impair an internet-facing server (I know from experience). A test case is included to verify the functionality works.

The downside is that a https://docs.rs/tokio/latest/tokio/time/struct.Sleep.html is required per connection being accepted, which I believe is a heap allocation.

Please note: This PR is on top of my AddrIncomingConfig PR (https://github.com/programatik29/axum-server/pull/38), for my own convenience, so I can use both together until one or both are merged.