From 4a1cb996776fedab20b93a46dc221ef9f05203f8 Mon Sep 17 00:00:00 2001 From: LA_DI_DA <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Sun, 23 Mar 2025 19:47:41 +0800 Subject: [PATCH] ref: change reload key to admin key --- blcrack/updater/main.cpp | 6 +++--- blcrack/updater/server.cpp | 10 +++++----- blcrack/updater/server.hpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/blcrack/updater/main.cpp b/blcrack/updater/main.cpp index ca3d6e857..62ddbfc8f 100644 --- a/blcrack/updater/main.cpp +++ b/blcrack/updater/main.cpp @@ -28,12 +28,12 @@ int main(int argc, char* argv[]) { cxxopts::Options options("BlCrackUpdater"); options.add_options() ("p,port", "Port to listen on", cxxopts::value()->default_value("7541")) - ("k,reload-key", "Reload key for the server", cxxopts::value()->default_value("BlCrackUpdater")); + ("k,admin-key", "Admin key for the server", cxxopts::value()->default_value("BlCrackUpdater")); auto result = options.parse(argc, argv); int port = result["port"].as(); - std::string reload_key = result["reload-key"].as(); + std::string admin_key = result["admin-key"].as(); - UpdateServer::Instance().start(port, reload_key).join(); + UpdateServer::Instance().start(port, admin_key).join(); return 0; } diff --git a/blcrack/updater/server.cpp b/blcrack/updater/server.cpp index 5a24c55c4..c8af33712 100644 --- a/blcrack/updater/server.cpp +++ b/blcrack/updater/server.cpp @@ -77,20 +77,20 @@ UpdateServer::UpdateServer() { Post("/reload", [this](const httplib::Request& req, httplib::Response& res) { SPDLOG_INFO("{} requested reload", req.remote_addr); - if (req.body == m_reload_key) { + if (req.body == m_admin_key) { update_files(); res.status = 200; return; } - SPDLOG_WARN("Invalid reload key: {}", req.body); + SPDLOG_WARN("Invalid key: {}", req.body); res.status = 400; }); } -UpdateServer& UpdateServer::start(int port, const std::string& reload_key) { - m_reload_key = reload_key; +UpdateServer& UpdateServer::start(int port, const std::string& admin_key) { + m_admin_key = admin_key; m_server_thread = std::thread([this, port] { - SPDLOG_INFO("Update server on port {}, reload key: {}", port, m_reload_key); + SPDLOG_INFO("Update server on port {}, reload key: {}", port, m_admin_key); listen("0.0.0.0", port); }); return *this; diff --git a/blcrack/updater/server.hpp b/blcrack/updater/server.hpp index e723e4773..0ce240553 100644 --- a/blcrack/updater/server.hpp +++ b/blcrack/updater/server.hpp @@ -20,7 +20,7 @@ public: UpdateServer(); ~UpdateServer() override = default; - UpdateServer& start(int port = 7541, const std::string& reload_key = ""); + UpdateServer& start(int port = 7541, const std::string& admin_key = ""); void join(); static UpdateServer& Instance(); @@ -30,7 +30,7 @@ private: static FileHash hash_file(const FileData& data); bool is_file_exists(const std::string& arch, const std::string& file) const; - std::string m_reload_key; + std::string m_admin_key; std::thread m_server_thread; std::map> m_files; };