From fed21b36170826d2f5c6c52a9f0d72e51d8b8670 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 1 Apr 2025 16:58:39 -0400 Subject: [PATCH] Make various packet dumping optional, turned off by default This creates a lot of clutter, and only really interesting to developers. --- src/config.rs | 5 +++++ src/packet/compression.rs | 6 +++++- src/packet/parsing.rs | 7 ++++++- src/world/connection.rs | 2 +- src/world/inventory.rs | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index a742d2b..9318ab4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -241,6 +241,10 @@ pub struct Config { #[serde(default)] pub world: WorldConfig, + + /// Enable various packet debug functions. This will clutter your working directory! + #[serde(default)] + pub packet_debugging: bool, } impl Default for Config { @@ -255,6 +259,7 @@ impl Default for Config { patch: PatchConfig::default(), web: WebConfig::default(), world: WorldConfig::default(), + packet_debugging: false, } } } diff --git a/src/packet/compression.rs b/src/packet/compression.rs index 924b72f..f93fed0 100644 --- a/src/packet/compression.rs +++ b/src/packet/compression.rs @@ -4,6 +4,7 @@ use std::io::Cursor; use binrw::{BinRead, BinResult}; use crate::{ + config::get_config, oodle::OodleNetwork, packet::{PacketHeader, PacketSegment}, }; @@ -46,7 +47,10 @@ pub(crate) fn decompress( let mut cursor = Cursor::new(&data); - std::fs::write("decompressed.bin", &data).unwrap(); + let config = get_config(); + if config.packet_debugging { + std::fs::write("decompressed.bin", &data).unwrap(); + } for _ in 0..header.segment_count { let current_position = cursor.position(); diff --git a/src/packet/parsing.rs b/src/packet/parsing.rs index 83f04db..654c0ae 100644 --- a/src/packet/parsing.rs +++ b/src/packet/parsing.rs @@ -5,6 +5,7 @@ use tokio::{io::AsyncWriteExt, net::TcpStream}; use crate::{ common::{custom_ipc::CustomIpcSegment, read_string, timestamp_msecs, write_string}, + config::get_config, oodle::OodleNetwork, packet::{compression::compress, encryption::decrypt}, }; @@ -195,7 +196,11 @@ pub async fn parse_packet( Ok(packet) => (packet.segments, packet.header.connection_type), Err(err) => { tracing::error!("{err}"); - dump("Failed to parse packet!", data); + + let config = get_config(); + if config.packet_debugging { + dump("Failed to parse packet!", data); + } (Vec::new(), ConnectionType::None) } diff --git a/src/world/connection.rs b/src/world/connection.rs index 3d8f291..963024c 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -521,7 +521,7 @@ impl ZoneConnection { } // inform the client of page 1 - { + { let ipc = ServerZoneIpcSegment { op_code: ServerZoneIpcType::ContainerInfo, timestamp: timestamp_secs(), diff --git a/src/world/inventory.rs b/src/world/inventory.rs index 783f772..4f8127e 100644 --- a/src/world/inventory.rs +++ b/src/world/inventory.rs @@ -88,7 +88,7 @@ impl Inventory { pub fn new() -> Self { Self { equipped: EquippedContainer::default(), - extra_slot: Item::default() + extra_slot: Item::default(), } }