#include "server.hpp" #include #include #include #include #include #include "cracker.hpp" #define CRACK_OK() \ res.body = "Crack OK!"; \ res.status = 200 CrackerServer::CrackerServer() { Post("/disable_all", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_all(); } catch (std::exception& e) { SPDLOG_ERROR("Disable all failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_global_ship_properties_crack", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_global_ship_properties_crack(); } catch (std::exception& e) { SPDLOG_ERROR("Enable global ship properties crack failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_global_ship_properties_crack", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_global_ship_properties_crack(); } catch (std::exception& e) { SPDLOG_ERROR("Disable global ship properties crack failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_global_ship_properties", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::ShipProperties properties = { .armor = j["armor"].asDouble(), .speed = j["speed"].asDouble(), .antiaircraft = j["antiaircraft"].asDouble(), .oxy_recovery_bench = j["oxy_recovery_bench"].asDouble(), .torpedo = j["torpedo"].asDouble(), .hit = j["hit"].asDouble(), .sonarRange = j["sonarRange"].asDouble(), .attack_duration = j["attack_duration"].asDouble(), .raid_distance = j["raid_distance"].asDouble(), .oxy_recovery_surface = j["oxy_recovery_surface"].asDouble(), .oxy_recovery = j["oxy_recovery"].asDouble(), .dodge = j["dodge"].asDouble(), .luck = j["luck"].asDouble(), .reload = j["reload"].asDouble(), .oxy_cost = j["oxy_cost"].asDouble(), .durability = j["durability"].asDouble(), .air = j["air"].asDouble(), .oxy_max = j["oxy_max"].asDouble(), .cannon = j["cannon"].asDouble(), .antisub = j["antisub"].asDouble(), }; Cracker::Instance().update_global_ship_properties(properties); } catch (std::exception& e) { SPDLOG_ERROR("Update global ship properties failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_fast_stage_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_fast_stage_move(); } catch (std::exception& e) { SPDLOG_ERROR("Enable fast stage move failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_fast_stage_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_fast_stage_move(); } catch (std::exception& e) { SPDLOG_ERROR("Disable fast stage move failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_remove_hard_mode_ship_properties_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Enable remove hard mode ship properties limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_remove_hard_mode_ship_properties_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Disable remove hard mode ship properties limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_remove_hard_mode_ship_type_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_remove_hard_mode_ship_type_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Enable remove hard mode ship type limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_remove_hard_mode_ship_type_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_remove_hard_mode_ship_type_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Disable remove hard mode ship type limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_remove_hard_mode_limit", [](const httplib::Request& req, httplib::Response& res) { try { auto& cracker = Cracker::Instance(); cracker.enable_remove_hard_mode_ship_type_limit(); cracker.enable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Enable remove hard mode limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_remove_hard_mode_limit", [](const httplib::Request& req, httplib::Response& res) { try { auto& cracker = Cracker::Instance(); cracker.disable_remove_hard_mode_ship_type_limit(); cracker.disable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Disable remove hard mode limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_no_bb_animation", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_no_bb_animation(); } catch (std::exception& e) { SPDLOG_ERROR("Enable no bb animation failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_no_bb_animation", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_no_bb_animation(); } catch (std::exception& e) { SPDLOG_ERROR("Disable no bb animation failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/print_table_field", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); std::vector path; for (auto& key : j["path"]) { path.push_back(key.asString()); } Cracker::Instance().print_table_field(path); } catch (std::exception& e) { SPDLOG_ERROR("Print table field failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Post("/print_value", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); std::vector path; for (auto& key : j["path"]) { path.push_back(key.asString()); } Cracker::Instance().print_value(path); } catch (std::exception& e) { SPDLOG_ERROR("Print value failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Post("/enable_fake_player", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_fake_player(); } catch (std::exception& e) { SPDLOG_ERROR("Enable fake player failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_fake_player", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_fake_player(); } catch (std::exception& e) { SPDLOG_ERROR("Disable fake player failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_fake_player_info", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::FakePlayerInfo info = { .name = j["name"].asString(), .id = j["id"].asString(), .level = j["level"].asString(), }; Cracker::Instance().update_fake_player_info(info); } catch (std::exception& e) { SPDLOG_ERROR("Update fake player info failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_no_emotion_warning", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_no_emotion_warning(); } catch (std::exception& e) { SPDLOG_ERROR("Enable no emotion warning failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_no_emotion_warning", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_no_emotion_warning(); } catch (std::exception& e) { SPDLOG_ERROR("Disable no emotion warning failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_opsi_fast_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_opsi_fast_move(); } catch (std::exception& e) { SPDLOG_ERROR("Enable opsi fast move failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_opsi_fast_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_opsi_fast_move(); } catch (std::exception& e) { SPDLOG_ERROR("Disable opsi fast move failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/is_alive", [](const httplib::Request& req, httplib::Response& res) { CRACK_OK(); }); Get("/get_coin", [](const httplib::Request& req, httplib::Response& res) { try { auto coin = Cracker::Instance().get_coin(); res.body = std::to_string(coin); } catch (std::exception& e) { SPDLOG_ERROR("Get coin failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_oil", [](const httplib::Request& req, httplib::Response& res) { try { auto oil = Cracker::Instance().get_oil(); res.body = std::to_string(oil); } catch (std::exception& e) { SPDLOG_ERROR("Get oil failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_gems", [](const httplib::Request& req, httplib::Response& res) { try { auto gems = Cracker::Instance().get_gems(); res.body = std::to_string(gems); } catch (std::exception& e) { SPDLOG_ERROR("Get gems failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_level", [](const httplib::Request& req, httplib::Response& res) { try { auto level = Cracker::Instance().get_level(); res.body = std::to_string(level); } catch (std::exception& e) { SPDLOG_ERROR("Get level failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_exp", [](const httplib::Request& req, httplib::Response& res) { try { auto exp = Cracker::Instance().get_exp(); res.body = std::to_string(exp); } catch (std::exception& e) { SPDLOG_ERROR("Get exp failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_merit", [](const httplib::Request& req, httplib::Response& res) { try { auto merit = Cracker::Instance().get_merit(); res.body = std::to_string(merit); } catch (std::exception& e) { SPDLOG_ERROR("Get merit failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_guild_coin", [](const httplib::Request& req, httplib::Response& res) { try { auto guild_coin = Cracker::Instance().get_guild_coin(); res.body = std::to_string(guild_coin); } catch (std::exception& e) { SPDLOG_ERROR("Get guild coin failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_design_prt", [](const httplib::Request& req, httplib::Response& res) { try { auto design_prt = Cracker::Instance().get_design_prt(); res.body = std::to_string(design_prt); } catch (std::exception& e) { SPDLOG_ERROR("Get design prt failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_core_data", [](const httplib::Request& req, httplib::Response& res) { try { auto core_data = Cracker::Instance().get_core_data(); res.body = std::to_string(core_data); } catch (std::exception& e) { SPDLOG_ERROR("Get core data failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_medal", [](const httplib::Request& req, httplib::Response& res) { try { auto medal = Cracker::Instance().get_medal(); res.body = std::to_string(medal); } catch (std::exception& e) { SPDLOG_ERROR("Get medal failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_pt", [](const httplib::Request& req, httplib::Response& res) { try { auto pt = Cracker::Instance().get_pt(); res.body = std::to_string(pt); } catch (std::exception& e) { SPDLOG_ERROR("Get pt failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_specialized_core", [](const httplib::Request& req, httplib::Response& res) { try { auto specialized_core = Cracker::Instance().get_specialized_core(); res.body = std::to_string(specialized_core); } catch (std::exception& e) { SPDLOG_ERROR("Get specialized core failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_curr_action_point", [](const httplib::Request& req, httplib::Response& res) { try { auto curr_action_point = Cracker::Instance().get_curr_action_point(); res.body = std::to_string(curr_action_point); } catch (std::exception& e) { SPDLOG_ERROR("Get curr action point failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/scan_dock", [](const httplib::Request& req, httplib::Response& res) { try { auto dock = Cracker::Instance().scan_dock(); Json::Value j; for (auto& ship : dock) { Json::Value ship_info_j; ship_info_j["config_id"] = ship.second.config_id; ship_info_j["emotion"] = ship.second.emotion; ship_info_j["rarity"] = ship.second.rarity; ship_info_j["level"] = ship.second.level; ship_info_j["exp"] = ship.second.exp; ship_info_j["curr_star"] = ship.second.curr_star; j[std::to_string(ship.first)] = ship_info_j; } Json::FastWriter writer; res.body = writer.write(j); } catch (std::exception& e) { SPDLOG_ERROR("Scan dock failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/scan_storage", [](const httplib::Request& req, httplib::Response& res) { try { auto storage = Cracker::Instance().scan_storage(); Json::Value j; for (auto& item : storage) { j[std::to_string(item.first)] = item.second; } Json::FastWriter writer; res.body = writer.write(j); } catch (std::exception& e) { SPDLOG_ERROR("Scan storage failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_ship_info", [](const httplib::Request& req, httplib::Response& res) { try { auto id = req.get_param_value("id"); if (id.empty()) { res.status = 400; return; } auto ship_info = Cracker::Instance().get_ship_info(std::stoi(id)); if (ship_info.has_value()) { Cracker::ShipInfo& info = ship_info.value(); Json::Value j; j["config_id"] = info.config_id; j["emotion"] = info.emotion; j["rarity"] = info.rarity; j["level"] = info.level; j["exp"] = info.exp; j["curr_star"] = info.curr_star; Json::FastWriter writer; res.body = writer.write(j); res.status = 200; } else { res.status = 400; return; } } catch (std::exception& e) { SPDLOG_ERROR("Get ship info failed: {}", e.what()); res.status = 500; return; } }); Get("/get_storage_item_count", [](const httplib::Request& req, httplib::Response& res) { try { auto item_id = req.get_param_value("item_id"); if (item_id.empty()) { res.status = 400; return; } auto count = Cracker::Instance().get_storage_item_count(std::stoi(item_id)); if (count.has_value()) { res.body = std::to_string(count.value()); res.status = 200; } else { res.status = 400; return; } } catch (std::exception& e) { SPDLOG_ERROR("Get storage item count failed: {}", e.what()); res.status = 500; return; } }); Post("/enable_gg_factor", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_gg_factor(); } catch (std::exception& e) { SPDLOG_ERROR("Enable gg factor failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_gg_factor", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_gg_factor(); } catch (std::exception& e) { SPDLOG_ERROR("Disable gg factor failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_gg_factor", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().update_gg_factor(j["factor"].asDouble()); } catch (std::exception& e) { SPDLOG_ERROR("Update gg factor failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_global_speedup", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_global_speedup(); } catch (std::exception& e) { SPDLOG_ERROR("Enable global speedup failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_global_speedup_rate", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().update_global_speedup_rate(j["rate"].asFloat()); } catch (std::exception& e) { SPDLOG_ERROR("Enable global speedup failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); 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; } CRACK_OK(); }); Post("/enable_exercise_god_mode", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_exercise_god_mode(); } catch (std::exception& e) { SPDLOG_ERROR("Enable exercise god mode failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_exercise_god_mode", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_exercise_god_mode(); } catch (std::exception& e) { SPDLOG_ERROR("Disable exercise god mode failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_exercise_more_power", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_exercise_more_power(); } catch (std::exception& e) { SPDLOG_ERROR("Enable exercise more power failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_exercise_more_power_rate", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().update_exercise_more_power_rate(j["rate"].asDouble() / 100); } catch (std::exception& e) { SPDLOG_ERROR("Update exercise more power rate failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_exercise_more_power", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_exercise_more_power(); } catch (std::exception& e) { SPDLOG_ERROR("Disable exercise more power failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_fast_wave", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_fast_wave(); } catch (std::exception& e) { SPDLOG_ERROR("Enable fast wave failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_fast_wave", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_fast_wave(); } catch (std::exception& e) { SPDLOG_ERROR("Disable fast wave failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_monster_kill_self", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_monster_kill_self(); } catch (std::exception& e) { SPDLOG_ERROR("Enable monster kill self failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_monster_kill_self", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_monster_kill_self(); } catch (std::exception& e) { SPDLOG_ERROR("Disable monster kill self failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_skip_battle_celebrate", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_skip_battle_celebrate(); } catch (std::exception& e) { SPDLOG_ERROR("Enable skip battle celebrate failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_skip_battle_celebrate", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_skip_battle_celebrate(); } catch (std::exception& e) { SPDLOG_ERROR("Disable skip battle celebrate failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/init", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance(); } catch (std::exception& e) { SPDLOG_ERROR("Init failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Get("/get_config", [](const httplib::Request& req, httplib::Response& res) { try { auto j = Cracker::Instance().get_config_json(); Json::FastWriter writer; res.body = writer.write(j); res.status = 200; res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Headers", "*"); res.set_header("Access-Control-Allow-Methods", "*"); return; } catch (std::exception& e) { SPDLOG_ERROR("Get config failed: {}", e.what()); res.status = 500; return; } res.status = 500; return; }); Options("/get_config", [](const httplib::Request& req, httplib::Response& res) { res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Headers", "*"); res.set_header("Access-Control-Allow-Methods", "*"); res.status = 200; }); Post("/apply", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Config config = { .flag = { .GLOBAL_SHIP_PROPERTIES_CRACK = j["globalShipProperties"]["enabled"].asBool(), .FAST_STAGE_MOVE_CRACK = j["chapterFastMove"]["enabled"].asBool(), .REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT = j["removeHardModeShipPropertiesLimit"]["enabled"].asBool(), .REMOVE_HARD_MODE_SHIP_TYPE_LIMIT = j["removeHardModeShipTypeLimit"]["enabled"].asBool(), .NO_BB_ANIMATION = j["noBBAnimation"]["enabled"].asBool(), .NO_EMOTION_WARNING = j["noEmotionWarning"]["enabled"].asBool(), .OPSI_FAST_MOVE = j["opsiFastMove"]["enabled"].asBool(), .GG_FACTOR = j["ggFactor"]["enabled"].asBool(), .GLOBAL_SPEEDUP = j["globalSpeedup"]["enabled"].asBool(), .EXERCISE_GOD_MOD = j["exerciseGodMode"]["enabled"].asBool(), .EXERCISE_MORE_POWER = j["exerciseMorePower"]["enabled"].asBool(), }, .globle_ship_properties = { .armor = j["globalShipProperties"]["value"]["armor"]["value"].asDouble(), .speed = j["globalShipProperties"]["value"]["speed"]["value"].asDouble(), .antiaircraft = j["globalShipProperties"]["value"]["antiaircraft"]["value"].asDouble(), .oxy_recovery_bench = j["globalShipProperties"]["value"]["oxy_recovery_bench"]["value"].asDouble(), .torpedo = j["globalShipProperties"]["value"]["torpedo"]["value"].asDouble(), .hit = j["globalShipProperties"]["value"]["hit"]["value"].asDouble(), .sonarRange = j["globalShipProperties"]["value"]["sonarRange"]["value"].asDouble(), .attack_duration = j["globalShipProperties"]["value"]["attack_duration"]["value"].asDouble(), .raid_distance = j["globalShipProperties"]["value"]["raid_distance"]["value"].asDouble(), .oxy_recovery_surface = j["globalShipProperties"]["value"]["oxy_recovery_surface"]["value"].asDouble(), .oxy_recovery = j["globalShipProperties"]["value"]["oxy_recovery"]["value"].asDouble(), .dodge = j["globalShipProperties"]["value"]["dodge"]["value"].asDouble(), .luck = j["globalShipProperties"]["value"]["luck"]["value"].asDouble(), .reload = j["globalShipProperties"]["value"]["reload"]["value"].asDouble(), .oxy_cost = j["globalShipProperties"]["value"]["oxy_cost"]["value"].asDouble(), .durability = j["globalShipProperties"]["value"]["durability"]["value"].asDouble(), .air = j["globalShipProperties"]["value"]["air"]["value"].asDouble(), .oxy_max = j["globalShipProperties"]["value"]["oxy_max"]["value"].asDouble(), .cannon = j["globalShipProperties"]["value"]["cannon"]["value"].asDouble(), .antisub = j["globalShipProperties"]["value"]["antisub"]["value"].asDouble(), }, .global_speedup_rate = j["globalSpeedup"]["value"].asFloat(), .gg_factor = j["ggFactor"]["value"].asDouble(), .exercise_more_power_rate = j["exerciseMorePower"]["value"].asDouble() / 100, }; Cracker::Instance().apply_config(config); res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Headers", "*"); res.set_header("Access-Control-Allow-Methods", "*"); CRACK_OK(); return; } catch (std::exception& e) { SPDLOG_ERROR("Apply config failed: {}", e.what()); res.status = 500; return; } res.status = 500; return; }); Options("/apply", [](const httplib::Request& req, httplib::Response& res) { res.set_header("Access-Control-Allow-Origin", "*"); res.set_header("Access-Control-Allow-Headers", "*"); res.set_header("Access-Control-Allow-Methods", "*"); res.status = 200; }); set_web_page(); std::thread([this] { SPDLOG_INFO("Start server on port 23897"); listen("0.0.0.0", 23897); }).detach(); } void CrackerServer::Start() { new CrackerServer; } void CrackerServer::set_web_page() { if (WebRes.contains("/index.html")) { Get("/", WebPageResponder(WebRes["/index.html"])); } for (auto& item: WebRes) { Get(item.first, WebPageResponder(item.second)); } } CrackerServer::WebPageResponder::WebPageResponder(WebPage& page) : m_page(page) {} void CrackerServer::WebPageResponder::operator()(const httplib::Request& req, httplib::Response& res) const { res.set_content(reinterpret_cast(m_page.content.data()), m_page.content.size(), m_page.type); res.status = 200; }