geforkt von Mirrors/Velocity
Minor cleanup.
Dieser Commit ist enthalten in:
Ursprung
0906a436e3
Commit
221ee510ff
@ -74,6 +74,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
public boolean handle(ServerLogin packet) {
|
public boolean handle(ServerLogin packet) {
|
||||||
this.login = packet;
|
this.login = packet;
|
||||||
if (mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_13) >= 0) {
|
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();
|
playerInfoId = ThreadLocalRandom.current().nextInt();
|
||||||
mcConnection.write(new LoginPluginMessage(playerInfoId, VELOCITY_IP_FORWARDING_CHANNEL,
|
mcConnection.write(new LoginPluginMessage(playerInfoId, VELOCITY_IP_FORWARDING_CHANNEL,
|
||||||
Unpooled.EMPTY_BUFFER));
|
Unpooled.EMPTY_BUFFER));
|
||||||
|
@ -13,12 +13,9 @@ import io.netty.channel.EventLoopGroup;
|
|||||||
import io.netty.channel.WriteBufferWaterMark;
|
import io.netty.channel.WriteBufferWaterMark;
|
||||||
import io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider;
|
import io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider;
|
||||||
import io.netty.resolver.dns.DnsAddressResolverGroup;
|
import io.netty.resolver.dns.DnsAddressResolverGroup;
|
||||||
import io.netty.resolver.dns.MultiDnsServerAddressStreamProvider;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@ -32,6 +29,9 @@ public final class ConnectionManager {
|
|||||||
private final EventLoopGroup bossGroup;
|
private final EventLoopGroup bossGroup;
|
||||||
private final EventLoopGroup workerGroup;
|
private final EventLoopGroup workerGroup;
|
||||||
private final VelocityServer server;
|
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;
|
public final ServerChannelInitializerHolder serverChannelInitializer;
|
||||||
|
|
||||||
private final DnsAddressResolverGroup resolverGroup;
|
private final DnsAddressResolverGroup resolverGroup;
|
||||||
|
@ -52,7 +52,7 @@ public class ServerChannelInitializer extends ChannelInitializer<Channel> {
|
|||||||
connection.setSessionHandler(new HandshakeSessionHandler(connection, this.server));
|
connection.setSessionHandler(new HandshakeSessionHandler(connection, this.server));
|
||||||
ch.pipeline().addLast(Connections.HANDLER, connection);
|
ch.pipeline().addLast(Connections.HANDLER, connection);
|
||||||
|
|
||||||
if (ServerChannelInitializer.this.server.getConfiguration().isProxyProtocol()) {
|
if (this.server.getConfiguration().isProxyProtocol()) {
|
||||||
ch.pipeline().addFirst(new HAProxyMessageDecoder());
|
ch.pipeline().addFirst(new HAProxyMessageDecoder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class ServerChannelInitializerHolder implements Supplier<ChannelInitializ
|
|||||||
private static final Logger LOGGER = LogManager.getLogger(ConnectionManager.class);
|
private static final Logger LOGGER = LogManager.getLogger(ConnectionManager.class);
|
||||||
private ChannelInitializer<Channel> initializer;
|
private ChannelInitializer<Channel> initializer;
|
||||||
|
|
||||||
public ServerChannelInitializerHolder(final ChannelInitializer<Channel> initializer) {
|
ServerChannelInitializerHolder(final ChannelInitializer<Channel> initializer) {
|
||||||
this.initializer = initializer;
|
this.initializer = initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,25 +25,24 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
int expectedUncompressedSize = ProtocolUtils.readVarInt(in);
|
int expectedSize = ProtocolUtils.readVarInt(in);
|
||||||
if (expectedUncompressedSize == 0) {
|
if (expectedSize == 0) {
|
||||||
// Strip the now-useless uncompressed size, this message is already uncompressed.
|
// Strip the now-useless uncompressed size, this message is already uncompressed.
|
||||||
out.add(in.retainedSlice());
|
out.add(in.retainedSlice());
|
||||||
in.skipBytes(in.readableBytes());
|
in.skipBytes(in.readableBytes());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkFrame(expectedUncompressedSize >= threshold,
|
checkFrame(expectedSize >= threshold, "Uncompressed size %s is greater than threshold %s",
|
||||||
"Uncompressed size %s is greater than threshold %s",
|
expectedSize, threshold);
|
||||||
expectedUncompressedSize, threshold);
|
|
||||||
ByteBuf compatibleIn = ensureCompatible(ctx.alloc(), compressor, in);
|
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);
|
ByteBuf uncompressed = preferredBuffer(ctx.alloc(), compressor, initialCapacity);
|
||||||
try {
|
try {
|
||||||
compressor.inflate(compatibleIn, uncompressed);
|
compressor.inflate(compatibleIn, uncompressed);
|
||||||
checkFrame(expectedUncompressedSize == uncompressed.readableBytes(),
|
checkFrame(expectedSize == uncompressed.readableBytes(),
|
||||||
"Mismatched compression sizes (got %s, expected %s)",
|
"Mismatched compression sizes (got %s, expected %s)",
|
||||||
uncompressed.readableBytes(), expectedUncompressedSize);
|
uncompressed.readableBytes(), expectedSize);
|
||||||
out.add(uncompressed);
|
out.add(uncompressed);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
uncompressed.release();
|
uncompressed.release();
|
||||||
|
@ -10,7 +10,7 @@ class VoidArgumentPropertySerializer<T extends ArgumentType<?>>
|
|||||||
|
|
||||||
private final Supplier<T> argumentSupplier;
|
private final Supplier<T> argumentSupplier;
|
||||||
|
|
||||||
public VoidArgumentPropertySerializer(Supplier<T> argumentSupplier) {
|
private VoidArgumentPropertySerializer(Supplier<T> argumentSupplier) {
|
||||||
this.argumentSupplier = argumentSupplier;
|
this.argumentSupplier = argumentSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren