1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-06 04:37:46 +00:00

Add config flag to disable outgoing packet compression

This commit is contained in:
Joshua Goins 2025-05-02 22:41:31 -04:00
parent 11156ea43c
commit 76583ed744
3 changed files with 29 additions and 9 deletions

View file

@ -1211,6 +1211,7 @@ async fn main() {
};
spawn_client(ZoneConnection {
config: get_config().world,
socket,
state,
player_data: PlayerData::default(),

View file

@ -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 {

View file

@ -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;