1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-17 07:49:29 +08:00

add: global speedup for hook

This commit is contained in:
0O0o0oOoO00
2025-05-11 15:19:14 +08:00
parent 724e89fd0f
commit 604da2aaeb
15 changed files with 487 additions and 355 deletions

View File

@@ -603,6 +603,34 @@ CrackerServer::CrackerServer() {
res.status = 200;
});
Post("/enable_global_speedup", [](const httplib::Request& req, httplib::Response& res) {
try {
Json::Reader reader;
Json::Value j;
reader.parse(req.body, j);
Cracker::Instance().enable_global_speedup(j["rate"].asFloat());
} catch (std::exception& e) {
SPDLOG_ERROR("Enable global speedup failed: {}", e.what());
res.status = 500;
return;
}
res.status = 200;
});
Post("/disable_global_speedup", [](const httplib::Request& req, httplib::Response& res) {
try {
Json::Reader reader;
Json::Value j;
reader.parse(req.body, j);
Cracker::Instance().disable_global_speedup();
} catch (std::exception& e) {
SPDLOG_ERROR("Disable global speedup failed: {}", e.what());
res.status = 500;
return;
}
res.status = 200;
});
std::thread([this] {
SPDLOG_INFO("Start server on port 23897");
listen("0.0.0.0", 23897);