Packet rate limit
This commit is contained in:
@@ -676,7 +676,7 @@ public class Administration{
|
||||
}
|
||||
|
||||
public enum ActionType{
|
||||
breakBlock, placeBlock, rotate, configure, withdrawItem, depositItem, control, buildSelect, command, removePlanned, commandUnits, commandBuilding
|
||||
breakBlock, placeBlock, rotate, configure, withdrawItem, depositItem, control, buildSelect, command, removePlanned, commandUnits, commandBuilding, respawn
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,6 +137,13 @@ public class ArcNetProvider implements NetProvider{
|
||||
ArcConnection k = getByArcID(connection.getID());
|
||||
if(!(object instanceof Packet pack) || k == null) return;
|
||||
|
||||
if(!k.packetRate.allow(3000, 270)){
|
||||
Log.warn("Blacklisting IP '@' as potential DOS attack - packet spam.", k.address);
|
||||
connection.close(DcReason.closed);
|
||||
netServer.admins.blacklistDos(k.address);
|
||||
return;
|
||||
}
|
||||
|
||||
Core.app.post(() -> {
|
||||
try{
|
||||
net.handleServerReceived(k, pack);
|
||||
|
||||
@@ -30,6 +30,8 @@ public abstract class NetConnection{
|
||||
public Seq<BuildPlan> rejectedRequests = new Seq<>();
|
||||
/** Handles chat spam rate limits. */
|
||||
public Ratekeeper chatRate = new Ratekeeper();
|
||||
/** Handles packet spam rate limits. */
|
||||
public Ratekeeper packetRate = new Ratekeeper();
|
||||
|
||||
public boolean hasConnected, hasBegunConnecting, hasDisconnected;
|
||||
public float viewWidth, viewHeight, viewX, viewY;
|
||||
|
||||
Reference in New Issue
Block a user