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:
1 parent
0c4183843f
commit
6e85d8e922
21 files changed
+209
-254
No files matched your search
@@ -29,38 +29,10 @@ namespace api
|
||||
response.set_content(R"({"access":"reject"})", JSON_TYPE);
|
||||
return;
|
||||
}
|
||||
// std::ifstream domainsfile("/etc/dnsmasq.conf.d/hosts");
|
||||
std::stringstream responsedata;
|
||||
responsedata << R"({"domains":)";
|
||||
// std::string ip_string = "";
|
||||
// std::string domain_string = "";
|
||||
// int iter = 0;
|
||||
responsedata << config::config.getConfig()["settings"]["dns"]["localdomains"];
|
||||
// for (nlohmann::json domains : config::config.getConfig()["setttings"]["dns"]["localdomains"]) {
|
||||
// responsedata <<
|
||||
// }
|
||||
// while (!domainsfile.eof())
|
||||
// {
|
||||
// domainsfile >> ip_string;
|
||||
// domainsfile >> domain_string;
|
||||
// if (domain_string.empty())
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// responsedata << R"({"ip":")" << ip_string << R"(","domain":")" << domain_string << R"("},)";
|
||||
// ip_string = "";
|
||||
// domain_string = "";
|
||||
// iter++;
|
||||
// }
|
||||
// if (iter != 0)
|
||||
// {
|
||||
// responsedata.str(responsedata.str().erase(responsedata.str().size() - 1, 1) + "]}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
responsedata << "}";
|
||||
// }
|
||||
// domainsfile.close();
|
||||
responsedata << "}";
|
||||
response.set_content(responsedata.str(), JSON_TYPE);
|
||||
}
|
||||
|
||||
@@ -89,6 +61,7 @@ namespace api
|
||||
domainsfile << ip << " " << dom << "\n";
|
||||
}
|
||||
domainsfile.close();
|
||||
config::config.setConfig(std::string("../config.json"));
|
||||
nlohmann::json new_config = config::config.getConfig();
|
||||
new_config["settings"]["dns"]["localdomains"] = json_body["domains"];
|
||||
config::config.setConfig(new_config);
|
||||
|
||||
Reference in new issue
Block a user