Fixed proxy online mode not being toggleable at runtime

This commit is contained in:
RaphiMC 2023-01-12 22:21:28 +01:00
parent 5395ec40c1
commit 412bcde727

View File

@ -70,11 +70,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
private static final Random RANDOM = new Random(); private static final Random RANDOM = new Random();
static { static {
if (Options.ONLINE_MODE) { KEY_PAIR = CryptUtil.generateKeyPair();
KEY_PAIR = CryptUtil.generateKeyPair();
} else {
KEY_PAIR = null;
}
} }
private ProxyConnection proxyConnection; private ProxyConnection proxyConnection;
@ -88,7 +84,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
public void channelActive(ChannelHandlerContext ctx) throws Exception { public void channelActive(ChannelHandlerContext ctx) throws Exception {
super.channelActive(ctx); super.channelActive(ctx);
if (Options.ONLINE_MODE) RANDOM.nextBytes(this.verifyToken); RANDOM.nextBytes(this.verifyToken);
this.proxyConnection = new ProxyConnection(Proxy2ServerHandler::new, Proxy2ServerChannelInitializer::new, (SocketChannel) ctx.channel()); this.proxyConnection = new ProxyConnection(Proxy2ServerHandler::new, Proxy2ServerChannelInitializer::new, (SocketChannel) ctx.channel());
ctx.channel().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection); ctx.channel().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);