added full support for config file
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Waiting to run
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Waiting to run

This commit is contained in:
wt committed 2025-02-11 03:24:55 +07:00
1 parent 0c4183843f
commit 6e85d8e922
21 files changed
+209 -254

No files matched your search

+8 -13
View File
@@ -31,10 +31,6 @@ namespace api
response.set_content(R"({"access":"reject"})", JSON_TYPE);
return;
}
// std::ifstream sshstatusfile("/etc/openrouter/ssh/status");
// int ssh_status;
// sshstatusfile >> ssh_status;
// sshstatusfile.close();
int ssh_status = config::config.getConfig()["settings"]["ssh"]["enabled"];
std::stringstream responsedata;
responsedata << R"({"status":")" << ssh_status << R"("})";
@@ -63,9 +59,8 @@ namespace api
response.set_content(R"({"access":"reject"})", JSON_TYPE);
return;
}
std::ofstream sshfileout("/etc/openrouter/ssh/status");
std::string new_ssh_status = json_body["status"];
if (new_ssh_status == "0")
bool new_ssh_status = json_body["status"];
if (!new_ssh_status)
{
if (get_ssh_server() == DROPBEAR_SSH)
{
@@ -89,12 +84,12 @@ namespace api
}
syslog(LOG_INFO, "%s", "SSH is enabled");
}
sshfileout << stoi(new_ssh_status);
sshfileout.close();
std::ifstream sshfile("/etc/openrouter/ssh/status");
int ssh_status;
sshfile >> ssh_status;
sshfile.close();
config::config.setConfig(std::string("../config.json"));
nlohmann::json new_config = config::config.getConfig();
new_config["settings"]["ssh"]["enabled"] = new_ssh_status;
config::config.setConfig(new_config);
config::config.saveConfig();
int ssh_status = config::config.getConfig()["settings"]["ssh"]["enabled"];
std::stringstream responsedata;
responsedata << R"({"status":")" << ssh_status << R"("})";
response.set_content(responsedata.str(), JSON_TYPE);