13
0
geforkt von Mirrors/Velocity

Suppress invalid protocol spam

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-09-27 22:23:40 -04:00
Ursprung 9141ea112f
Commit 546307b0d6

Datei anzeigen

@ -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;
} }
} }