geforkt von Mirrors/Velocity
Properly block connecting to Velocity with legacy forwarding.
I also took the opportunity to improve the disconnect handling for Disconnect messages from the server.
Dieser Commit ist enthalten in:
Ursprung
44c4221e19
Commit
1e178cfe2a
@ -208,7 +208,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
} else {
|
} else {
|
||||||
logger.error("{}: disconnected while connecting to {}: {}", this, info.getName(), plainTextReason);
|
logger.error("{}: disconnected while connecting to {}: {}", this, info.getName(), plainTextReason);
|
||||||
}
|
}
|
||||||
handleConnectionException(info, disconnectReason);
|
handleConnectionException(info, TextComponent.builder()
|
||||||
|
.content("Unable to connect to " + info.getName() + ": ")
|
||||||
|
.color(TextColor.RED)
|
||||||
|
.append(disconnectReason)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleConnectionException(ServerInfo info, Component disconnectReason) {
|
public void handleConnectionException(ServerInfo info, Component disconnectReason) {
|
||||||
|
@ -55,18 +55,27 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
case StateRegistry.LOGIN_ID:
|
case StateRegistry.LOGIN_ID:
|
||||||
connection.setState(StateRegistry.LOGIN);
|
connection.setState(StateRegistry.LOGIN);
|
||||||
connection.setProtocolVersion(handshake.getProtocolVersion());
|
connection.setProtocolVersion(handshake.getProtocolVersion());
|
||||||
|
|
||||||
if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) {
|
if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) {
|
||||||
connection.closeWith(Disconnect.create(TranslatableComponent.of("multiplayer.disconnect.outdated_client")));
|
connection.closeWith(Disconnect.create(TranslatableComponent.of("multiplayer.disconnect.outdated_client")));
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
InetAddress address = ((InetSocketAddress) connection.getChannel().remoteAddress()).getAddress();
|
|
||||||
if (!VelocityServer.getServer().getIpAttemptLimiter().attempt(address)) {
|
|
||||||
connection.closeWith(Disconnect.create(TextComponent.of("You are logging in too fast, try again later.")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
VelocityServer.getServer().getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
|
|
||||||
connection.setSessionHandler(new LoginSessionHandler(connection, ic));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InetAddress address = ((InetSocketAddress) connection.getChannel().remoteAddress()).getAddress();
|
||||||
|
if (!VelocityServer.getServer().getIpAttemptLimiter().attempt(address)) {
|
||||||
|
connection.closeWith(Disconnect.create(TextComponent.of("You are logging in too fast, try again later.")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure legacy forwarding is not in use on this connection. Make sure that we do _not_ reject Forge,
|
||||||
|
// although Velocity does not yet support Forge.
|
||||||
|
if (handshake.getServerAddress().contains("\0") && !handshake.getServerAddress().endsWith("\0FML\0")) {
|
||||||
|
connection.closeWith(Disconnect.create(TextComponent.of("Running Velocity behind Velocity is unsupported.")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityServer.getServer().getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
|
||||||
|
connection.setSessionHandler(new LoginSessionHandler(connection, ic));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid state " + handshake.getNextStatus());
|
throw new IllegalArgumentException("Invalid state " + handshake.getNextStatus());
|
||||||
|
@ -56,7 +56,7 @@ public class Handshake implements MinecraftPacket {
|
|||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||||
this.protocolVersion = ProtocolUtils.readVarInt(buf);
|
this.protocolVersion = ProtocolUtils.readVarInt(buf);
|
||||||
this.serverAddress = ProtocolUtils.readString(buf, 255);
|
this.serverAddress = ProtocolUtils.readString(buf);
|
||||||
this.port = buf.readUnsignedShort();
|
this.port = buf.readUnsignedShort();
|
||||||
this.nextStatus = ProtocolUtils.readVarInt(buf);
|
this.nextStatus = ProtocolUtils.readVarInt(buf);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren