13
0
geforkt von Mirrors/Velocity
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-01-01 04:34:31 -05:00
Ursprung 0906a436e3
Commit 221ee510ff
6 geänderte Dateien mit 15 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -74,6 +74,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
public boolean handle(ServerLogin packet) {
this.login = packet;
if (mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_13) >= 0) {
// To make sure the connecting client isn't Velocity, send a plugin message that Velocity will
// recognize and respond to.
playerInfoId = ThreadLocalRandom.current().nextInt();
mcConnection.write(new LoginPluginMessage(playerInfoId, VELOCITY_IP_FORWARDING_CHANNEL,
Unpooled.EMPTY_BUFFER));

Datei anzeigen

@ -13,12 +13,9 @@ import io.netty.channel.EventLoopGroup;
import io.netty.channel.WriteBufferWaterMark;
import io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider;
import io.netty.resolver.dns.DnsAddressResolverGroup;
import io.netty.resolver.dns.MultiDnsServerAddressStreamProvider;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -32,6 +29,9 @@ public final class ConnectionManager {
private final EventLoopGroup bossGroup;
private final EventLoopGroup workerGroup;
private final VelocityServer server;
// This is intentionally made public for plugins like ViaVersion, which inject their own
// protocol logic into the proxy.
@SuppressWarnings("WeakerAccess")
public final ServerChannelInitializerHolder serverChannelInitializer;
private final DnsAddressResolverGroup resolverGroup;

Datei anzeigen

@ -52,7 +52,7 @@ public class ServerChannelInitializer extends ChannelInitializer<Channel> {
connection.setSessionHandler(new HandshakeSessionHandler(connection, this.server));
ch.pipeline().addLast(Connections.HANDLER, connection);
if (ServerChannelInitializer.this.server.getConfiguration().isProxyProtocol()) {
if (this.server.getConfiguration().isProxyProtocol()) {
ch.pipeline().addFirst(new HAProxyMessageDecoder());
}
}

Datei anzeigen

@ -11,7 +11,7 @@ public class ServerChannelInitializerHolder implements Supplier<ChannelInitializ
private static final Logger LOGGER = LogManager.getLogger(ConnectionManager.class);
private ChannelInitializer<Channel> initializer;
public ServerChannelInitializerHolder(final ChannelInitializer<Channel> initializer) {
ServerChannelInitializerHolder(final ChannelInitializer<Channel> initializer) {
this.initializer = initializer;
}

Datei anzeigen

@ -25,25 +25,24 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
int expectedUncompressedSize = ProtocolUtils.readVarInt(in);
if (expectedUncompressedSize == 0) {
int expectedSize = ProtocolUtils.readVarInt(in);
if (expectedSize == 0) {
// Strip the now-useless uncompressed size, this message is already uncompressed.
out.add(in.retainedSlice());
in.skipBytes(in.readableBytes());
return;
}
checkFrame(expectedUncompressedSize >= threshold,
"Uncompressed size %s is greater than threshold %s",
expectedUncompressedSize, threshold);
checkFrame(expectedSize >= threshold, "Uncompressed size %s is greater than threshold %s",
expectedSize, threshold);
ByteBuf compatibleIn = ensureCompatible(ctx.alloc(), compressor, in);
int initialCapacity = Math.min(expectedUncompressedSize, MAXIMUM_INITIAL_BUFFER_SIZE);
int initialCapacity = Math.min(expectedSize, MAXIMUM_INITIAL_BUFFER_SIZE);
ByteBuf uncompressed = preferredBuffer(ctx.alloc(), compressor, initialCapacity);
try {
compressor.inflate(compatibleIn, uncompressed);
checkFrame(expectedUncompressedSize == uncompressed.readableBytes(),
checkFrame(expectedSize == uncompressed.readableBytes(),
"Mismatched compression sizes (got %s, expected %s)",
uncompressed.readableBytes(), expectedUncompressedSize);
uncompressed.readableBytes(), expectedSize);
out.add(uncompressed);
} catch (Exception e) {
uncompressed.release();

Datei anzeigen

@ -10,7 +10,7 @@ class VoidArgumentPropertySerializer<T extends ArgumentType<?>>
private final Supplier<T> argumentSupplier;
public VoidArgumentPropertySerializer(Supplier<T> argumentSupplier) {
private VoidArgumentPropertySerializer(Supplier<T> argumentSupplier) {
this.argumentSupplier = argumentSupplier;
}