From da8466c43282a601b696d4b78919d491f654856e Mon Sep 17 00:00:00 2001 From: James Osborne Date: Wed, 20 May 2026 09:46:25 -0400 Subject: [PATCH] Make DC V2 EXP dispatcher rate-aware --- src/ReceiveSubcommands.cc | 7 +++++-- src/ServerState.cc | 4 ++++ src/ServerState.hh | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 3bf2f090..9632df81 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -3656,11 +3656,14 @@ static asio::awaitable dispatch_dc_v2_exp_patch(shared_ptr c) { co_return; } - string key = "PsoPeepsV2EXP_internal_10x_"; + auto server_state = c->require_server_state(); + + string key = "PsoPeepsV2EXP_internal_"; + key += std::to_string(server_state->psopeeps_dcv2_exp_multiplier); + key += "x_"; key += diff_str; try { - auto server_state = c->require_server_state(); auto fn = server_state->client_functions->get(key, c->specific_version); co_await send_function_call(c, fn); } catch (const out_of_range&) { diff --git a/src/ServerState.cc b/src/ServerState.cc index 7b7604a4..d9d31fdf 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -878,6 +878,10 @@ void ServerState::load_config_early() { this->client_ping_interval_usecs = this->config_json->get_int("ClientPingInterval", 30000000); this->client_idle_timeout_usecs = this->config_json->get_int("ClientIdleTimeout", 60000000); this->patch_client_idle_timeout_usecs = this->config_json->get_int("PatchClientIdleTimeout", 300000000); + this->psopeeps_dcv2_exp_multiplier = this->config_json->get_int("PsoPeepsDCV2EXPMultiplier", 5); + if ((this->psopeeps_dcv2_exp_multiplier != 5) && (this->psopeeps_dcv2_exp_multiplier != 10)) { + throw runtime_error("PsoPeepsDCV2EXPMultiplier must be 5 or 10"); + } this->ip_stack_debug = this->config_json->get_bool("IPStackDebug", false); this->allow_unregistered_users = this->config_json->get_bool("AllowUnregisteredUsers", false); diff --git a/src/ServerState.hh b/src/ServerState.hh index af693ae8..b27f5a1a 100644 --- a/src/ServerState.hh +++ b/src/ServerState.hh @@ -123,6 +123,7 @@ struct ServerState : public std::enable_shared_from_this { uint64_t client_ping_interval_usecs = 30000000; uint64_t client_idle_timeout_usecs = 60000000; uint64_t patch_client_idle_timeout_usecs = 300000000; + uint64_t psopeeps_dcv2_exp_multiplier = 5; bool is_debug = false; bool ip_stack_debug = false; bool allow_unregistered_users = false;