From 76583ed744ccfcb300d562f334f1e781a7c9dba5 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 2 May 2025 22:41:31 -0400 Subject: [PATCH] Add config flag to disable outgoing packet compression --- src/bin/kawari-world.rs | 1 + src/config.rs | 8 ++++++++ src/world/connection.rs | 29 ++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 8fa3b2d..3749b21 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -1211,6 +1211,7 @@ async fn main() { }; spawn_client(ZoneConnection { + config: get_config().world, socket, state, player_data: PlayerData::default(), diff --git a/src/config.rs b/src/config.rs index 40ba4cf..3062004 100644 --- a/src/config.rs +++ b/src/config.rs @@ -207,6 +207,9 @@ pub struct WorldConfig { /// Enable packet obsfucation. There's literally no reason to do this! #[serde(default = "WorldConfig::default_packet_obsfucation")] pub enable_packet_obsfucation: bool, + /// Enable packet compression for packets from the server. It's recommended to keep this on. + #[serde(default = "WorldConfig::default_packet_compression")] + pub enable_packet_compression: bool, } impl Default for WorldConfig { @@ -219,6 +222,7 @@ impl Default for WorldConfig { rcon_port: Self::default_rcon_port(), rcon_password: Self::default_rcon_password(), enable_packet_obsfucation: Self::default_packet_obsfucation(), + enable_packet_compression: Self::default_packet_compression(), } } } @@ -251,6 +255,10 @@ impl WorldConfig { fn default_packet_obsfucation() -> bool { false } + + fn default_packet_compression() -> bool { + true + } } impl WorldConfig { diff --git a/src/world/connection.rs b/src/world/connection.rs index 1783999..53de7ca 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -11,14 +11,16 @@ use tokio::{net::TcpStream, sync::mpsc::Sender}; use crate::{ OBFUSCATION_ENABLED_MODE, common::{GameData, ObjectId, Position, timestamp_secs}, - config::get_config, + config::{WorldConfig, get_config}, inventory::{Inventory, Item}, - ipc::chat::ServerChatIpcSegment, - ipc::zone::{ - ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, ContainerInfo, - DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, PlayerStats, PlayerSubKind, - ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList, UpdateClassInfo, - WeatherChange, + ipc::{ + chat::ServerChatIpcSegment, + zone::{ + ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, + ContainerInfo, DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, + PlayerStats, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, + StatusEffectList, UpdateClassInfo, WeatherChange, + }, }, opcodes::ServerZoneIpcType, packet::{ @@ -129,6 +131,7 @@ impl ServerHandle { /// Represents a single connection between an instance of the client and the world server pub struct ZoneConnection { + pub config: WorldConfig, pub socket: TcpStream, pub state: PacketState, @@ -164,7 +167,11 @@ impl ZoneConnection { &mut self.socket, &mut self.state, ConnectionType::Zone, - CompressionType::Oodle, + if self.config.enable_packet_compression { + CompressionType::Oodle + } else { + CompressionType::Uncompressed + }, &[segment], ) .await; @@ -175,7 +182,11 @@ impl ZoneConnection { &mut self.socket, &mut self.state, ConnectionType::Chat, - CompressionType::Oodle, + if self.config.enable_packet_compression { + CompressionType::Oodle + } else { + CompressionType::Uncompressed + }, &[segment], ) .await;