geforkt von Mirrors/Velocity
Suppress invalid protocol spam
Dieser Commit ist enthalten in:
Ursprung
aff06164cd
Commit
1824c7ad7e
@ -26,9 +26,13 @@ import java.util.Optional;
|
|||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.TranslatableComponent;
|
import net.kyori.text.TranslatableComponent;
|
||||||
import net.kyori.text.format.TextColor;
|
import net.kyori.text.format.TextColor;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(HandshakeSessionHandler.class);
|
||||||
|
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
|
|
||||||
@ -58,11 +62,11 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
public boolean handle(Handshake handshake) {
|
public boolean handle(Handshake handshake) {
|
||||||
InitialInboundConnection ic = new InitialInboundConnection(connection,
|
InitialInboundConnection ic = new InitialInboundConnection(connection,
|
||||||
cleanVhost(handshake.getServerAddress()), handshake);
|
cleanVhost(handshake.getServerAddress()), handshake);
|
||||||
connection.setAssociation(ic);
|
|
||||||
switch (handshake.getNextStatus()) {
|
switch (handshake.getNextStatus()) {
|
||||||
case StateRegistry.STATUS_ID:
|
case StateRegistry.STATUS_ID:
|
||||||
connection.setState(StateRegistry.STATUS);
|
connection.setState(StateRegistry.STATUS);
|
||||||
connection.setProtocolVersion(handshake.getProtocolVersion());
|
connection.setProtocolVersion(handshake.getProtocolVersion());
|
||||||
|
connection.setAssociation(ic);
|
||||||
connection.setSessionHandler(new StatusSessionHandler(server, connection, ic));
|
connection.setSessionHandler(new StatusSessionHandler(server, connection, ic));
|
||||||
return true;
|
return true;
|
||||||
case StateRegistry.LOGIN_ID:
|
case StateRegistry.LOGIN_ID:
|
||||||
@ -101,11 +105,14 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connection.setAssociation(ic);
|
||||||
server.getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
|
server.getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
|
||||||
connection.setSessionHandler(new LoginSessionHandler(server, connection, ic));
|
connection.setSessionHandler(new LoginSessionHandler(server, connection, ic));
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid state " + handshake.getNextStatus());
|
LOGGER.error("{} provided invalid protocol {}", ic, handshake.getNextStatus());
|
||||||
|
connection.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren