mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-01 18:50:27 +03:00
Blacklist UDP address along with TCP address (#12274)
This commit is contained in:
@@ -319,7 +319,7 @@ public class NetClient implements ApplicationListener{
|
||||
//detect and kick for foul play
|
||||
if(player != null && player.con != null && !player.con.chatRate.allow(2000, Config.chatSpamLimit.num())){
|
||||
player.con.kick(KickReason.kick);
|
||||
netServer.admins.blacklistDos(player.con.address);
|
||||
player.con.blacklist();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ public class ArcNetProvider implements NetProvider{
|
||||
if(packetSpamLimit > 0 && !k.packetRate.allow(3000, packetSpamLimit)){
|
||||
Log.warn("Blacklisting IP '@' as potential DOS attack - packet spam.", k.address);
|
||||
connection.close(DcReason.closed);
|
||||
netServer.admins.blacklistDos(k.address);
|
||||
k.blacklist();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -366,6 +366,17 @@ public class ArcNetProvider implements NetProvider{
|
||||
return connection.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklist(){
|
||||
//Blacklist TCP address
|
||||
super.blacklist();
|
||||
//Blacklist UDP address
|
||||
var address = connection.getRemoteAddressUDP();
|
||||
if(address != null){
|
||||
netServer.admins.blacklistDos(address.getAddress().getHostAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStream(Streamable stream){
|
||||
connection.addListener(new InputStreamSender(stream.stream, 1024){
|
||||
|
||||
@@ -129,6 +129,10 @@ public abstract class NetConnection{
|
||||
}
|
||||
}
|
||||
|
||||
public void blacklist(){
|
||||
netServer.admins.blacklistDos(address);
|
||||
}
|
||||
|
||||
public abstract void send(Object object, boolean reliable);
|
||||
|
||||
public abstract void close();
|
||||
|
||||
Reference in New Issue
Block a user