Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Make sure to deny 1.12.2 and below clients in "modern" IP forwarding.
Dieser Commit ist enthalten in:
Ursprung
b5ebb4541f
Commit
c2fa5d3ff1
@ -57,7 +57,7 @@ public class VelocityServer implements ProxyServer {
|
|||||||
.registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer())
|
.registerTypeHierarchyAdapter(Favicon.class, new FaviconSerializer())
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
private final ConnectionManager cm = new ConnectionManager();
|
private final ConnectionManager cm = new ConnectionManager(this);
|
||||||
private VelocityConfiguration configuration;
|
private VelocityConfiguration configuration;
|
||||||
private NettyHttpClient httpClient;
|
private NettyHttpClient httpClient;
|
||||||
private KeyPair serverKeyPair;
|
private KeyPair serverKeyPair;
|
||||||
|
@ -6,6 +6,7 @@ import com.velocitypowered.api.event.connection.ConnectionHandshakeEvent;
|
|||||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
||||||
import com.velocitypowered.api.proxy.InboundConnection;
|
import com.velocitypowered.api.proxy.InboundConnection;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
|
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||||
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
@ -26,9 +27,11 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
|
private final VelocityServer server;
|
||||||
|
|
||||||
public HandshakeSessionHandler(MinecraftConnection connection) {
|
public HandshakeSessionHandler(MinecraftConnection connection, VelocityServer server) {
|
||||||
this.connection = Preconditions.checkNotNull(connection, "connection");
|
this.connection = Preconditions.checkNotNull(connection, "connection");
|
||||||
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,6 +77,14 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the proxy is configured for modern forwarding, we must deny connections from 1.12.2 and lower,
|
||||||
|
// otherwise IP information will never get forwarded.
|
||||||
|
if (server.getConfiguration().getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && handshake.getProtocolVersion() <
|
||||||
|
ProtocolConstants.MINECRAFT_1_13) {
|
||||||
|
connection.closeWith(Disconnect.create(TextComponent.of("This server is only compatible with 1.13 and above.")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VelocityServer.getServer().getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
|
VelocityServer.getServer().getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic));
|
||||||
connection.setSessionHandler(new LoginSessionHandler(connection, ic));
|
connection.setSessionHandler(new LoginSessionHandler(connection, ic));
|
||||||
break;
|
break;
|
||||||
|
@ -2,6 +2,7 @@ package com.velocitypowered.proxy.network;
|
|||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import com.velocitypowered.natives.util.Natives;
|
import com.velocitypowered.natives.util.Natives;
|
||||||
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
|
import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||||
@ -53,8 +54,10 @@ public final class ConnectionManager {
|
|||||||
private final TransportType transportType;
|
private final TransportType transportType;
|
||||||
private final EventLoopGroup bossGroup;
|
private final EventLoopGroup bossGroup;
|
||||||
private final EventLoopGroup workerGroup;
|
private final EventLoopGroup workerGroup;
|
||||||
|
private final VelocityServer server;
|
||||||
|
|
||||||
public ConnectionManager() {
|
public ConnectionManager(VelocityServer server) {
|
||||||
|
this.server = server;
|
||||||
this.transportType = TransportType.bestType();
|
this.transportType = TransportType.bestType();
|
||||||
this.bossGroup = transportType.createEventLoopGroup(true);
|
this.bossGroup = transportType.createEventLoopGroup(true);
|
||||||
this.workerGroup = transportType.createEventLoopGroup(false);
|
this.workerGroup = transportType.createEventLoopGroup(false);
|
||||||
@ -83,7 +86,7 @@ public final class ConnectionManager {
|
|||||||
|
|
||||||
final MinecraftConnection connection = new MinecraftConnection(ch);
|
final MinecraftConnection connection = new MinecraftConnection(ch);
|
||||||
connection.setState(StateRegistry.HANDSHAKE);
|
connection.setState(StateRegistry.HANDSHAKE);
|
||||||
connection.setSessionHandler(new HandshakeSessionHandler(connection));
|
connection.setSessionHandler(new HandshakeSessionHandler(connection, server));
|
||||||
ch.pipeline().addLast(Connections.HANDLER, connection);
|
ch.pipeline().addLast(Connections.HANDLER, connection);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren