-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
add packet limiter for incoming packets #3733
base: master
Are you sure you want to change the base?
Conversation
Would it maybe be useful to change this to have just have a task per connection on the netty thread every second setting the counter to 0? I think calling the currentTimeMillis method and checking for seconds elapsed for every packet is a waste of time. |
As you can see we dont get the millis every packet, we check for the millis every 2000th packet Normally a client send 20-60 packets per second so this should not have any Performance impact at all Edit: If you would set the limit to 1000 in the config every 1000th packet would be checked |
Oh, I somehow missed that part of the logic. My bad. |
I saw that in 1 fork they also check the packet size in bytes, maybe it will be a good idea? Does it check every possible connection from player? Pretty nice idea for the counter. |
i dont think a data size check is needed |
What if you have many large packets under the limit? |
Too large packets are causing kicks by bungee or spigot already. |
That depends, but I guess we talk about the thing when pakets are received earlier on bungee than spigot. |
if the packet exceeds the protocol limits we throw an exception on bungee side, if we do not read the packet the minecraft server throws the exception |
I mean the packets that are handled on bukkit, I suppose it's possible to lag it before it even reaches the spigot. |
i dont get your point |
I think it's possible to mass spam packets, the netty thread on bungeecord will be lagged it even reaches the spigot. |
how can you mass spam if there is a packet limit? |
Spam under the packet limit with massive packets, I was more worried without the limiter. |
thats not a bungeecord issue but this pr should mitigate that |
Wouldn't an external plugin be better just for this? |
Too much resources for the plugin I think.
I think it would be really nice to limit bytes too and maybe avoid checking instances of handler every packet. |
checking for the handler should make no performace decrease at all |
If it can be avoided I think it's good to not do that or check it just once. What do you think about the byte limiter? |
unnecessary the packet amount limit is enought |
Can't some packets with nbt reach huge sizes? Nice patch, I love that. |
yes they need to have big size so we cant kick them. for example if you have a big shulker box or something |
if you want to kick players based on packet size you need to have more context (do it on spigot) |
I thought about basic check, 1 fork did that in MinecaftDecoder, multiplying the bytes by some small number like 0.001, summarizing it and when it reaches the threshold under 1 second, the user gets kicked. |
i think the risk of false flags is to high |
That's what the configuration is for and it should be set pretty well to avoid false flags, but be secured properly from all kinds of attacks. |
Also we dont know the lenght of the packet if its compressed, we would need to read the lenght of every compressed packet. I think thats not worth |
Incoming compressed packet? |
Yes |
I don't know about such packets, but if I do it in MinecraftDecoder the bytes are already read. |
Ah yes we decompress them anyway. But this would have no benefits for bungee. |
Won't it be good idea to avoid spam with big packets? |
big packets are not a problem i guess |
Packets that are too large will simply be cancelled by disconnecting to that connection by the backend itself |
But you need the protection on the backend too and you need to listen there for every packet and check the size there too. |
@md-5 what do you think about a packet amount limitation? |
If the Vanilla server can handle it, why not Bungee? |
Weird question, also I don't think that vanilla server can handle huge amount of packets. |
It is possible to make netty threads lag by spamming a massive amount of packets.
And you can make players time out with it.
I am not sure if i should say how specifically you can achieve that, publicly.
A simple packet limiter should mitigate those attacks.
A vanilla client should never exeed the default value of 2000 packets per second, but we can disguss about this if any concerns