Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential DDOS by honest clients when servers are at capacity #108

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## v0.6.3

- Allow users to use tokio v2.4.0 in their projects. See [#106](https://github.com/gbaranski/ezsockets/pull/106).
- Fix DDOS by honest clients when servers check capacity *after* clients connect.


## v0.6.2
Expand Down
4 changes: 4 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ impl<E: ClientExt, C: ClientConnector> ClientActor<E, C> {
match self.client.on_close(frame).await? {
ClientCloseMode::Reconnect => {
std::mem::drop(socket);
// Sleep so honest clients won't DDOS the server if it is at capacity and if
// capacity is checked *after* clients connect.
sleep(self.config.reconnect_interval).await;
let Some(socket) = client_connect(
self.config.max_reconnect_attempts,
&self.config,
Expand Down Expand Up @@ -594,6 +597,7 @@ impl<E: ClientExt, C: ClientConnector> ClientActor<E, C> {
match self.client.on_disconnect().await? {
ClientCloseMode::Reconnect => {
std::mem::drop(socket);
// Note: We don't sleep here unlike above because a disconnect is assumed to be a network error.
let Some(socket) = client_connect(
self.config.max_reconnect_attempts,
&self.config,
Expand Down
Loading