Hotfix antiddos
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
e58860644c
Commit
63043ee677
@ -4,15 +4,17 @@ import de.steamwar.bungeecore.sql.SWException;
|
|||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.logging.Filter;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
public class ErrorLogger extends Handler {
|
public class ErrorLogger extends Handler implements Filter {
|
||||||
private static ErrorLogger instance;
|
private static ErrorLogger instance;
|
||||||
|
|
||||||
ErrorLogger(){
|
ErrorLogger(){
|
||||||
ProxyServer.getInstance().getLogger().addHandler(this);
|
ProxyServer.getInstance().getLogger().addHandler(this);
|
||||||
|
ProxyServer.getInstance().getLogger().setFilter(this);
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,6 +22,29 @@ public class ErrorLogger extends Handler {
|
|||||||
ProxyServer.getInstance().getLogger().removeHandler(instance);
|
ProxyServer.getInstance().getLogger().removeHandler(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLoggable(LogRecord record) {
|
||||||
|
if(record.getLevel() != Level.SEVERE)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
StringBuilder stacktrace = new StringBuilder(record.getSourceClassName() + "\n" + record.getSourceMethodName());
|
||||||
|
Throwable thrown = record.getThrown();
|
||||||
|
while(thrown != null){
|
||||||
|
stacktrace.append("\nCaused by ").append(thrown.getMessage());
|
||||||
|
|
||||||
|
for(StackTraceElement ste : thrown.getStackTrace())
|
||||||
|
stacktrace.append("\n").append(ste.toString());
|
||||||
|
|
||||||
|
thrown = thrown.getCause();
|
||||||
|
}
|
||||||
|
|
||||||
|
String stacktraceString = stacktrace.toString();
|
||||||
|
if(stacktraceString.contains("Cannot request protocol")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publish(LogRecord record) {
|
public void publish(LogRecord record) {
|
||||||
if(record.getLevel() != Level.SEVERE)
|
if(record.getLevel() != Level.SEVERE)
|
||||||
@ -28,7 +53,7 @@ public class ErrorLogger extends Handler {
|
|||||||
StringBuilder stacktrace = new StringBuilder(record.getSourceClassName() + "\n" + record.getSourceMethodName());
|
StringBuilder stacktrace = new StringBuilder(record.getSourceClassName() + "\n" + record.getSourceMethodName());
|
||||||
Throwable thrown = record.getThrown();
|
Throwable thrown = record.getThrown();
|
||||||
while(thrown != null){
|
while(thrown != null){
|
||||||
stacktrace.append("\nCaused by").append(thrown.getMessage());
|
stacktrace.append("\nCaused by ").append(thrown.getMessage());
|
||||||
|
|
||||||
for(StackTraceElement ste : thrown.getStackTrace())
|
for(StackTraceElement ste : thrown.getStackTrace())
|
||||||
stacktrace.append("\n").append(ste.toString());
|
stacktrace.append("\n").append(ste.toString());
|
||||||
@ -36,7 +61,8 @@ public class ErrorLogger extends Handler {
|
|||||||
thrown = thrown.getCause();
|
thrown = thrown.getCause();
|
||||||
}
|
}
|
||||||
|
|
||||||
SWException.log("Bungee", MessageFormat.format(record.getMessage(), record.getParameters()), stacktrace.toString());
|
String stacktraceString = stacktrace.toString();
|
||||||
|
SWException.log("Bungee", MessageFormat.format(record.getMessage(), record.getParameters()), stacktraceString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren