diff --git a/surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/netty/ClientNettyClientImpl.kt b/surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/netty/ClientNettyClientImpl.kt index 9167050d..bfbcca93 100644 --- a/surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/netty/ClientNettyClientImpl.kt +++ b/surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/netty/ClientNettyClientImpl.kt @@ -88,7 +88,8 @@ class ClientNettyClientImpl( ConnectionImpl.connect( inetSocketAddress, configHolder.config.connectionConfig.nettyConfig.useEpoll, - connection + connection, + configHolder ) ConnectionTickScope.launch { @@ -205,7 +206,7 @@ class ClientNettyClientImpl( useEpoll: Boolean, ): ConnectionImpl { val connection = ConnectionImpl(PacketFlow.CLIENTBOUND, EncryptionManager.instance) - ConnectionImpl.connect(address, useEpoll, connection) + ConnectionImpl.connect(address, useEpoll, connection, configHolder) return connection } diff --git a/surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/netty/network/ConnectionImpl.kt b/surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/netty/network/ConnectionImpl.kt index 14f9ed0c..be0640c3 100644 --- a/surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/netty/network/ConnectionImpl.kt +++ b/surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/netty/network/ConnectionImpl.kt @@ -1221,7 +1221,8 @@ class ConnectionImpl( suspend fun connect( address: InetSocketAddress, useEpoll: Boolean, - connection: ConnectionImpl + connection: ConnectionImpl, + configHolder: AbstractSurfCloudConfigHolder<*> ) { val channelClass: Class val eventLoopGroup: EventLoopGroup @@ -1248,7 +1249,12 @@ class ConnectionImpl( val pipeline = channel.pipeline() .addLast(HandlerNames.TIMEOUT, ReadTimeoutHandler(30)) - configureSerialization(pipeline, PacketFlow.CLIENTBOUND, local = false) + configureSerialization( + pipeline, + PacketFlow.CLIENTBOUND, + false, + configHolder + ) connection.configurePacketHandler(channel, pipeline) } }) @@ -1256,7 +1262,12 @@ class ConnectionImpl( .suspend() } - fun configureSerialization(pipeline: ChannelPipeline, side: PacketFlow, local: Boolean) { + fun configureSerialization( + pipeline: ChannelPipeline, + side: PacketFlow, + local: Boolean, + configHolder: AbstractSurfCloudConfigHolder<*> + ) { val opposite = side.getOpposite() val receivingSide = side == PacketFlow.SERVERBOUND val sendingSide = opposite == PacketFlow.SERVERBOUND @@ -1264,7 +1275,7 @@ class ConnectionImpl( pipeline.addFirst( HandlerNames.LOGGER, - LoggingHandler(bean>().config.logging.nettyLogLevel) + LoggingHandler(configHolder.config.logging.nettyLogLevel) ) // .addLast(HandlerNames.SSL_HANDLER_ENFORCER, EnforceSslHandler()) .addLast(HandlerNames.COMPRESS, ZstdEncoder(8)) diff --git a/surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/netty/server/connection/ServerConnectionListener.kt b/surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/netty/server/connection/ServerConnectionListener.kt index 1846ac4a..b6852014 100644 --- a/surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/netty/server/connection/ServerConnectionListener.kt +++ b/surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/netty/server/connection/ServerConnectionListener.kt @@ -91,7 +91,8 @@ class ServerConnectionListener( ConnectionImpl.configureSerialization( pipeline, PacketFlow.SERVERBOUND, - false + false, + configHolder ) val connection = @@ -206,7 +207,11 @@ class ServerConnectionListener( } } - fun broadcast(packet: NettyPacket, flush: Boolean = true, except: (ConnectionImpl) -> Boolean = { false }) { + fun broadcast( + packet: NettyPacket, + flush: Boolean = true, + except: (ConnectionImpl) -> Boolean = { false } + ) { require(packet !is RespondingNettyPacket<*>) { "Cannot broadcast responding packets" } val activeProtocols = packet.protocols