From 5162c0c381a4c2bb6ebe551b8b0d0fc13e6dd227 Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Thu, 15 Jul 2021 21:45:46 +0200 Subject: [PATCH] Log RCON on demand with a dvar --- src/Components/Modules/RCon.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index b1cc435b..870609fb 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -29,7 +29,8 @@ namespace Components if (!RCon::Password.empty()) { Network::Address target(addr); - if (!target.isValid()) { + if (!target.isValid()) + { target = Party::Target(); } @@ -75,6 +76,7 @@ namespace Components Dvar::OnInit([]() { Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); + Dvar::Register("log_rcon_requests", true, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); }); Network::Handle("rcon", [](Network::Address address, const std::string& _data) @@ -111,7 +113,12 @@ namespace Components static std::string outputBuffer; outputBuffer.clear(); - Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data()); +#ifndef DEBUG + if (Dvar::Var("log_rcon_requests").get()) +#endif + { + Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data()); + } Logger::PipeOutput([](const std::string& output) {