Packet rate limit
This commit is contained in:
@@ -35,7 +35,8 @@ public class Team implements Comparable<Team>{
|
|||||||
|
|
||||||
//TODO temporarily no palettes for these teams.
|
//TODO temporarily no palettes for these teams.
|
||||||
green = new Team(4, "green", Color.valueOf("54d67d")),//Color.valueOf("96f58c"), Color.valueOf("54d67d"), Color.valueOf("28785c")),
|
green = new Team(4, "green", Color.valueOf("54d67d")),//Color.valueOf("96f58c"), Color.valueOf("54d67d"), Color.valueOf("28785c")),
|
||||||
blue = new Team(5, "blue", Color.valueOf("6c87fd")); //Color.valueOf("85caf9"), Color.valueOf("6c87fd"), Color.valueOf("3b3392")
|
blue = new Team(5, "blue", Color.valueOf("6c87fd")), //Color.valueOf("85caf9"), Color.valueOf("6c87fd"), Color.valueOf("3b3392")
|
||||||
|
neoplastic = new Team(6, "neoplastic", Color.valueOf("e05438")); //yes, it looks very similar to crux, you're not supposed to use this team for block regions anyway
|
||||||
|
|
||||||
static{
|
static{
|
||||||
Mathf.rand.setSeed(8);
|
Mathf.rand.setSeed(8);
|
||||||
|
|||||||
@@ -556,6 +556,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
public static void unitClear(Player player){
|
public static void unitClear(Player player){
|
||||||
if(player == null) return;
|
if(player == null) return;
|
||||||
|
|
||||||
|
//make sure player is allowed to control the building
|
||||||
|
if(net.server() && !netServer.admins.allowAction(player, ActionType.respawn, action -> {})){
|
||||||
|
throw new ValidateException(player, "Player cannot respawn.");
|
||||||
|
}
|
||||||
|
|
||||||
if(!player.dead() && !player.unit().spawnedByCore){
|
if(!player.dead() && !player.unit().spawnedByCore){
|
||||||
var docked = player.unit().dockedType;
|
var docked = player.unit().dockedType;
|
||||||
|
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum ActionType{
|
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());
|
ArcConnection k = getByArcID(connection.getID());
|
||||||
if(!(object instanceof Packet pack) || k == null) return;
|
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(() -> {
|
Core.app.post(() -> {
|
||||||
try{
|
try{
|
||||||
net.handleServerReceived(k, pack);
|
net.handleServerReceived(k, pack);
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public abstract class NetConnection{
|
|||||||
public Seq<BuildPlan> rejectedRequests = new Seq<>();
|
public Seq<BuildPlan> rejectedRequests = new Seq<>();
|
||||||
/** Handles chat spam rate limits. */
|
/** Handles chat spam rate limits. */
|
||||||
public Ratekeeper chatRate = new Ratekeeper();
|
public Ratekeeper chatRate = new Ratekeeper();
|
||||||
|
/** Handles packet spam rate limits. */
|
||||||
|
public Ratekeeper packetRate = new Ratekeeper();
|
||||||
|
|
||||||
public boolean hasConnected, hasBegunConnecting, hasDisconnected;
|
public boolean hasConnected, hasBegunConnecting, hasDisconnected;
|
||||||
public float viewWidth, viewHeight, viewX, viewY;
|
public float viewWidth, viewHeight, viewX, viewY;
|
||||||
|
|||||||
Reference in New Issue
Block a user