mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Improve net security against snooping, make configurable
This commit is contained in:
@@ -14,7 +14,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(chat_system: crate::state::chat::ChatImpl, conf: &oj_rc_core::persist::config::ConfigImpl) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::new()
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.modify(<oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::polariton_operation_modifier(conf))
|
||||
.add(more_auth::MoreLobbyAuth::new())
|
||||
.add(chat_ignores::ignores_provider())
|
||||
.add(pending_sanctions::pending_sanctions_checker())
|
||||
|
||||
@@ -9,6 +9,7 @@ pub use persist::user::{UserImpl, UserProvider, UserAuthenticator};
|
||||
pub use persist::config::{ConfigImpl, ConfigProvider};
|
||||
|
||||
pub mod polariton;
|
||||
pub use polariton::OpModImpl;
|
||||
|
||||
pub mod factory;
|
||||
|
||||
|
||||
@@ -637,4 +637,8 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
defederated: self.federation.defederated.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn polariton_operation_modifier(&self) -> crate::OpModImpl {
|
||||
crate::OpModImpl::new(self.settings.polariton.clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn redacted_json(&self) -> String;
|
||||
/// None when federation is not enabled
|
||||
fn federation(&self) -> Option<Federation>;
|
||||
fn polariton_operation_modifier(&self) -> crate::OpModImpl;
|
||||
}
|
||||
|
||||
pub struct DevMessageProvider<C: Clone> {
|
||||
|
||||
@@ -28,6 +28,7 @@ pub use client_config::{GameplaySettings, PlatformSettings};
|
||||
|
||||
mod settings;
|
||||
pub use settings::{Settings, QueueMode};
|
||||
pub(crate) use settings::PolaritonSettings;
|
||||
|
||||
mod chat;
|
||||
pub use chat::{ChatConfig, ChatCommand, ChatOperation, BuiltInChatOperation, IntercomChatOperation, ChatPermission, SystemChatOperation};
|
||||
|
||||
@@ -10,6 +10,10 @@ pub struct Settings {
|
||||
pub garage_upgrades: Vec<GarageSlotUpgrade>,
|
||||
#[serde(default = "default_server_conf")]
|
||||
pub server: ServerSettings,
|
||||
#[serde(default = "default_pun_conf", alias = "photon")]
|
||||
pub polariton: PolaritonSettings,
|
||||
#[serde(default = "default_lnl_conf", alias = "lnl")]
|
||||
pub lrl: LiteRustLibSettings,
|
||||
}
|
||||
|
||||
impl super::config::SelfValidator for Settings {
|
||||
@@ -27,6 +31,8 @@ impl super::config::RedactedClone for Settings {
|
||||
banners: self.banners.clone(),
|
||||
garage_upgrades: self.garage_upgrades.clone(),
|
||||
server: self.server.redacted_clone(),
|
||||
polariton: self.polariton.clone(),
|
||||
lrl: self.lrl.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,3 +220,29 @@ fn default_game_version() -> u32 {
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct PolaritonSettings {
|
||||
#[serde(default = "default_true")]
|
||||
pub force_encrypt_responses: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub add_unique_response_param: bool,
|
||||
}
|
||||
|
||||
fn default_pun_conf() -> PolaritonSettings {
|
||||
PolaritonSettings {
|
||||
force_encrypt_responses: true,
|
||||
add_unique_response_param: true,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct LiteRustLibSettings {
|
||||
|
||||
}
|
||||
|
||||
fn default_lnl_conf() -> LiteRustLibSettings {
|
||||
LiteRustLibSettings {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
mod op_mod;
|
||||
pub use op_mod::RcOpModifier;
|
||||
pub use op_mod::{OpModImpl, RcOpModifier};
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
use polariton_server::operations::OperationModifier;
|
||||
|
||||
pub struct RcOpModifier;
|
||||
pub type OpModImpl = RcOpModifier;
|
||||
|
||||
pub struct RcOpModifier {
|
||||
settings: crate::persist::PolaritonSettings,
|
||||
unique_param_value: std::sync::atomic::AtomicI64,
|
||||
}
|
||||
|
||||
impl RcOpModifier {
|
||||
const SERVICE_MAPPING_KEY: u8 = 0;
|
||||
const SAFE_UNIQUE_RESPONSE_PARAM: u8 = 255;
|
||||
|
||||
pub(crate) fn new(settings: crate::persist::PolaritonSettings) -> Self {
|
||||
let now = chrono::Utc::now();
|
||||
Self {
|
||||
settings,
|
||||
unique_param_value: std::sync::atomic::AtomicI64::new(
|
||||
now.timestamp_nanos_opt()
|
||||
.unwrap_or(now.timestamp_millis())
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl <C: Clone + Send + Sync + 'static> OperationModifier<C> for RcOpModifier {
|
||||
@@ -13,6 +30,16 @@ impl <C: Clone + Send + Sync + 'static> OperationModifier<C> for RcOpModifier {
|
||||
resp.params.insert(Self::SERVICE_MAPPING_KEY, svelto_service_id.to_owned());
|
||||
}
|
||||
}
|
||||
*flags |= 0x80;
|
||||
if self.settings.force_encrypt_responses {
|
||||
*flags |= 0x80;
|
||||
}
|
||||
if self.settings.add_unique_response_param {
|
||||
#[cfg(debug_assertions)]
|
||||
if resp.params.get(&Self::SAFE_UNIQUE_RESPONSE_PARAM).is_some() {
|
||||
log::warn!("Smashed param {} of polariton response {}", Self::SAFE_UNIQUE_RESPONSE_PARAM, resp.code);
|
||||
}
|
||||
let new_val = self.unique_param_value.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
resp.params.insert(Self::SAFE_UNIQUE_RESPONSE_PARAM, polariton::operation::Typed::Long(new_val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::<crate::UserTy>::new()
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.modify(<oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::polariton_operation_modifier(&init_ctx.config))
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
//.add(eac::EacChallengeIgnorer)
|
||||
.add(polariton_server::operations::Ack::<2, _>::default())
|
||||
|
||||
@@ -122,7 +122,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::new()
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.modify(<oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::polariton_operation_modifier(&init_ctx.cubes))
|
||||
.add(eac::EacChallengeIgnorer)
|
||||
.add(more_auth::more_auth_provider(&init_ctx.user_mesh))
|
||||
.add(versioner::version_teller(&init_ctx.cubes))
|
||||
|
||||
@@ -7,7 +7,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::<crate::UserTy>::new()
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.modify(<oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::polariton_operation_modifier(&init_ctx.config))
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
.add(eac::EacChallengeIgnorer)
|
||||
.add(load_ai_robots::tdm_machines_provider(&init_ctx.factory, init_ctx.parsers.weapon_order(), &init_ctx.config, init_ctx.parsers.cpu_counter()))
|
||||
|
||||
@@ -42,7 +42,7 @@ use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy, crate::data::custom::CustomType> {
|
||||
OperationsHandler::<crate::UserTy, crate::data::custom::CustomType>::new()
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.modify(<oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::polariton_operation_modifier(&init_ctx.config))
|
||||
.add(more_auth::more_lobby_auth(init_ctx))
|
||||
.add(friend_list::friends_provider(init_ctx)) // TODO friend object parsing Token: 0x0200169C RID: 5788
|
||||
.add(settings::settings_provider()) // TODO save settings persistently
|
||||
|
||||
Reference in New Issue
Block a user