<1.1.4> Add HAProxy and 1.9-1.12 support to EaglerXVelocity

This commit is contained in:
lax1dude
2024-11-16 17:18:43 -08:00
parent b80d5f6772
commit 4d66ca140a
14 changed files with 156 additions and 68 deletions

View File

@ -17,13 +17,13 @@ package net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity;
*/
public class EaglerXVelocityVersion {
public static final String NATIVE_VELOCITY_BUILD = "3.4.0-SNAPSHOT:99aaf3ce:b439";
public static final String NATIVE_VELOCITY_BUILD = "3.4.0-SNAPSHOT:cefa3b27:b450";
public static final String ID = "EaglerXVelocity";
public static final String PLUGIN_ID = "eaglerxvelocity";
public static final String NAME = "EaglercraftXVelocity";
public static final String DESCRIPTION = "Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks";
public static final String VERSION = "1.1.3";
public static final String VERSION = "1.1.4";
public static final String[] AUTHORS = new String[] { "lax1dude", "ayunami2000" };
}

View File

@ -1,8 +1,8 @@
package net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.api;
import com.velocitypowered.proxy.protocol.util.VelocityLegacyHoverEventSerializer;
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
import net.kyori.adventure.text.serializer.json.LegacyHoverEventSerializer;
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
@ -21,7 +21,21 @@ import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
*/
public class JSONLegacySerializer {
public static final JSONComponentSerializer instance = JSONComponentSerializer.builder()
.legacyHoverEventSerializer(VelocityLegacyHoverEventSerializer.INSTANCE).build();
static {
JSONComponentSerializer.Builder builder = JSONComponentSerializer.builder();
try {
builder.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get());
}catch(Throwable t) {
try {
Class c = Class.forName("com.velocitypowered.proxy.protocol.util.VelocityLegacyHoverEventSerializer");
builder.legacyHoverEventSerializer((LegacyHoverEventSerializer)c.getDeclaredField("INSTANCE").get(null));
}catch(Throwable tt) {
throw new RuntimeException("Legacy hover event serializer is unavailable! (downgrade velocity)");
}
}
instance = builder.build();
}
public static final JSONComponentSerializer instance;
}

View File

@ -71,12 +71,15 @@ public class EaglerListenerConfig {
}
boolean allowMOTD = config.getBoolean("allow_motd", true);
boolean allowQuery = config.getBoolean("allow_query", true);
int minMCProtocol = config.getInt("min_minecraft_protocol", 47);
int maxMCProtocol = config.getInt("max_minecraft_protocol", 340);
boolean allowV3 = config.getBoolean("allow_protocol_v3", true);
boolean allowV4 = config.getBoolean("allow_protocol_v4", true);
if(!allowV3 && !allowV4) {
throw new IllegalArgumentException("Both v3 and v4 protocol are disabled!");
}
int defragSendDelay = config.getInt("protocol_v4_defrag_send_delay", 10);
boolean haproxyProtocol = config.getBoolean("use_haproxy_protocol", false);
int cacheTTL = 7200;
boolean cacheAnimation = false;
@ -152,8 +155,8 @@ public class EaglerListenerConfig {
cacheTrending, cachePortfolios);
return new EaglerListenerConfig(hostv4, hostv6, maxPlayer,
forwardIp, forwardIpHeader, redirectLegacyClientsTo, serverIcon, serverMOTD, allowMOTD, allowQuery,
allowV3, allowV4, defragSendDelay, cacheConfig, httpServer, enableVoiceChat, ratelimitIp,
ratelimitLogin, ratelimitMOTD, ratelimitQuery);
minMCProtocol, maxMCProtocol, allowV3, allowV4, defragSendDelay, haproxyProtocol, cacheConfig,
httpServer, enableVoiceChat, ratelimitIp, ratelimitLogin, ratelimitMOTD, ratelimitQuery);
}
private final InetSocketAddress address;
@ -166,9 +169,12 @@ public class EaglerListenerConfig {
private final List<String> serverMOTD;
private final boolean allowMOTD;
private final boolean allowQuery;
private final int minMCProtocol;
private final int maxMCProtocol;
private final boolean allowV3;
private final boolean allowV4;
private final int defragSendDelay;
private final boolean haproxyProtocol;
private final MOTDCacheConfiguration motdCacheConfig;
private final HttpWebServer webServer;
private boolean serverIconSet = false;
@ -181,10 +187,11 @@ public class EaglerListenerConfig {
public EaglerListenerConfig(InetSocketAddress address, InetSocketAddress addressV6, int maxPlayer,
boolean forwardIp, String forwardIpHeader, String redirectLegacyClientsTo, String serverIcon,
List<String> serverMOTD, boolean allowMOTD, boolean allowQuery, boolean allowV3, boolean allowV4,
int defragSendDelay, MOTDCacheConfiguration motdCacheConfig, HttpWebServer webServer,
boolean enableVoiceChat, EaglerRateLimiter ratelimitIp, EaglerRateLimiter ratelimitLogin,
EaglerRateLimiter ratelimitMOTD, EaglerRateLimiter ratelimitQuery) {
List<String> serverMOTD, boolean allowMOTD, boolean allowQuery, int minMCProtocol, int maxMCProtocol,
boolean allowV3, boolean allowV4, int defragSendDelay, boolean haproxyProtocol,
MOTDCacheConfiguration motdCacheConfig, HttpWebServer webServer, boolean enableVoiceChat,
EaglerRateLimiter ratelimitIp, EaglerRateLimiter ratelimitLogin, EaglerRateLimiter ratelimitMOTD,
EaglerRateLimiter ratelimitQuery) {
this.address = address;
this.addressV6 = addressV6;
this.maxPlayer = maxPlayer;
@ -195,9 +202,12 @@ public class EaglerListenerConfig {
this.serverMOTD = serverMOTD;
this.allowMOTD = allowMOTD;
this.allowQuery = allowQuery;
this.minMCProtocol = minMCProtocol;
this.maxMCProtocol = maxMCProtocol;
this.allowV3 = allowV3;
this.allowV4 = allowV4;
this.defragSendDelay = defragSendDelay;
this.haproxyProtocol = haproxyProtocol;
this.motdCacheConfig = motdCacheConfig;
this.webServer = webServer;
this.enableVoiceChat = enableVoiceChat;
@ -261,6 +271,14 @@ public class EaglerListenerConfig {
return allowQuery;
}
public int getMinMCProtocol() {
return minMCProtocol;
}
public int getMaxMCProtocol() {
return maxMCProtocol;
}
public boolean isAllowV3() {
return allowV3;
}
@ -273,6 +291,10 @@ public class EaglerListenerConfig {
return defragSendDelay;
}
public boolean isHAProxyProtocol() {
return haproxyProtocol;
}
public HttpWebServer getWebServer() {
return webServer;
}

View File

@ -16,11 +16,15 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.scheduler.VelocityScheduler;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.WriteBufferWaterMark;
import io.netty.handler.codec.compression.ZlibCodecFactory;
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
@ -211,7 +215,16 @@ public class EaglerPipeline {
@Override
protected void initChannel(Channel channel) throws Exception {
channel.config().setAllocator(PooledByteBufAllocator.DEFAULT).setWriteBufferWaterMark(SERVER_WRITE_MARK);
try {
channel.config().setOption(ChannelOption.IP_TOS, 24);
} catch (ChannelException var3) {
}
EaglerListenerConfig listener = channel.attr(LISTENER).get();
ChannelPipeline pipeline = channel.pipeline();
if(listener.isHAProxyProtocol()) {
pipeline.addLast("HAProxyMessageDecoder", new HAProxyMessageDecoder());
}
pipeline.addLast("HttpServerCodec", new HttpServerCodec());
pipeline.addLast("HttpObjectAggregator", new HttpObjectAggregator(65535));
int compressionLevel = EaglerXVelocity.getEagler().getConfig().getHttpWebsocketCompressionLevel();
@ -227,7 +240,7 @@ public class EaglerPipeline {
pipeline.addLast("HttpCompressionHandler", new WebSocketServerExtensionHandler(deflateExtensionHandshaker,
perMessageDeflateExtensionHandshaker));
}
pipeline.addLast("HttpHandshakeHandler", new HttpHandshakeHandler(channel.attr(LISTENER).get()));
pipeline.addLast("HttpHandshakeHandler", new HttpHandshakeHandler(listener));
channel.attr(CONNECTION_INSTANCE).set(new EaglerConnectionInstance(channel));
synchronized(openChannels) {
openChannels.add(channel);

View File

@ -10,6 +10,7 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.haproxy.HAProxyMessage;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaders;
@ -48,6 +49,9 @@ public class HttpHandshakeHandler extends ChannelInboundHandlerAdapter {
private static final byte[] error429Bytes = "<h3>429 Too Many Requests<br /><small>(Try again later)</small></h3>".getBytes(StandardCharsets.UTF_8);
private final EaglerListenerConfig conf;
private boolean logExceptions;
private boolean healthCheck;
private InetSocketAddress haproxyRemoteAddr;
public HttpHandshakeHandler(EaglerListenerConfig conf) {
this.conf = conf;
@ -56,18 +60,31 @@ public class HttpHandshakeHandler extends ChannelInboundHandlerAdapter {
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
try {
if (msg instanceof HttpRequest) {
logExceptions = true;
EaglerConnectionInstance pingTracker = ctx.channel().attr(EaglerPipeline.CONNECTION_INSTANCE).get();
HttpRequest req = (HttpRequest) msg;
HttpHeaders headers = req.headers();
String rateLimitHost = null;
SocketAddress addr;
if (conf.isForwardIp()) {
String str = headers.get(conf.getForwardIpHeader());
if (str != null) {
rateLimitHost = str.split(",", 2)[0];
try {
ctx.channel().attr(EaglerPipeline.REAL_ADDRESS).set(InetAddress.getByName(rateLimitHost));
InetAddress inetAddr = InetAddress.getByName(rateLimitHost);
if(haproxyRemoteAddr != null) {
addr = new InetSocketAddress(inetAddr, haproxyRemoteAddr.getPort());
}else {
addr = ctx.channel().remoteAddress();
if(addr instanceof InetSocketAddress) {
addr = new InetSocketAddress(inetAddr, ((InetSocketAddress)addr).getPort());
}else {
addr = new InetSocketAddress(inetAddr, 0);
}
}
ctx.channel().attr(EaglerPipeline.REAL_ADDRESS).set(inetAddr);
} catch (UnknownHostException ex) {
EaglerXVelocity.logger().warn("[{}]: Connected with an invalid '{}' header, disconnecting...", ctx.channel().remoteAddress(), conf.getForwardIpHeader());
ctx.close();
@ -78,8 +95,11 @@ public class HttpHandshakeHandler extends ChannelInboundHandlerAdapter {
ctx.close();
return;
}
} else if(haproxyRemoteAddr != null) {
addr = haproxyRemoteAddr;
ctx.channel().attr(EaglerPipeline.REAL_ADDRESS).set(haproxyRemoteAddr.getAddress());
} else {
SocketAddress addr = ctx.channel().remoteAddress();
addr = ctx.channel().remoteAddress();
if (addr instanceof InetSocketAddress) {
rateLimitHost = ((InetSocketAddress) addr).getAddress().getHostAddress();
}
@ -176,6 +196,19 @@ public class HttpHandshakeHandler extends ChannelInboundHandlerAdapter {
.addListener(ChannelFutureListener.CLOSE);
}
}
} else if (msg instanceof HAProxyMessage) {
logExceptions = true;
HAProxyMessage proxy = (HAProxyMessage) msg;
if(proxy.sourceAddress() != null) {
if(!conf.isForwardIp()) {
try {
haproxyRemoteAddr = new InetSocketAddress(proxy.sourceAddress(), proxy.sourcePort());
}catch(IllegalArgumentException t) {
}
}
}else {
healthCheck = true;
}
} else {
ctx.close();
}
@ -186,15 +219,13 @@ public class HttpHandshakeHandler extends ChannelInboundHandlerAdapter {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (ctx.channel().isActive()) {
EaglerXVelocity.logger().warn("[Pre][{}]: Exception Caught: {}", ctx.channel().remoteAddress(), cause.toString(), cause);
if(logExceptions && !healthCheck) {
EaglerXVelocity.logger().warn("[Pre][{}]: Exception Caught: {}", ctx.channel().remoteAddress(), cause.toString(), cause);
}
ctx.close();
}
}
private static String formatAddressFor404(String str) {
return "<span style=\"font-family:monospace;font-weight:bold;background-color:#EEEEEE;padding:3px 4px;\">" + str.replace("<", "&lt;").replace(">", "&gt;") + "</span>";
}
public void channelInactive(ChannelHandlerContext ctx) {
EaglerPipeline.closeChannel(ctx.channel());
}

View File

@ -13,6 +13,7 @@ import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.haproxy.HAProxyMessage;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
@ -136,7 +137,9 @@ public abstract class HttpServerQueryHandler extends ChannelInboundHandlerAdapte
} else if (msg instanceof CloseWebSocketFrame) {
ctx.close();
}
} else {
}else if(msg instanceof HAProxyMessage) {
EaglerXVelocity.logger().warn("[{}]: Ignoring HAProxyMessage because the WebSocket connection has already been established", ctx.channel().remoteAddress());
}else {
EaglerXVelocity.logger().error("Unexpected Packet: {}", msg.getClass().getSimpleName());
}
} finally {

View File

@ -36,7 +36,6 @@ import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.GameProfile.Property;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
import com.velocitypowered.proxy.connection.ConnectionType;
import com.velocitypowered.proxy.connection.ConnectionTypes;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.client.*;
@ -53,6 +52,7 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.haproxy.HAProxyMessage;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
@ -203,7 +203,9 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
} else if (msg instanceof CloseWebSocketFrame) {
ctx.close();
}
} else {
}else if(msg instanceof HAProxyMessage) {
EaglerXVelocity.logger().warn("[{}]: Ignoring HAProxyMessage because the WebSocket connection has already been established", ctx.channel().remoteAddress());
}else {
EaglerXVelocity.logger().error("Unexpected Packet: {}", msg.getClass().getSimpleName());
}
} finally {
@ -312,8 +314,6 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
EaglerXVelocity eaglerXBungee = EaglerXVelocity.getEagler();
EaglerAuthConfig authConfig = eaglerXBungee.getConfig().getAuthConfig();
final int minecraftProtocolVersion = 47;
int eaglerLegacyProtocolVersion = buffer.readUnsignedByte();
if(eaglerLegacyProtocolVersion == 1) {
@ -321,7 +321,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
sendErrorCode(ctx, HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE, "Please update your client to register on this server!")
.addListener(ChannelFutureListener.CLOSE);
return;
}else if(buffer.readUnsignedByte() != minecraftProtocolVersion || !conf.isAllowV3()) {
} else if (buffer.readUnsignedByte() != 47 || 47 < conf.getMinMCProtocol()
|| 47 > conf.getMaxMCProtocol() || !conf.isAllowV3()) {
clientLoginState = HandshakePacketTypes.STATE_CLIENT_COMPLETE;
connectionClosed = true;
ByteBuf buf = ctx.alloc().buffer();
@ -341,8 +342,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
int maxServerSupported = conf.isAllowV4() ? 4 : 3;
int minAvailableProtVers = Integer.MAX_VALUE;
int maxAvailableProtVers = Integer.MIN_VALUE;
int minSupportedProtVers = Integer.MAX_VALUE;
int maxSupportedProtVers = Integer.MIN_VALUE;
int protVers = -1;
int cnt = buffer.readUnsignedShort();
for(int i = 0; i < cnt; ++i) {
@ -353,53 +353,52 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if(j < minAvailableProtVers) {
minAvailableProtVers = j;
}
if(j >= minServerSupported && j <= maxServerSupported) {
if(j > maxSupportedProtVers) {
maxSupportedProtVers = j;
}
if(j < minSupportedProtVers) {
minSupportedProtVers = j;
}
if(j >= minServerSupported && j <= maxServerSupported && j > protVers) {
protVers = j;
}
}
int minGameVers = Integer.MAX_VALUE;
int maxGameVers = -1;
boolean has47InList = false;
int minGameVers = conf.getMinMCProtocol();
int maxGameVers = conf.getMaxMCProtocol();
int minAvailableGameVers = Integer.MAX_VALUE;
int maxAvailableGameVers = Integer.MIN_VALUE;
int gameVers = -1;
cnt = buffer.readUnsignedShort();
for(int i = 0; i < cnt; ++i) {
int j = buffer.readUnsignedShort();
if(j == minecraftProtocolVersion) {
has47InList = true;
if(j > maxAvailableGameVers) {
maxAvailableGameVers = j;
}
if(j > maxGameVers) {
maxGameVers = j;
if(j < minAvailableGameVers) {
minAvailableGameVers = j;
}
if(j < minGameVers) {
minGameVers = j;
if(j >= minGameVers && j <= maxGameVers && j > gameVers) {
gameVers = j;
}
}
if(maxAvailableProtVers == Integer.MIN_VALUE || maxGameVers == Integer.MIN_VALUE) {
if(maxAvailableProtVers == Integer.MIN_VALUE || maxAvailableGameVers == Integer.MIN_VALUE) {
throw new IOException();
}
boolean versMisMatch = false;
boolean isServerProbablyOutdated = false;
boolean isClientProbablyOutdated = false;
if(maxSupportedProtVers == Integer.MIN_VALUE) {
if(protVers == -1) {
clientProtocolVersion = maxAvailableProtVers < 3 ? 2 : 3;
versMisMatch = true;
isServerProbablyOutdated = minAvailableProtVers > maxServerSupported && maxAvailableProtVers > maxServerSupported;
isClientProbablyOutdated = minAvailableProtVers < minServerSupported && maxAvailableProtVers < minServerSupported;
}else if(!has47InList) {
clientProtocolVersion = 3;
versMisMatch = true;
isServerProbablyOutdated = minGameVers > minecraftProtocolVersion && maxGameVers > minecraftProtocolVersion;
isClientProbablyOutdated = minGameVers < minecraftProtocolVersion && maxGameVers < minecraftProtocolVersion;
}else {
clientProtocolVersion = maxSupportedProtVers;
clientProtocolVersion = protVers;
if(gameVers == -1) {
versMisMatch = true;
isServerProbablyOutdated = minAvailableGameVers > maxGameVers && maxAvailableGameVers > maxGameVers;
isClientProbablyOutdated = minAvailableGameVers < minGameVers && maxAvailableGameVers < minGameVers;
}else {
gameProtocolVersion = gameVers;
}
}
if(versMisMatch) {
@ -417,8 +416,9 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
buf.writeShort(4);
}
buf.writeShort(1);
buf.writeShort(minecraftProtocolVersion); // want game version 47
buf.writeShort(2);
buf.writeShort(minGameVers);
buf.writeShort(maxGameVers);
String str = isClientProbablyOutdated ? "Outdated Client" : (isServerProbablyOutdated ? "Outdated Server" : "Unsupported Client Version");
buf.writeByte(str.length());
@ -450,6 +450,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
boolean useSnapshotFallbackProtocol = false;
if(eaglerLegacyProtocolVersion == 1 && !authConfig.isEnableAuthentication()) {
clientProtocolVersion = 2;
gameProtocolVersion = 47;
useSnapshotFallbackProtocol = true;
clientAuth = false;
clientAuthUsername = null;
@ -481,7 +482,6 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
final boolean final_useSnapshotFallbackProtocol = useSnapshotFallbackProtocol;
Runnable continueThread = () -> {
clientLoginState = HandshakePacketTypes.STATE_CLIENT_VERSION;
gameProtocolVersion = 47;
clientBrandString = eaglerBrand;
clientVersionString = eaglerVersionString;
@ -492,7 +492,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
buf.writeByte(1);
}else {
buf.writeShort(clientProtocolVersion);
buf.writeShort(minecraftProtocolVersion);
buf.writeShort(gameProtocolVersion);
}
String brandStr = EaglerXVelocityVersion.NAME;

View File

@ -27,7 +27,6 @@ import net.lax1dude.eaglercraft.v1_8.plugin.backend_rpc_protocol.pkt.server.SPac
import net.lax1dude.eaglercraft.v1_8.plugin.backend_rpc_protocol.pkt.server.SPacketRPCEventWebViewOpenClose;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.api.EnumVoiceState;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.api.event.EaglercraftVoiceStatusChangeEvent;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.server.EaglerPlayerData;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.voice.VoiceService;
import net.lax1dude.eaglercraft.v1_8.socket.protocol.util.ReusableByteArrayInputStream;

View File

@ -5,9 +5,10 @@ import com.google.gson.JsonObject;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.api.query.EaglerQuerySimpleHandler;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.config.EaglerListenerConfig;
/**
* Copyright (c) 2022-2023 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -27,20 +28,19 @@ public class VersionQueryHandler extends EaglerQuerySimpleHandler {
protected void begin(String queryType) {
JsonObject responseObj = new JsonObject();
JsonArray handshakeVersions = new JsonArray();
if(this.getListener().isAllowV3()) {
EaglerListenerConfig cfg = this.getListener();
if(cfg.isAllowV3()) {
handshakeVersions.add(2);
handshakeVersions.add(3);
}
if(this.getListener().isAllowV4()) {
if(cfg.isAllowV4()) {
handshakeVersions.add(4);
}
responseObj.add("handshakeVersions", handshakeVersions);
JsonArray protocolVersions = new JsonArray();
protocolVersions.add(47);
JsonObject protocolVersions = new JsonObject();
protocolVersions.addProperty("min", cfg.getMinMCProtocol());
protocolVersions.addProperty("max", cfg.getMaxMCProtocol());
responseObj.add("protocolVersions", protocolVersions);
JsonArray gameVersions = new JsonArray();
gameVersions.add("1.8");
responseObj.add("gameVersions", gameVersions);
JsonObject proxyInfo = new JsonObject();
proxyInfo.addProperty("brand", EaglerXVelocity.proxy().getVersion().getName());
proxyInfo.addProperty("vers", EaglerXVelocity.proxy().getVersion().getVersion());

View File

@ -10,9 +10,12 @@ listener_01:
- '&6An EaglercraftX server'
allow_motd: true
allow_query: true
min_minecraft_protocol: 47
max_minecraft_protocol: 340
allow_protocol_v3: true
allow_protocol_v4: true
protocol_v4_defrag_send_delay: 10
use_haproxy_protocol: false
allow_cookie_revoke_query: true
request_motd_cache:
cache_ttl: 7200

View File

@ -1 +1 @@
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.1.3","description":"Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.1.4","description":"Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}