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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user