Skip to content

Commit 7570188

Browse files
committed
push update
1 parent 790b33a commit 7570188

13 files changed

+42
-32
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ repositories {
1010
}
1111

1212
dependencies {
13-
implementation files("libs/ViaProxy-3.2.0-SNAPSHOT+java8.jar")
13+
implementation files("libs/ViaProxy-3.3.0-SNAPSHOT+java8.jar")
1414
}

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglerServerHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import net.raphimc.netminecraft.netty.connection.NetClient;
2323
import net.raphimc.netminecraft.packet.PacketTypes;
2424
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
25-
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ClientboundPackets1_5_2;
26-
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2;
27-
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
25+
import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.packet.ClientboundPackets1_5_2;
26+
import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.packet.ServerboundPackets1_5_2;
27+
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
2828
import net.raphimc.viaproxy.proxy.session.LegacyProxyConnection;
2929
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
3030
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
@@ -60,7 +60,7 @@ public EaglerServerHandler(NetClient proxyConnection, String password) {
6060

6161
@Override
6262
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
63-
ExceptionUtil.handleNettyException(ctx, cause, null);
63+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
6464
}
6565

6666
private int handshakeState = 0;
@@ -412,7 +412,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
412412
handshakeState = 3;
413413
ConnectionHandshake.attemptHandshake3(ctx.channel(), ByteBufUtil.getBytes(in.content()), (ProxyConnection) proxyConnection);
414414
ByteBuf bb = ctx.alloc().buffer();
415-
PacketTypes.writeVarInt(bb, MCPackets.S2C_LOGIN_SUCCESS.getId(version.getVersion()));
415+
PacketTypes.writeVarInt(bb, MCPackets.S2C_LOGIN_GAME_PROFILE.getId(version.getVersion()));
416416
PacketTypes.writeString(bb, ((ProxyConnection) proxyConnection).getGameProfile().getId().toString());
417417
PacketTypes.writeString(bb, ((ProxyConnection) proxyConnection).getGameProfile().getName());
418418
out.add(bb);
@@ -421,7 +421,7 @@ public void decode(ChannelHandlerContext ctx, WebSocketFrame in, List<Object> ou
421421
ConnectionHandshake.attemptHandshake4(ctx.channel(), ByteBufUtil.getBytes(in.content()), (ProxyConnection) proxyConnection);
422422
out.add(Unpooled.EMPTY_BUFFER);
423423
} else {
424-
if (in.content().getByte(0) == MCPackets.S2C_LOGIN_SUCCESS.getId(version.getVersion()) && in.content().getByte(1) == 0 && in.content().getByte(2) == 2) {
424+
if (in.content().getByte(0) == MCPackets.S2C_LOGIN_GAME_PROFILE.getId(version.getVersion()) && in.content().getByte(1) == 0 && in.content().getByte(2) == 2) {
425425
out.add(Unpooled.EMPTY_BUFFER);
426426
return;
427427
}

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglerSkinHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io.netty.channel.ChannelHandlerContext;
77
import io.netty.channel.ChannelInboundHandlerAdapter;
88
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
9-
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
9+
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
1010
import net.raphimc.viaproxy.ViaProxy;
1111
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
1212

@@ -50,7 +50,7 @@ public EaglerSkinHandler(final String username) {
5050

5151
@Override
5252
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
53-
ExceptionUtil.handleNettyException(ctx, cause, null);
53+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
5454
}
5555

5656
@Override

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglerVoiceHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.netty.channel.ChannelInboundHandlerAdapter;
66
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
77
import net.raphimc.netminecraft.packet.PacketTypes;
8-
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
8+
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
99
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
1010

1111
import java.io.*;
@@ -34,7 +34,7 @@ public EaglerVoiceHandler(final String username) {
3434

3535
@Override
3636
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
37-
ExceptionUtil.handleNettyException(ctx, cause, null);
37+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
3838
}
3939

4040
private static UUID nameToUUID(String name) {

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglerXLoginHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public EaglerXLoginHandler() {
1818
@Override
1919
@SuppressWarnings("deprecation")
2020
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
21-
ExceptionUtil.handleNettyException(ctx, cause, null);
21+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
2222
}
2323

2424
@Override

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglerXSkinHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public EaglerXSkinHandler() {
2424

2525
@Override
2626
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
27-
ExceptionUtil.handleNettyException(ctx, cause, null);
27+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
2828
}
2929

3030
@Override

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglercraftHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import net.raphimc.netminecraft.constants.MCPipeline;
2525
import net.raphimc.netminecraft.packet.PacketTypes;
2626
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
27-
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2;
28-
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
27+
import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.packet.ServerboundPackets1_5_2;
28+
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
2929
import net.raphimc.viaproxy.ViaProxy;
3030
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
3131
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
@@ -258,7 +258,7 @@ protected void decode(final ChannelHandlerContext ctx, final WebSocketFrame in,
258258
throw new IllegalArgumentException("Too much data in packet: " + data.readableBytes() + " bytes");
259259
}
260260
this.state = State.LOGIN_COMPLETE;
261-
this.pluginMessageId = MCPackets.C2S_PLUGIN_MESSAGE.getId(this.version.getVersion());
261+
this.pluginMessageId = MCPackets.C2S_CUSTOM_PAYLOAD.getId(this.version.getVersion());
262262
if (this.pluginMessageId == -1) {
263263
Logger.LOGGER.error("Unsupported protocol version: " + this.version.getVersion());
264264
ctx.close();
@@ -286,7 +286,7 @@ protected void decode(final ChannelHandlerContext ctx, final WebSocketFrame in,
286286
break;
287287
}
288288
if (!ctx.channel().hasAttr(Main.secureWs) || ctx.channel().attr(Main.secureWs) == null) {
289-
if (packetId == ServerboundPackets1_5_2.PLUGIN_MESSAGE.getId() && Types1_6_4.STRING.read(data).startsWith("EAG|")) {
289+
if (packetId == ServerboundPackets1_5_2.CUSTOM_PAYLOAD.getId() && Types1_6_4.STRING.read(data).startsWith("EAG|")) {
290290
break;
291291
}
292292
}
@@ -364,7 +364,7 @@ private ByteBuf writeHandshake(final ByteBuf byteBuf, final ConnectionState stat
364364
}
365365

366366
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
367-
ExceptionUtil.handleNettyException(ctx, cause, null);
367+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
368368
}
369369

370370
public enum State {

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/EaglercraftInitialHandler.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
public class EaglercraftInitialHandler extends ByteToMessageDecoder {
3131
private static final Method initChannelMethod;
3232
public static SslContext sslContext;
33+
private static long lastTime = 0;
3334

3435
@Override
3536
protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) {
@@ -40,10 +41,11 @@ protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final L
4041
return;
4142
}
4243
if (in.readableBytes() >= 3 || in.getByte(0) != 71) {
43-
boolean ssl = EaglercraftInitialHandler.sslContext != null && in.readableBytes() >= 3 && in.getByte(0) == 22;
44+
renewCerts();
45+
boolean ssl = sslContext != null && in.readableBytes() >= 3 && in.getByte(0) == 22;
4446
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"))) {
4547
if (ssl) {
46-
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-ssl-handler", EaglercraftInitialHandler.sslContext.newHandler(ctx.alloc()));
48+
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-ssl-handler", sslContext.newHandler(ctx.alloc()));
4749
}
4850
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-http-codec", new HttpServerCodec());
4951
ctx.pipeline().addBefore("eaglercraft-initial-handler", "ws-http-aggregator", new HttpObjectAggregator(65535, true));
@@ -98,15 +100,22 @@ protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
98100
}
99101
}
100102

101-
static {
103+
public static void renewCerts() {
104+
final long currTime = System.currentTimeMillis();
105+
if (currTime - lastTime <= 1000 * 60 * 60) return;
106+
lastTime = currTime;
102107
final File certFolder = new File("certs");
103108
if (certFolder.exists()) {
104109
try {
105-
EaglercraftInitialHandler.sslContext = SslContextBuilder.forServer(new File(certFolder, "fullchain.pem"), new File(certFolder, "privkey.pem")).build();
110+
sslContext = SslContextBuilder.forServer(new File(certFolder, "fullchain.pem"), new File(certFolder, "privkey.pem")).build();
106111
} catch (Throwable e) {
107112
throw new RuntimeException("Failed to load SSL context", e);
108113
}
109114
}
115+
}
116+
117+
static {
118+
renewCerts();
110119
try {
111120
initChannelMethod = PassthroughClient2ProxyChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class);
112121
initChannelMethod.setAccessible(true);
@@ -121,6 +130,6 @@ public static final class EaglercraftClientConnected {
121130

122131
@Override
123132
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
124-
ExceptionUtil.handleNettyException(ctx, cause, null);
133+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
125134
}
126135
}

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/FunnyConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Collections;
88
import java.util.List;
99
import java.util.Map;
10+
import java.util.logging.Logger;
1011

1112
public class FunnyConfig extends Config {
1213
public static boolean premiumSkins = false;
@@ -15,7 +16,7 @@ public class FunnyConfig extends Config {
1516
public static int eaglerServerMode = 0;
1617

1718
protected FunnyConfig(File configFile) {
18-
super(configFile);
19+
super(configFile, Logger.getLogger("FunnyConfig"));
1920
}
2021

2122
@Override

src/main/java/me/ayunami2000/ayunViaProxyEagUtils/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import net.lenni0451.lambdaevents.EventHandler;
1919
import net.raphimc.netminecraft.constants.MCPipeline;
2020
import net.raphimc.netminecraft.netty.connection.NetClient;
21-
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
21+
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
2222
import net.raphimc.viaproxy.ViaProxy;
2323
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
2424
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
@@ -175,7 +175,7 @@ private static void doWsServerStuff(Channel ch, NetClient proxyConnection, Chann
175175
@Override
176176
public void channelInactive(ChannelHandlerContext ctx) {
177177
if (this.handshakeFuture().cause() != null) {
178-
ExceptionUtil.handleNettyException(ctx, this.handshakeFuture().cause(), null);
178+
ExceptionUtil.handleNettyException(ctx, this.handshakeFuture().cause(), null, true);
179179
}
180180
super.closeOutbound();
181181
}
@@ -226,7 +226,7 @@ public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt
226226

227227
@Override
228228
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
229-
ExceptionUtil.handleNettyException(ctx, cause, null);
229+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
230230
}
231231
}
232232

@@ -255,7 +255,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) throw
255255

256256
@Override
257257
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
258-
ExceptionUtil.handleNettyException(ctx, cause, null);
258+
ExceptionUtil.handleNettyException(ctx, cause, null, true);
259259
}
260260
}
261261
}

0 commit comments

Comments
 (0)