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

+1 -18
View File
@@ -29,28 +29,10 @@ namespace api
response.set_content(R"({"access":"reject"})", JSON_TYPE);
return;
}
std::ifstream dnsserversfile("/etc/dnsmasq.conf.d/resolv.conf");
std::stringstream responsedata;
responsedata << R"({"servers":)";
responsedata << config::config.getConfig()["settings"]["dns"]["servers"];
// std::string dns_server_string = "";
// int iter = 0;
// while (std::getline(dnsserversfile, dns_server_string))
// {
// dns_server_string.erase(0, 11);
// responsedata << "\"" << dns_server_string << R"(",)";
// dns_server_string = "";
// iter++;
// }
// if (iter != 0)
// {
// responsedata.str(responsedata.str().erase(responsedata.str().size() - 1, 1) + "]}");
// }
// else
// {
responsedata << "}";
// }
dnsserversfile.close();
response.set_content(responsedata.str(), JSON_TYPE);
}
@@ -82,6 +64,7 @@ namespace api
dnsserversfile << "nameserver " << srv << "\n";
}
dnsserversfile.close();
config::config.setConfig(std::string("../config.json"));
nlohmann::json new_config = config::config.getConfig();
new_config["settings"]["dns"]["servers"] = json_body["servers"];
config::config.setConfig(new_config);