8000 feat: implement command rate limiter by bridgelol · Pull Request #1524 · PaperMC/Velocity · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: implement command rate limiter #1524

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

Merged
merged 9 commits into from
Apr 3, 2025

Conversation

bridgelol
Copy link
Contributor
@bridgelol bridgelol commented Mar 7, 2025

Velocity proxies can still be crashed with any other commands besides /velocity info. A proper fix for this is to rate limit the frequency of which a client can send commands to the server. Currently there is none.

@electronicboy
Copy link
Member

We don't have a means of updating config files properly, and the nature of this will induce weird protocol state if somebody does trigger this; I would generally mostly prefer that we address the bottleneck rather than introducing mechanisms like this which, with the current state of the protocol, creates a whole bunch of other issues if people start configuring this for anything but kicking bad clients

@bridgelol
Copy link
Contributor Author

We don't have a means of updating config files properly, and the nature of this will induce weird protocol state if somebody does trigger this; I would generally mostly prefer that we address the bottleneck rather than introducing mechanisms like this which, with the current state of the protocol, creates a whole bunch of other issues if people start configuring this for anything but kicking bad clients

You will need some sort of rate limiting mechanism to prevent this, can send thousands of packets a second on any velocity command

@bridgelol
Copy link
Contributor Author

The defaults should also be fine to the extent where most shouldn't need to configure it

@bridgelol
Copy link
Contributor Author

Could also add a hard minimum which isn't configurable so users can't break it

@Timongcraft
Copy link
Contributor

Is there a reason why literal kick messages are used instead of translatables?

@bridgelol
Copy link
Contributor Author

Could add, figured it wouldn't be needed as literal messages are used pretty often for kicks (i.e VelocityServer L521)

@GrowlyX
Copy link
GrowlyX commented Mar 7, 2025

You should probably use translatables and change the English message to "You are tab completing too fast." rather than the message you have right now

@Timongcraft
Copy link
Contributor

Could add, figured it wouldn't be needed as literal messages are used pretty often for kicks (i.e VelocityServer L521)

I don't know why that is, but you should be abel to just add a key to the .properties file(s) and use that in the translatable, we can translate at this point because the player was already connected.
Also what happens if a plugin registered a command with a signed argument, wouldn't this break the chat chain?

Copy link
Member
@electronicboy electronicboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest issue with this is that we have no means to update peoples config files properly, will probably have to figure out some quick mitigation for that in this case, I know that we've been able to handle this somewhat manually but it's far from ideal; I don't really wanna add a bunch of new config options, especially which have side effects, which don't show up in peoples existing config files

@Timongcraft
Copy link
Contributor

This pr currently has an issue with signed commands e.g. the built-in /msg command.
By setting the command-rate-limit to 2000 for demonstration purposes, you can see the command being canceled and any other message with a signed context now disconnecting the client as chat chain was broken when canceling the command.

Quick demo:
https://github.com/user-attachments/assets/84a3334c-a268-41fa-acbe-51257223564b

@bridgelol
Copy link
Contributor Author

This pr currently has an issue with signed commands e.g. the built-in /msg command. By setting the command-rate-limit to 2000 for demonstration purposes, you can see the command being canceled and any other message with a signed context now disconnecting the client as chat chain was broken when canceling the command.

Quick demo: https://github.com/user-attachments/assets/84a3334c-a268-41fa-acbe-51257223564b

My latest commit should resolve this

@bridgelol
Copy link
Contributor Author

The biggest issue with this is that we have no means to update peoples config files properly, will probably have to figure out some quick mitigation for that in this case, I know that we've been able to handle this somewhat manually but it's far from ideal; I don't really wanna add a bunch of new config options, especially which have side effects, which don't show up in peoples existing config files

Could make the defaults extra tame

@bridgelol
Copy link
Contributor Author

Additionally, now that it forwards the packet to the server upon hitting rate limit, I could disable kicks by default

@Timongcraft
Copy link
Contributor

Then would you rename cancel-commands-if-rate-limited to smh. like forward-commands-if-rate-limited, as cancel doesn't seem appropriate anymore? Or what is the plan for the config?

@CullanP
Copy link
CullanP commented Mar 25, 2025

Is it intentional that tab completes don't reset to 0 when not failing, if a player fails once it never resets so over time it will eventually kick them, the limits currently set are good, but without it resetting to 0 you will get players that are kicked if not adjusted

@bridgelol
Copy link
Contributor Author

Is it intentional that tab completes don't reset to 0 when not failing, if a player fails once it never resets so over time it will eventually kick them, the limits currently set are good, but without it resetting to 0 you will get players that are kicked if not adjusted

Wasn't intentional no, fixed :D

@Skullians
Copy link

Any update on this?

@electronicboy
Copy link
Member

Generally needs testing/additional feedback, been too preoccupied to deal with this myself

@Skullians
Copy link

Generally needs testing/additional feedback, been too preoccupied to deal with this myself

Okay, thanks for the clarification.

@bridgelol
Copy link
Contributor Author
bridgelol commented Apr 2, 2025

Our server and many others medium / large servers have been running this in production for weeks now, without any issues

@electronicboy
Copy link
Member

I would generally want 3rd party confirmation of that, but I'll look at merging this tomorrow morning unless somebody else gets to it

@electronicboy electronicboy merged commit 7ffa43f into PaperMC:dev/3.0.0 Apr 3, 2025
1 check passed
@HamtaBot
Copy link
HamtaBot commented Apr 3, 2025

tested aswell since a months with no issues and default values

@Timongcraft Timongcraft mentioned this pull request Apr 3, 2025
pull bot pushed a commit to WiIIiam278/Velocity that referenced this pull request Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
0