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:
parent
11156ea43c
commit
76583ed744
3 changed files with 29 additions and 9 deletions
|
@ -1211,6 +1211,7 @@ async fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
spawn_client(ZoneConnection {
|
spawn_client(ZoneConnection {
|
||||||
|
config: get_config().world,
|
||||||
socket,
|
socket,
|
||||||
state,
|
state,
|
||||||
player_data: PlayerData::default(),
|
player_data: PlayerData::default(),
|
||||||
|
|
|
@ -207,6 +207,9 @@ pub struct WorldConfig {
|
||||||
/// Enable packet obsfucation. There's literally no reason to do this!
|
/// Enable packet obsfucation. There's literally no reason to do this!
|
||||||
#[serde(default = "WorldConfig::default_packet_obsfucation")]
|
#[serde(default = "WorldConfig::default_packet_obsfucation")]
|
||||||
pub enable_packet_obsfucation: bool,
|
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 {
|
impl Default for WorldConfig {
|
||||||
|
@ -219,6 +222,7 @@ impl Default for WorldConfig {
|
||||||
rcon_port: Self::default_rcon_port(),
|
rcon_port: Self::default_rcon_port(),
|
||||||
rcon_password: Self::default_rcon_password(),
|
rcon_password: Self::default_rcon_password(),
|
||||||
enable_packet_obsfucation: Self::default_packet_obsfucation(),
|
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 {
|
fn default_packet_obsfucation() -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_packet_compression() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorldConfig {
|
impl WorldConfig {
|
||||||
|
|
|
@ -11,14 +11,16 @@ use tokio::{net::TcpStream, sync::mpsc::Sender};
|
||||||
use crate::{
|
use crate::{
|
||||||
OBFUSCATION_ENABLED_MODE,
|
OBFUSCATION_ENABLED_MODE,
|
||||||
common::{GameData, ObjectId, Position, timestamp_secs},
|
common::{GameData, ObjectId, Position, timestamp_secs},
|
||||||
config::get_config,
|
config::{WorldConfig, get_config},
|
||||||
inventory::{Inventory, Item},
|
inventory::{Inventory, Item},
|
||||||
ipc::chat::ServerChatIpcSegment,
|
ipc::{
|
||||||
ipc::zone::{
|
chat::ServerChatIpcSegment,
|
||||||
ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn, ContainerInfo,
|
zone::{
|
||||||
DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind, PlayerStats, PlayerSubKind,
|
ActorControlSelf, ActorMove, ActorSetPos, ClientZoneIpcSegment, CommonSpawn,
|
||||||
ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect, StatusEffectList, UpdateClassInfo,
|
ContainerInfo, DisplayFlag, Equip, InitZone, ItemInfo, NpcSpawn, ObjectKind,
|
||||||
WeatherChange,
|
PlayerStats, PlayerSubKind, ServerZoneIpcData, ServerZoneIpcSegment, StatusEffect,
|
||||||
|
StatusEffectList, UpdateClassInfo, WeatherChange,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
opcodes::ServerZoneIpcType,
|
opcodes::ServerZoneIpcType,
|
||||||
packet::{
|
packet::{
|
||||||
|
@ -129,6 +131,7 @@ impl ServerHandle {
|
||||||
|
|
||||||
/// Represents a single connection between an instance of the client and the world server
|
/// Represents a single connection between an instance of the client and the world server
|
||||||
pub struct ZoneConnection {
|
pub struct ZoneConnection {
|
||||||
|
pub config: WorldConfig,
|
||||||
pub socket: TcpStream,
|
pub socket: TcpStream,
|
||||||
|
|
||||||
pub state: PacketState,
|
pub state: PacketState,
|
||||||
|
@ -164,7 +167,11 @@ impl ZoneConnection {
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
&mut self.state,
|
&mut self.state,
|
||||||
ConnectionType::Zone,
|
ConnectionType::Zone,
|
||||||
CompressionType::Oodle,
|
if self.config.enable_packet_compression {
|
||||||
|
CompressionType::Oodle
|
||||||
|
} else {
|
||||||
|
CompressionType::Uncompressed
|
||||||
|
},
|
||||||
&[segment],
|
&[segment],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
@ -175,7 +182,11 @@ impl ZoneConnection {
|
||||||
&mut self.socket,
|
&mut self.socket,
|
||||||
&mut self.state,
|
&mut self.state,
|
||||||
ConnectionType::Chat,
|
ConnectionType::Chat,
|
||||||
CompressionType::Oodle,
|
if self.config.enable_packet_compression {
|
||||||
|
CompressionType::Oodle
|
||||||
|
} else {
|
||||||
|
CompressionType::Uncompressed
|
||||||
|
},
|
||||||
&[segment],
|
&[segment],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
Loading…
Add table
Reference in a new issue