mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-02 08:50:26 +01:00
Removed now not needed anymore code
This commit is contained in:
parent
ab93dbc9ed
commit
c5a772d6db
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.raphimc.viaproxy.protocolhack.viaproxy.raknet_fix;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.channel.ChannelOutboundHandlerAdapter;
|
|
||||||
import io.netty.channel.ChannelPromise;
|
|
||||||
import io.netty.channel.socket.DatagramPacket;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakPing;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
|
||||||
|
|
||||||
import static org.cloudburstmc.netty.channel.raknet.RakConstants.ID_UNCONNECTED_PING;
|
|
||||||
|
|
||||||
// Temporary fix until the library fixes the issue
|
|
||||||
public class FixedUnconnectedPingEncoder extends ChannelOutboundHandlerAdapter {
|
|
||||||
|
|
||||||
private final RakClientChannel rakClientChannel;
|
|
||||||
|
|
||||||
public FixedUnconnectedPingEncoder(final RakClientChannel rakClientChannel) {
|
|
||||||
this.rakClientChannel = rakClientChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
|
||||||
if (!(msg instanceof RakPing)) {
|
|
||||||
ctx.write(msg, promise);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RakPing ping = (RakPing) msg;
|
|
||||||
ByteBuf magicBuf = this.rakClientChannel.config().getOption(RakChannelOption.RAK_UNCONNECTED_MAGIC);
|
|
||||||
long guid = this.rakClientChannel.config().getOption(RakChannelOption.RAK_GUID);
|
|
||||||
|
|
||||||
ByteBuf pingBuffer = ctx.alloc().ioBuffer(magicBuf.readableBytes() + 17);
|
|
||||||
pingBuffer.writeByte(ID_UNCONNECTED_PING);
|
|
||||||
pingBuffer.writeLong(ping.getPingTime());
|
|
||||||
pingBuffer.writeBytes(magicBuf, magicBuf.readerIndex(), magicBuf.readableBytes());
|
|
||||||
pingBuffer.writeLong(guid);
|
|
||||||
ctx.write(new DatagramPacket(pingBuffer, ping.getSender()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
|
||||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.raphimc.viaproxy.protocolhack.viaproxy.raknet_fix;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.ByteBufUtil;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.channel.socket.DatagramPacket;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakPong;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
|
||||||
import org.cloudburstmc.netty.handler.codec.raknet.AdvancedChannelInboundHandler;
|
|
||||||
|
|
||||||
import static org.cloudburstmc.netty.channel.raknet.RakConstants.ID_UNCONNECTED_PONG;
|
|
||||||
|
|
||||||
// Temporary fix until the library fixes the issue
|
|
||||||
public class FixedUnconnectedPongDecoder extends AdvancedChannelInboundHandler<DatagramPacket> {
|
|
||||||
|
|
||||||
private final RakClientChannel rakClientChannel;
|
|
||||||
|
|
||||||
public FixedUnconnectedPongDecoder(final RakClientChannel rakClientChannel) {
|
|
||||||
this.rakClientChannel = rakClientChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean acceptInboundMessage(ChannelHandlerContext ctx, Object msg) throws Exception {
|
|
||||||
if (!super.acceptInboundMessage(ctx, msg)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DatagramPacket packet = (DatagramPacket) msg;
|
|
||||||
ByteBuf buf = packet.content();
|
|
||||||
return buf.isReadable() && buf.getUnsignedByte(buf.readerIndex()) == ID_UNCONNECTED_PONG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
|
|
||||||
ByteBuf buf = packet.content();
|
|
||||||
buf.readUnsignedByte(); // Packet ID
|
|
||||||
|
|
||||||
long pingTime = buf.readLong();
|
|
||||||
long guid = buf.readLong();
|
|
||||||
|
|
||||||
ByteBuf magicBuf = this.rakClientChannel.config().getOption(RakChannelOption.RAK_UNCONNECTED_MAGIC);
|
|
||||||
if (!buf.isReadable(magicBuf.readableBytes()) || !ByteBufUtil.equals(buf.readSlice(magicBuf.readableBytes()), magicBuf)) {
|
|
||||||
// Magic does not match
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteBuf pongData = Unpooled.EMPTY_BUFFER;
|
|
||||||
if (buf.isReadable(2)) { // Length
|
|
||||||
pongData = buf.readRetainedSlice(buf.readUnsignedShort());
|
|
||||||
}
|
|
||||||
ctx.fireChannelRead(new RakPong(pingTime, guid, pongData, packet.sender()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -33,13 +33,8 @@ import net.raphimc.netminecraft.util.ServerAddress;
|
|||||||
import net.raphimc.viaprotocolhack.netty.VPHPipeline;
|
import net.raphimc.viaprotocolhack.netty.VPHPipeline;
|
||||||
import net.raphimc.viaprotocolhack.netty.viabedrock.PingEncapsulationCodec;
|
import net.raphimc.viaprotocolhack.netty.viabedrock.PingEncapsulationCodec;
|
||||||
import net.raphimc.viaprotocolhack.util.VersionEnum;
|
import net.raphimc.viaprotocolhack.util.VersionEnum;
|
||||||
import net.raphimc.viaproxy.protocolhack.viaproxy.raknet_fix.FixedUnconnectedPingEncoder;
|
|
||||||
import net.raphimc.viaproxy.protocolhack.viaproxy.raknet_fix.FixedUnconnectedPongDecoder;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
|
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
|
||||||
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
|
|
||||||
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
||||||
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPingEncoder;
|
|
||||||
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPongDecoder;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
@ -93,12 +88,6 @@ public class BedrockProxyConnection extends ProxyConnection {
|
|||||||
this.initialize(new Bootstrap());
|
this.initialize(new Bootstrap());
|
||||||
}
|
}
|
||||||
this.getChannel().bind(new InetSocketAddress(0)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE).syncUninterruptibly();
|
this.getChannel().bind(new InetSocketAddress(0)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE).syncUninterruptibly();
|
||||||
final RakClientChannel channel = (RakClientChannel) this.getChannel();
|
|
||||||
|
|
||||||
{ // Temporary fix for the ping encoder
|
|
||||||
channel.parent().pipeline().replace(UnconnectedPingEncoder.NAME, UnconnectedPingEncoder.NAME, new FixedUnconnectedPingEncoder(channel));
|
|
||||||
channel.parent().pipeline().replace(UnconnectedPongDecoder.NAME, UnconnectedPongDecoder.NAME, new FixedUnconnectedPongDecoder(channel));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.getChannel().pipeline().replace(VPHPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, "ping_encapsulation", new PingEncapsulationCodec(serverAddress.toSocketAddress()));
|
this.getChannel().pipeline().replace(VPHPipeline.VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, "ping_encapsulation", new PingEncapsulationCodec(serverAddress.toSocketAddress()));
|
||||||
this.getChannel().pipeline().remove(VPHPipeline.VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
this.getChannel().pipeline().remove(VPHPipeline.VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
||||||
|
Loading…
Reference in New Issue
Block a user