From ad32c0a986069c203e376d0d89352de06ac03201 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 24 Dec 2023 22:50:33 -0800 Subject: [PATCH] make hide_download_commands configurable --- src/Client.cc | 3 ++- src/ReceiveCommands.cc | 2 +- src/SendCommands.cc | 3 ++- src/ServerState.cc | 2 ++ src/ServerState.hh | 1 + system/config.example.json | 5 +++++ tests/config.json | 1 + 7 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Client.cc b/src/Client.cc index 83c19c4e..554fdd64 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -191,7 +191,8 @@ Client::Client( // Don't print data sent to patch clients to the logs. The patch server // protocol is fully understood and data logs for patch clients are generally // more annoying than helpful at this point. - if ((this->channel.version == Version::PC_PATCH) || (this->channel.version == Version::BB_PATCH)) { + if ((server->get_state()->hide_download_commands) && + ((this->channel.version == Version::PC_PATCH) || (this->channel.version == Version::BB_PATCH))) { this->channel.terminal_recv_color = TerminalFormat::END; this->channel.terminal_send_color = TerminalFormat::END; } diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 44aa022e..d675104f 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1135,7 +1135,7 @@ static void on_93_BB(shared_ptr c, uint16_t, uint32_t, string& data) { // command. on_login_complete(c); - } else { + } else if (s->hide_download_commands) { // The BB data server protocol is fairly well-understood and has some large // commands, so we omit data logging for clients on the data server. c->log.info("Client is in the BB data server phase; disabling command data logging for the rest of this client\'s session"); diff --git a/src/SendCommands.cc b/src/SendCommands.cc index bfb3f937..9d305dd3 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -3206,7 +3206,8 @@ void send_quest_file_chunk( cmd.data_size = size; c->log.info("Sending quest file chunk %s:%zu", filename.c_str(), chunk_index); - c->channel.send(is_download_quest ? 0xA7 : 0x13, chunk_index, &cmd, sizeof(cmd), true); + const auto& s = c->require_server_state(); + c->channel.send(is_download_quest ? 0xA7 : 0x13, chunk_index, &cmd, sizeof(cmd), s->hide_download_commands); } template diff --git a/src/ServerState.cc b/src/ServerState.cc index 3daa0f85..5e6e2776 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -67,6 +67,7 @@ ServerState::ServerState(shared_ptr base, const string& confi ep3_final_round_meseta_bonus(300), ep3_jukebox_is_free(false), ep3_behavior_flags(0), + hide_download_commands(true), run_shell_behavior(RunShellBehavior::DEFAULT), cheat_mode_behavior(BehaviorSwitch::OFF_BY_DEFAULT), bb_global_exp_multiplier(1), @@ -719,6 +720,7 @@ void ServerState::parse_config(const JSON& json, bool is_reload) { this->ep3_jukebox_is_free = json.get_bool("Episode3JukeboxIsFree", this->ep3_jukebox_is_free); this->ep3_behavior_flags = json.get_int("Episode3BehaviorFlags", this->ep3_behavior_flags); this->ep3_card_auction_points = json.get_int("CardAuctionPoints", this->ep3_card_auction_points); + this->hide_download_commands = json.get_bool("HideDownloadCommands", this->hide_download_commands); this->proxy_allow_save_files = json.get_bool("ProxyAllowSaveFiles", this->proxy_allow_save_files); this->proxy_enable_login_options = json.get_bool("ProxyEnableLoginOptions", this->proxy_enable_login_options); diff --git a/src/ServerState.hh b/src/ServerState.hh index 1bafa468..fdfc7e79 100644 --- a/src/ServerState.hh +++ b/src/ServerState.hh @@ -105,6 +105,7 @@ struct ServerState : public std::enable_shared_from_this { uint32_t ep3_final_round_meseta_bonus; bool ep3_jukebox_is_free; uint32_t ep3_behavior_flags; + bool hide_download_commands; RunShellBehavior run_shell_behavior; BehaviorSwitch cheat_mode_behavior; std::vector> bb_private_keys; diff --git a/system/config.example.json b/system/config.example.json index a3b7cea9..f4fc6b79 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -226,6 +226,11 @@ // Static game data messages describe the loading of any kind of game data. "StaticGameData": "INFO", }, + // Some large commands (especially during the BB login sequence) can clutter + // up logs, so we hide these commands by default. If you're investigating or + // submitting a bug report that occurs on BB clients, set this to false to get + // a full session log before submitting your report. + "HideDownloadCommands": true, // If this option is disabled, the server only allows users who have licenses // on the server to connect. If this is enabled, all users will be allowed to diff --git a/tests/config.json b/tests/config.json index 95024f5f..2c20c168 100644 --- a/tests/config.json +++ b/tests/config.json @@ -105,6 +105,7 @@ "GameServer": "INFO", "StaticGameData": "INFO", }, + "HideDownloadCommands": true, "AllowUnregisteredUsers": true, "AllowPCNTE": true,