little fixes #32
+16
-18
@@ -21,17 +21,16 @@ namespace api
|
|||||||
void Settings::restore(const httplib::Request& request, httplib::Response& response)
|
void Settings::restore(const httplib::Request& request, httplib::Response& response)
|
||||||
{
|
{
|
||||||
const httplib::MultipartFormData& file = request.get_file_value("restore_settings");
|
const httplib::MultipartFormData& file = request.get_file_value("restore_settings");
|
||||||
if (file.content_type == JSON_TYPE) {
|
if (!file.content_type.compare(JSON_TYPE)) {
|
||||||
nlohmann::json new_config = nlohmann::json::parse(file.content);
|
response.set_content(R"({"status":false})", JSON_TYPE);
|
||||||
config::config.setConfig(new_config);
|
|
||||||
config::config.saveConfig();
|
|
||||||
set_all_settings(config::config.getConfig());
|
|
||||||
response.set_content(R"({"status":true})", JSON_TYPE);
|
|
||||||
system("rc restart auth_service");
|
|
||||||
system("rc restart openrouter");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.set_content(R"({"status":false})", JSON_TYPE);
|
nlohmann::json new_config = nlohmann::json::parse(file.content);
|
||||||
|
config::config.setConfig(new_config);
|
||||||
|
config::config.saveConfig();
|
||||||
|
set_all_settings(config::config.getConfig());
|
||||||
|
response.set_content(R"({"status":true})", JSON_TYPE);
|
||||||
|
system("rc restart openrouter");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::restore_defaults(const httplib::Request& request, httplib::Response& response)
|
void Settings::restore_defaults(const httplib::Request& request, httplib::Response& response)
|
||||||
@@ -39,17 +38,16 @@ namespace api
|
|||||||
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
|
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
|
||||||
response.set_header("Access-Control-Allow-Origin", "*");
|
response.set_header("Access-Control-Allow-Origin", "*");
|
||||||
check_body_empty(request, response, ACCESS_REQUIRED_STRING);
|
check_body_empty(request, response, ACCESS_REQUIRED_STRING);
|
||||||
if (std::filesystem::exists(config::config.getConfigFileName())) {
|
if (!std::filesystem::exists(config::config.getConfigFileName())) {
|
||||||
std::filesystem::remove(config::config.getConfigFileName());
|
response.set_content(R"({"status":false})", JSON_TYPE);
|
||||||
std::filesystem::copy("../config_default.json", config::config.getConfigFileName());
|
|
||||||
config::config.setConfig(config::config.getConfigFileName());
|
|
||||||
set_all_settings(config::config.getConfig());
|
|
||||||
response.set_content(R"({"status":true})", JSON_TYPE);
|
|
||||||
system("rc restart auth_service");
|
|
||||||
system("rc restart openrouter");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.set_content(R"({"status":false})", JSON_TYPE);
|
std::filesystem::remove(config::config.getConfigFileName());
|
||||||
|
std::filesystem::copy("../config_default.json", config::config.getConfigFileName());
|
||||||
|
config::config.setConfig(config::config.getConfigFileName());
|
||||||
|
set_all_settings(config::config.getConfig());
|
||||||
|
response.set_content(R"({"status":true})", JSON_TYPE);
|
||||||
|
system("rc restart openrouter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,11 @@ namespace api
|
|||||||
system("rc stop dnsmasq");
|
system("rc stop dnsmasq");
|
||||||
system("rc del dnsmasq");
|
system("rc del dnsmasq");
|
||||||
syslog(LOG_INFO, "%s", "DNS is disabled");
|
syslog(LOG_INFO, "%s", "DNS is disabled");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
system("rc restart dnsmasq");
|
||||||
{
|
system("rc add dnsmasq");
|
||||||
system("rc restart dnsmasq");
|
syslog(LOG_INFO, "%s", "DNS is enabled");
|
||||||
system("rc add dnsmasq");
|
|
||||||
syslog(LOG_INFO, "%s", "DNS is enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ namespace api
|
|||||||
system("rc stop ftpd");
|
system("rc stop ftpd");
|
||||||
system("rc del ftpd");
|
system("rc del ftpd");
|
||||||
syslog(LOG_INFO, "%s", "Ftp is disabled");
|
syslog(LOG_INFO, "%s", "Ftp is disabled");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
system("rc start ftpd");
|
||||||
{
|
system("rc add ftpd");
|
||||||
system("rc start ftpd");
|
syslog(LOG_INFO, "%s", "Ftp is enabled");
|
||||||
system("rc add ftpd");
|
|
||||||
syslog(LOG_INFO, "%s", "Ftp is enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,20 +24,18 @@ namespace api
|
|||||||
system("rc del ssh");
|
system("rc del ssh");
|
||||||
}
|
}
|
||||||
syslog(LOG_INFO, "%s", "SSH is disabled");
|
syslog(LOG_INFO, "%s", "SSH is disabled");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
if (ssh_server == DROPBEAR_SSH)
|
||||||
{
|
{
|
||||||
if (ssh_server == DROPBEAR_SSH)
|
system("rc start dropbear");
|
||||||
{
|
system("rc add dropbear");
|
||||||
system("rc start dropbear");
|
|
||||||
system("rc add dropbear");
|
|
||||||
}
|
|
||||||
else if (ssh_server == OPENSSH_SSH) {
|
|
||||||
system("rc start ssh");
|
|
||||||
system("rc add ssh");
|
|
||||||
}
|
|
||||||
syslog(LOG_INFO, "%s", "SSH is enabled");
|
|
||||||
}
|
}
|
||||||
|
else if (ssh_server == OPENSSH_SSH) {
|
||||||
|
system("rc start ssh");
|
||||||
|
system("rc add ssh");
|
||||||
|
}
|
||||||
|
syslog(LOG_INFO, "%s", "SSH is enabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ namespace api
|
|||||||
system("rc stop telnetd");
|
system("rc stop telnetd");
|
||||||
system("rc del telnetd");
|
system("rc del telnetd");
|
||||||
syslog(LOG_INFO, "%s", "Telnet is disabled");
|
syslog(LOG_INFO, "%s", "Telnet is disabled");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
system("rc start telnetd");
|
||||||
{
|
system("rc add telnetd");
|
||||||
system("rc start telnetd");
|
syslog(LOG_INFO, "%s", "Telnet is enabled");
|
||||||
system("rc add telnetd");
|
|
||||||
syslog(LOG_INFO, "%s", "Telnet is enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,11 @@ namespace api
|
|||||||
system("rc stop hostapd");
|
system("rc stop hostapd");
|
||||||
system("rc del hostapd");
|
system("rc del hostapd");
|
||||||
syslog(LOG_INFO, "%s", "WIFI is disabled");
|
syslog(LOG_INFO, "%s", "WIFI is disabled");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
system("rc start hostapd");
|
||||||
{
|
system("rc add hostapd");
|
||||||
system("rc start hostapd");
|
syslog(LOG_INFO, "%s", "WIFI is enabled");
|
||||||
system("rc add hostapd");
|
|
||||||
syslog(LOG_INFO, "%s", "WIFI is enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user