Skip to content

Commit

Permalink
fix potential DDOS by honest clients when servers are at capacity (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
UkoeHB authored Sep 4, 2024
1 parent fde643a commit cc4bc65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
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

0 comments on commit cc4bc65

Please sign in to comment.