1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-02 03:07:44 +00:00

Add an option to enable packet obsfucation for the World server

There's no point in doing this yet:
1. This *crashes* the client, nice. Most likely because we're not
actually obsfucating anything, only tricking the client into thinking we
were. Why this can crash the client is beyond me?
2. Obsfucation is still optional.
This commit is contained in:
Joshua Goins 2025-04-30 22:37:57 -04:00
parent d94c3a8e03
commit 614e470669
4 changed files with 23 additions and 1 deletions

View file

@ -204,6 +204,9 @@ pub struct WorldConfig {
/// Password of the RCON server, if left blank (the default) RCON is disabled.
#[serde(default = "WorldConfig::default_rcon_password")]
pub rcon_password: String,
/// Enable packet obsfucation. There's literally no reason to do this!
#[serde(default = "WorldConfig::default_packet_obsfucation")]
pub enable_packet_obsfucation: bool,
}
impl Default for WorldConfig {
@ -215,6 +218,7 @@ impl Default for WorldConfig {
scripts_location: Self::default_scripts_location(),
rcon_port: Self::default_rcon_port(),
rcon_password: Self::default_rcon_password(),
enable_packet_obsfucation: Self::default_packet_obsfucation(),
}
}
}
@ -243,6 +247,10 @@ impl WorldConfig {
fn default_rcon_password() -> String {
String::default()
}
fn default_packet_obsfucation() -> bool {
false
}
}
impl WorldConfig {

View file

@ -59,3 +59,6 @@ const SUPPORTED_EXPAC_VERSIONS: [(&str, Version); 5] = [
pub fn get_supported_expac_versions() -> HashMap<&'static str, Version<'static>> {
HashMap::from(SUPPORTED_EXPAC_VERSIONS)
}
/// Constant to enable packet obsfucation. Changes every patch.
pub const OBFUSCATION_ENABLED_MODE: u8 = 41;

View file

@ -9,7 +9,9 @@ use std::{
use tokio::{net::TcpStream, sync::mpsc::Sender};
use crate::{
OBFUSCATION_ENABLED_MODE,
common::{GameData, ObjectId, Position, timestamp_secs},
config::get_config,
opcodes::ServerZoneIpcType,
packet::{
CompressionType, ConnectionType, PacketSegment, PacketState, SegmentType, parse_packet,
@ -433,6 +435,8 @@ impl ZoneConnection {
// Init Zone
{
let config = get_config();
let ipc = ServerZoneIpcSegment {
op_code: ServerZoneIpcType::InitZone,
timestamp: timestamp_secs(),
@ -440,6 +444,11 @@ impl ZoneConnection {
server_id: 0,
zone_id: self.zone.as_ref().unwrap().id,
weather_id: 1,
obsfucation_mode: if config.world.enable_packet_obsfucation {
OBFUSCATION_ENABLED_MODE
} else {
0
},
..Default::default()
}),
..Default::default()

View file

@ -14,7 +14,9 @@ pub struct InitZone {
pub weather_id: u16, // index into Weather sheet probably?
pub unk_really: u16,
pub unk_bitmask1: u8,
pub unk_bitmask2: u8,
/// Zero means "no obsfucation" (not really, but functionally yes.)
/// To enable obsfucation, you need to set this to a constant that changes every patch. See lib.rs for the constant.
pub obsfucation_mode: u8,
pub unk1: u8,
pub unk2: u32,
pub festival_id: u16,