mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-09-30 07:27:28 +02:00
76 lines
3.9 KiB
Diff
76 lines
3.9 KiB
Diff
From b867ce525077abf99f35c0d942d619c7ce8ef0d2 Mon Sep 17 00:00:00 2001
|
|
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
|
Date: Thu, 23 Mar 2023 22:35:42 -0300
|
|
Subject: [PATCH] Optimize PipelineUtils
|
|
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
index 00d3096a..faccdc6c 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
@@ -6,11 +6,13 @@ import dev._2lstudios.flamecord.FlameCord;
|
|
import io.github.waterfallmc.waterfall.event.ConnectionInitEvent;
|
|
import io.netty.buffer.PooledByteBufAllocator;
|
|
import io.netty.channel.Channel;
|
|
+import io.netty.channel.ChannelConfig;
|
|
import io.netty.channel.ChannelException;
|
|
import io.netty.channel.ChannelFactory;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelInitializer;
|
|
import io.netty.channel.ChannelOption;
|
|
+import io.netty.channel.ChannelPipeline;
|
|
import io.netty.channel.EventLoopGroup;
|
|
import io.netty.channel.ServerChannel;
|
|
import io.netty.channel.WriteBufferWaterMark;
|
|
@@ -54,7 +56,6 @@ import net.md_5.bungee.protocol.Varint21LengthFieldPrepender;
|
|
|
|
public class PipelineUtils
|
|
{
|
|
-
|
|
public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.newInstance( "ListerInfo" );
|
|
public static final ChannelInitializer<Channel> SERVER_CHILD = new ChannelInitializer<Channel>()
|
|
{
|
|
@@ -251,26 +252,30 @@ public class PipelineUtils
|
|
@Override
|
|
public void initChannel(Channel ch) throws Exception
|
|
{
|
|
+ // FlameCord start - Optimize PipelineUtils
|
|
+ ChannelPipeline pipeline = ch.pipeline();
|
|
+ ChannelConfig channelConfig = ch.config();
|
|
try
|
|
{
|
|
- ch.config().setOption( ChannelOption.IP_TOS, 0x18 );
|
|
+ channelConfig.setOption( ChannelOption.IP_TOS, 0x18 );
|
|
} catch ( ChannelException ex )
|
|
{
|
|
// IP_TOS is not supported (Windows XP / Windows Server 2003)
|
|
}
|
|
- ch.config().setOption( ChannelOption.TCP_NODELAY, true );
|
|
+ channelConfig.setOption( ChannelOption.TCP_NODELAY, true );
|
|
// FlameCord - TCP Fast Open
|
|
- ch.config().setOption( ChannelOption.TCP_FASTOPEN, FlameCord.getInstance().getFlameCordConfiguration().getTcpFastOpen() );
|
|
- ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );
|
|
- ch.config().setWriteBufferWaterMark( MARK );
|
|
+ channelConfig.setOption( ChannelOption.TCP_FASTOPEN, FlameCord.getInstance().getFlameCordConfiguration().getTcpFastOpen() );
|
|
+ channelConfig.setAllocator( PooledByteBufAllocator.DEFAULT );
|
|
+ channelConfig.setWriteBufferWaterMark( MARK );
|
|
|
|
- ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder() );
|
|
- ch.pipeline().addLast( TIMEOUT_HANDLER, new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
|
|
+ pipeline.addLast( FRAME_DECODER, new Varint21FrameDecoder() );
|
|
+ pipeline.addLast( TIMEOUT_HANDLER, new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
|
|
// No encryption bungee -> server, therefore use extra buffer to avoid copying everything for length prepending
|
|
// Not used bungee -> client as header would need to be encrypted separately through expensive JNI call
|
|
- ch.pipeline().addLast( FRAME_PREPENDER, ( toServer ) ? serverFramePrepender : framePrepender );
|
|
+ pipeline.addLast( FRAME_PREPENDER, ( toServer ) ? serverFramePrepender : framePrepender );
|
|
|
|
- ch.pipeline().addLast( BOSS_HANDLER, new HandlerBoss() );
|
|
+ pipeline.addLast( BOSS_HANDLER, new HandlerBoss() );
|
|
+ // FlameCord end - Optimize PipelineUtils
|
|
}
|
|
|
|
// FlameCord - Close on exception caught
|
|
--
|
|
2.37.3.windows.1
|
|
|