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
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:
@@ -31,10 +31,6 @@ namespace api
|
||||
response.set_content(R"({"access":"reject"})", JSON_TYPE);
|
||||
return;
|
||||
}
|
||||
// std::ifstream dnsfile("/etc/openrouter/dns");
|
||||
// int dns_enabled;
|
||||
// dnsfile >> dns_enabled;
|
||||
// dnsfile.close();
|
||||
int dns_enabled = config::config.getConfig()["settings"]["dns"]["enabled"];
|
||||
std::stringstream responsedata;
|
||||
responsedata << R"({"enabled":")" << dns_enabled << R"("})";
|
||||
@@ -63,7 +59,6 @@ namespace api
|
||||
response.set_content(R"({"access":"reject"})", JSON_TYPE);
|
||||
return;
|
||||
}
|
||||
// std::ofstream dnsfileout("/etc/openrouter/dns");
|
||||
bool new_dns_enabled = json_body["enabled"];
|
||||
if (!new_dns_enabled)
|
||||
{
|
||||
@@ -77,18 +72,12 @@ namespace api
|
||||
system("rc add dnsmasq");
|
||||
syslog(LOG_INFO, "%s", "DNS is enabled");
|
||||
}
|
||||
config::config.setConfig(std::string("../config.json"));
|
||||
nlohmann::json new_config = config::config.getConfig();
|
||||
new_config["settings"]["dns"]["enabled"] = new_dns_enabled;
|
||||
config::config.setConfig(new_config);
|
||||
config::config.saveConfig();
|
||||
int dns_enabled = config::config.getConfig()["settings"]["dns"]["enabled"];
|
||||
// dnsfileout << stoi(new_dns_enabled);
|
||||
// dnsfileout.close();
|
||||
// std::ifstream dnsfile("/etc/openrouter/dns");
|
||||
// int dns_enabled;
|
||||
// dnsfile >> dns_enabled;
|
||||
// dnsfile.close();
|
||||
|
||||
std::stringstream responsedata;
|
||||
responsedata << R"({"enabled":")" << dns_enabled << R"("})";
|
||||
response.set_content(responsedata.str(), JSON_TYPE);
|
||||
|
||||
Reference in New Issue
Block a user