[PR #2818] [MERGED] Dedicated server: apply server.properties rate-limit #4635

Closed
opened 2026-11-03 05:06:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2818
Author: @sirrayi
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/rate-limit-property


📝 Commits (1)

  • 4fea5fa Dedicated server: apply server.properties rate-limit

📊 Changes

3 files changed (+139 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game/dedicated.rs (+1 -0)
📝 crates/horizon-client/src/lan/conn.rs (+134 -12)
📝 crates/horizon-client/src/lan/mod.rs (+4 -0)

📄 Description

🤖 Opened by sirrayi's AI agent (Devin), not by sirrayi themselves.

What and why

server.properties' rate-limit was parsed (horizon-server-files Properties::rate_limit) but never used. A server owner who set it got no protection against a client flooding packets.

Now NetConfig carries rate_limit (0, off, for LAN and integrated servers; the property's value for a dedicated server). Each play connection keeps its packets-a-second average as Connection.tickSecond does: average = Mth.lerp(0.75F, received, average) once a second. Idle seconds decay it in one step, without a loop. When the average passes the limit:

  • the server logs Player exceeded rate-limit (sent N packets per second) as WARN on the Server thread, with Java's Float.toString (java_text::float_to_string);
  • the player gets disconnect.exceeded_packet_rate, as RateKickingConnection does.

read_loop's Result<String, u128> became an Ended enum with three outcomes: the connection closed, the player declined the required pack, or the player passed the rate limit.

Vanilla reference

  • ServerConnectionListener: RateKickingConnection when getRateLimitPacketsPerSecond() > 0.
  • Connection.tickSecond, RateKickingConnection.tickSecond.

Self-check

  • cargo fmt --all -- --check ✅, cargo clippy -p horizon-client --lib --tests -- -D warnings ✅
  • cargo test -p horizon-client --lib lan::conn ✅, cargo check -p horizon-client --bins ✅
  • New tests: lan::conn::tests::a_rate_over_the_limit_kicks and lan::conn::tests::an_idle_gap_decays_without_a_loop.

The dedicated_server harness needs .local/, so it didn't run here.

Generated with Devin


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2818 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/rate-limit-property` --- ### 📝 Commits (1) - [`4fea5fa`](https://github.com/horizon-rust/horizon/commit/4fea5fafe5d897d3e08c7b09979fc749f67e271e) Dedicated server: apply server.properties rate-limit ### 📊 Changes **3 files changed** (+139 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dedicated.rs` (+1 -0) 📝 `crates/horizon-client/src/lan/conn.rs` (+134 -12) 📝 `crates/horizon-client/src/lan/mod.rs` (+4 -0) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (Devin), not by sirrayi themselves. ## What and why `server.properties`' `rate-limit` was parsed (`horizon-server-files` `Properties::rate_limit`) but never used. A server owner who set it got no protection against a client flooding packets. Now `NetConfig` carries `rate_limit` (0, off, for LAN and integrated servers; the property's value for a dedicated server). Each play connection keeps its packets-a-second average as `Connection.tickSecond` does: `average = Mth.lerp(0.75F, received, average)` once a second. Idle seconds decay it in one step, without a loop. When the average passes the limit: - the server logs `Player exceeded rate-limit (sent N packets per second)` as WARN on the Server thread, with Java's `Float.toString` (`java_text::float_to_string`); - the player gets `disconnect.exceeded_packet_rate`, as `RateKickingConnection` does. `read_loop`'s `Result<String, u128>` became an `Ended` enum with three outcomes: the connection closed, the player declined the required pack, or the player passed the rate limit. ## Vanilla reference - `ServerConnectionListener`: `RateKickingConnection` when `getRateLimitPacketsPerSecond() > 0`. - `Connection.tickSecond`, `RateKickingConnection.tickSecond`. ## Self-check - `cargo fmt --all -- --check` ✅, `cargo clippy -p horizon-client --lib --tests -- -D warnings` ✅ - `cargo test -p horizon-client --lib lan::conn` ✅, `cargo check -p horizon-client --bins` ✅ - New tests: `lan::conn::tests::a_rate_over_the_limit_kicks` and `lan::conn::tests::an_idle_gap_decays_without_a_loop`. The `dedicated_server` harness needs `.local/`, so it didn't run here. Generated with [Devin](https://devin.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:06:50 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4635
No description provided.