Commit 79bb0e4
authored
refactor(iroh-relay)!: proper timeouts on relay connections (#4083)
## Description
Adds a timeout to relay connections to abort connections that stall
while establishing the relay WebSocket connection.
A timeout of 30s is started for each new incoming TCP stream. The
timeout is cleared once the connection has completed a TLS handshake (if
serving via HTTPS), received a WebSocket request and passed that request
to the relay protocol handler. If the timeout elapses before the
connection is fully established and passed to the relay handler, the
connection is aborted.
Before this change, clients could open TCP connections to the relay
server, and they would sit idle forever if the client neither closes it
nor issues the WebSocket request.
## Breaking Changes
* `iroh_relay::server::http_server::RelayService` no longer implements
`hyper::Service`. Use
`iroh_relay::server::http_server::RelayServiceWithNotify` instead, it
can be constructed from a `RelayService` with
`RelayServiceWithNotify::new`
* `iroh_relay::server::http_server::RelayService::handle_connection` now
takes a new argument `establish_timeout`
<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.1 parent 159a5cf commit 79bb0e4
1 file changed
Lines changed: 222 additions & 46 deletions
0 commit comments