mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-23 12:05:28 +01:00
removed temp fix
This commit is contained in:
parent
d2c754ab0c
commit
61881ecd94
@ -23,8 +23,6 @@ import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.DisconnectAdapter;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.codec.PingEncapsulationCodec;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.codec.RakMessageEncapsulationCodec;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.codec.library_fix.FixedUnconnectedPingEncoder;
|
||||
import de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.codec.library_fix.FixedUnconnectedPongDecoder;
|
||||
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.netty.VLBPipeline;
|
||||
import de.florianmichael.vialoadingbase.netty.event.CompressionReorderEvent;
|
||||
@ -38,9 +36,6 @@ import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.netty.PreNettyLengthPrepender;
|
||||
import net.raphimc.vialegacy.netty.PreNettyLengthRemover;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols.PreNettyBaseProtocol;
|
||||
import org.cloudburstmc.netty.channel.raknet.RakClientChannel;
|
||||
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPingEncoder;
|
||||
import org.cloudburstmc.netty.handler.codec.raknet.common.UnconnectedPongDecoder;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@ -99,13 +94,6 @@ public class ViaFabricPlusVLBPipeline extends VLBPipeline {
|
||||
|
||||
// Pinging in RakNet is something different
|
||||
if (ProtocolHack.getRakNetPingSessions().contains(address)) {
|
||||
{ // Temporary fix for the ping encoder
|
||||
final RakClientChannel rakChannel = (RakClientChannel) ctx.channel();
|
||||
|
||||
rakChannel.parent().pipeline().replace(UnconnectedPingEncoder.NAME, UnconnectedPingEncoder.NAME, new FixedUnconnectedPingEncoder(rakChannel));
|
||||
rakChannel.parent().pipeline().replace(UnconnectedPongDecoder.NAME, UnconnectedPongDecoder.NAME, new FixedUnconnectedPongDecoder(rakChannel));
|
||||
}
|
||||
|
||||
pipeline.replace(VIA_BEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, VIA_BEDROCK_PING_ENCAPSULATION_HANDLER_NAME, new PingEncapsulationCodec(address));
|
||||
|
||||
pipeline.remove(VIA_BEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME);
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaBedrock - https://github.com/RaphiMC/ViaBedrock
|
||||
* 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 de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.codec.library_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 ViaBedrock - https://github.com/RaphiMC/ViaBedrock
|
||||
* 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 de.florianmichael.viafabricplus.protocolhack.netty.viabedrock.codec.library_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()));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user