push update

This commit is contained in:
ayunami2000 2024-06-21 10:08:15 -04:00
parent 790b33ad68
commit 757018828d
13 changed files with 42 additions and 32 deletions

View File

@ -10,5 +10,5 @@ repositories {
} }
dependencies { dependencies {
implementation files("libs/ViaProxy-3.2.0-SNAPSHOT+java8.jar") implementation files("libs/ViaProxy-3.3.0-SNAPSHOT+java8.jar")
} }

View File

@ -22,9 +22,9 @@ import net.raphimc.netminecraft.constants.MCPackets;
import net.raphimc.netminecraft.netty.connection.NetClient; import net.raphimc.netminecraft.netty.connection.NetClient;
import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.PacketTypes;
import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ClientboundPackets1_5_2; import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.packet.ClientboundPackets1_5_2;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2; import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.packet.ServerboundPackets1_5_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.viaproxy.proxy.session.LegacyProxyConnection; import net.raphimc.viaproxy.proxy.session.LegacyProxyConnection;
import net.raphimc.viaproxy.proxy.session.ProxyConnection; import net.raphimc.viaproxy.proxy.session.ProxyConnection;
import net.raphimc.viaproxy.proxy.util.ExceptionUtil; import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
@ -60,7 +60,7 @@ public class EaglerServerHandler extends MessageToMessageCodec<WebSocketFrame, B
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
private int handshakeState = 0; private int handshakeState = 0;
@ -412,7 +412,7 @@ public class EaglerServerHandler extends MessageToMessageCodec<WebSocketFrame, B
handshakeState = 3; handshakeState = 3;
ConnectionHandshake.attemptHandshake3(ctx.channel(), ByteBufUtil.getBytes(in.content()), (ProxyConnection) proxyConnection); ConnectionHandshake.attemptHandshake3(ctx.channel(), ByteBufUtil.getBytes(in.content()), (ProxyConnection) proxyConnection);
ByteBuf bb = ctx.alloc().buffer(); ByteBuf bb = ctx.alloc().buffer();
PacketTypes.writeVarInt(bb, MCPackets.S2C_LOGIN_SUCCESS.getId(version.getVersion())); PacketTypes.writeVarInt(bb, MCPackets.S2C_LOGIN_GAME_PROFILE.getId(version.getVersion()));
PacketTypes.writeString(bb, ((ProxyConnection) proxyConnection).getGameProfile().getId().toString()); PacketTypes.writeString(bb, ((ProxyConnection) proxyConnection).getGameProfile().getId().toString());
PacketTypes.writeString(bb, ((ProxyConnection) proxyConnection).getGameProfile().getName()); PacketTypes.writeString(bb, ((ProxyConnection) proxyConnection).getGameProfile().getName());
out.add(bb); out.add(bb);
@ -421,7 +421,7 @@ public class EaglerServerHandler extends MessageToMessageCodec<WebSocketFrame, B
ConnectionHandshake.attemptHandshake4(ctx.channel(), ByteBufUtil.getBytes(in.content()), (ProxyConnection) proxyConnection); ConnectionHandshake.attemptHandshake4(ctx.channel(), ByteBufUtil.getBytes(in.content()), (ProxyConnection) proxyConnection);
out.add(Unpooled.EMPTY_BUFFER); out.add(Unpooled.EMPTY_BUFFER);
} else { } else {
if (in.content().getByte(0) == MCPackets.S2C_LOGIN_SUCCESS.getId(version.getVersion()) && in.content().getByte(1) == 0 && in.content().getByte(2) == 2) { if (in.content().getByte(0) == MCPackets.S2C_LOGIN_GAME_PROFILE.getId(version.getVersion()) && in.content().getByte(1) == 0 && in.content().getByte(2) == 2) {
out.add(Unpooled.EMPTY_BUFFER); out.add(Unpooled.EMPTY_BUFFER);
return; return;
} }

View File

@ -6,7 +6,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.proxy.util.ExceptionUtil; import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
@ -50,7 +50,7 @@ public class EaglerSkinHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
@Override @Override

View File

@ -5,7 +5,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.PacketTypes;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.viaproxy.proxy.util.ExceptionUtil; import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
import java.io.*; import java.io.*;
@ -34,7 +34,7 @@ public class EaglerVoiceHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
private static UUID nameToUUID(String name) { private static UUID nameToUUID(String name) {

View File

@ -18,7 +18,7 @@ public class EaglerXLoginHandler extends ChannelOutboundHandlerAdapter {
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
@Override @Override

View File

@ -24,7 +24,7 @@ public class EaglerXSkinHandler extends ChannelInboundHandlerAdapter {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
@Override @Override

View File

@ -24,8 +24,8 @@ import net.raphimc.netminecraft.constants.MCPackets;
import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.constants.MCPipeline;
import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.PacketTypes;
import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2; import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.packet.ServerboundPackets1_5_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer; import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
import net.raphimc.viaproxy.proxy.util.ExceptionUtil; import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
@ -258,7 +258,7 @@ public class EaglercraftHandler extends MessageToMessageCodec<WebSocketFrame, By
throw new IllegalArgumentException("Too much data in packet: " + data.readableBytes() + " bytes"); throw new IllegalArgumentException("Too much data in packet: " + data.readableBytes() + " bytes");
} }
this.state = State.LOGIN_COMPLETE; this.state = State.LOGIN_COMPLETE;
this.pluginMessageId = MCPackets.C2S_PLUGIN_MESSAGE.getId(this.version.getVersion()); this.pluginMessageId = MCPackets.C2S_CUSTOM_PAYLOAD.getId(this.version.getVersion());
if (this.pluginMessageId == -1) { if (this.pluginMessageId == -1) {
Logger.LOGGER.error("Unsupported protocol version: " + this.version.getVersion()); Logger.LOGGER.error("Unsupported protocol version: " + this.version.getVersion());
ctx.close(); ctx.close();
@ -286,7 +286,7 @@ public class EaglercraftHandler extends MessageToMessageCodec<WebSocketFrame, By
break; break;
} }
if (!ctx.channel().hasAttr(Main.secureWs) || ctx.channel().attr(Main.secureWs) == null) { if (!ctx.channel().hasAttr(Main.secureWs) || ctx.channel().attr(Main.secureWs) == null) {
if (packetId == ServerboundPackets1_5_2.PLUGIN_MESSAGE.getId() && Types1_6_4.STRING.read(data).startsWith("EAG|")) { if (packetId == ServerboundPackets1_5_2.CUSTOM_PAYLOAD.getId() && Types1_6_4.STRING.read(data).startsWith("EAG|")) {
break; break;
} }
} }
@ -364,7 +364,7 @@ public class EaglercraftHandler extends MessageToMessageCodec<WebSocketFrame, By
} }
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
public enum State { public enum State {

View File

@ -30,6 +30,7 @@ import java.util.function.Supplier;
public class EaglercraftInitialHandler extends ByteToMessageDecoder { public class EaglercraftInitialHandler extends ByteToMessageDecoder {
private static final Method initChannelMethod; private static final Method initChannelMethod;
public static SslContext sslContext; public static SslContext sslContext;
private static long lastTime = 0;
@Override @Override
protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) { protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) {
@ -40,10 +41,11 @@ public class EaglercraftInitialHandler extends ByteToMessageDecoder {
return; return;
} }
if (in.readableBytes() >= 3 || in.getByte(0) != 71) { if (in.readableBytes() >= 3 || in.getByte(0) != 71) {
boolean ssl = EaglercraftInitialHandler.sslContext != null && in.readableBytes() >= 3 && in.getByte(0) == 22; renewCerts();
boolean ssl = sslContext != null && in.readableBytes() >= 3 && in.getByte(0) == 22;
if (ssl || (in.readableBytes() >= 3 && in.getCharSequence(0, 3, StandardCharsets.UTF_8).equals("GET")) || (in.readableBytes() >= 4 && in.getCharSequence(0, 4, StandardCharsets.UTF_8).equals("POST"))) { if (ssl || (in.readableBytes() >= 3 && in.getCharSequence(0, 3, StandardCharsets.UTF_8).equals("GET")) || (in.readableBytes() >= 4 && in.getCharSequence(0, 4, StandardCharsets.UTF_8).equals("POST"))) {
if (ssl) { if (ssl) {
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-ssl-handler", EaglercraftInitialHandler.sslContext.newHandler(ctx.alloc())); ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-ssl-handler", sslContext.newHandler(ctx.alloc()));
} }
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-http-codec", new HttpServerCodec()); ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-http-codec", new HttpServerCodec());
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-http-aggregator", new HttpObjectAggregator(65535, true)); ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-http-aggregator", new HttpObjectAggregator(65535, true));
@ -98,15 +100,22 @@ public class EaglercraftInitialHandler extends ByteToMessageDecoder {
} }
} }
static { public static void renewCerts() {
final long currTime = System.currentTimeMillis();
if (currTime - lastTime <= 1000 * 60 * 60) return;
lastTime = currTime;
final File certFolder = new File("certs"); final File certFolder = new File("certs");
if (certFolder.exists()) { if (certFolder.exists()) {
try { try {
EaglercraftInitialHandler.sslContext = SslContextBuilder.forServer(new File(certFolder, "fullchain.pem"), new File(certFolder, "privkey.pem")).build(); sslContext = SslContextBuilder.forServer(new File(certFolder, "fullchain.pem"), new File(certFolder, "privkey.pem")).build();
} catch (Throwable e) { } catch (Throwable e) {
throw new RuntimeException("Failed to load SSL context", e); throw new RuntimeException("Failed to load SSL context", e);
} }
} }
}
static {
renewCerts();
try { try {
initChannelMethod = PassthroughClient2ProxyChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class); initChannelMethod = PassthroughClient2ProxyChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class);
initChannelMethod.setAccessible(true); initChannelMethod.setAccessible(true);
@ -121,6 +130,6 @@ public class EaglercraftInitialHandler extends ByteToMessageDecoder {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
} }

View File

@ -7,6 +7,7 @@ import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
public class FunnyConfig extends Config { public class FunnyConfig extends Config {
public static boolean premiumSkins = false; public static boolean premiumSkins = false;
@ -15,7 +16,7 @@ public class FunnyConfig extends Config {
public static int eaglerServerMode = 0; public static int eaglerServerMode = 0;
protected FunnyConfig(File configFile) { protected FunnyConfig(File configFile) {
super(configFile); super(configFile, Logger.getLogger("FunnyConfig"));
} }
@Override @Override

View File

@ -18,7 +18,7 @@ import io.netty.util.AttributeKey;
import net.lenni0451.lambdaevents.EventHandler; import net.lenni0451.lambdaevents.EventHandler;
import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.constants.MCPipeline;
import net.raphimc.netminecraft.netty.connection.NetClient; import net.raphimc.netminecraft.netty.connection.NetClient;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.plugins.ViaProxyPlugin; import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent; import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
@ -175,7 +175,7 @@ public class Main extends ViaProxyPlugin {
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) { public void channelInactive(ChannelHandlerContext ctx) {
if (this.handshakeFuture().cause() != null) { if (this.handshakeFuture().cause() != null) {
ExceptionUtil.handleNettyException(ctx, this.handshakeFuture().cause(), null); ExceptionUtil.handleNettyException(ctx, this.handshakeFuture().cause(), null, true);
} }
super.closeOutbound(); super.closeOutbound();
} }
@ -226,7 +226,7 @@ public class Main extends ViaProxyPlugin {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
} }
@ -255,7 +255,7 @@ public class Main extends ViaProxyPlugin {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
} }
} }

View File

@ -25,7 +25,7 @@ public class SkinService {
private static void sendData(final ChannelHandlerContext ctx, final byte[] data) { private static void sendData(final ChannelHandlerContext ctx, final byte[] data) {
final ByteBuf bb = ctx.alloc().buffer(); final ByteBuf bb = ctx.alloc().buffer();
PacketTypes.writeVarInt(bb, MCPackets.S2C_PLUGIN_MESSAGE.getId((((EaglercraftHandler) ctx.pipeline().get("eaglercraft-handler")).version).getVersion())); PacketTypes.writeVarInt(bb, MCPackets.S2C_CUSTOM_PAYLOAD.getId((((EaglercraftHandler) ctx.pipeline().get("eaglercraft-handler")).version).getVersion()));
PacketTypes.writeString(bb, "EAG|Skins-1.8"); PacketTypes.writeString(bb, "EAG|Skins-1.8");
bb.writeBytes(data); bb.writeBytes(data);
ctx.writeAndFlush(new BinaryWebSocketFrame(bb)); ctx.writeAndFlush(new BinaryWebSocketFrame(bb));

View File

@ -5,7 +5,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import net.raphimc.netminecraft.constants.MCPackets; import net.raphimc.netminecraft.constants.MCPackets;
import net.raphimc.netminecraft.packet.PacketTypes; import net.raphimc.netminecraft.packet.PacketTypes;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
@ -165,7 +165,7 @@ public class VoiceServerImpl {
bb.setShort(21, bb.writerIndex() - 23); bb.setShort(21, bb.writerIndex() - 23);
} else { } else {
if (pluginMessageId <= 0) { if (pluginMessageId <= 0) {
pluginMessageId = MCPackets.S2C_PLUGIN_MESSAGE.getId((((EaglercraftHandler) ctx.pipeline().get("eaglercraft-handler")).version).getVersion()); pluginMessageId = MCPackets.S2C_CUSTOM_PAYLOAD.getId((((EaglercraftHandler) ctx.pipeline().get("eaglercraft-handler")).version).getVersion());
} }
PacketTypes.writeVarInt(bb, pluginMessageId); PacketTypes.writeVarInt(bb, pluginMessageId);
PacketTypes.writeString(bb, "EAG|Voice-1.8"); PacketTypes.writeString(bb, "EAG|Voice-1.8");

View File

@ -21,6 +21,6 @@ public class WebSocketActiveNotifier extends ChannelInboundHandlerAdapter {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ExceptionUtil.handleNettyException(ctx, cause, null); ExceptionUtil.handleNettyException(ctx, cause, null, true);
} }
} }