Files
openrouter/src/settings/dns/servers.cpp
T
wt cedc9cd995
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
making easy
2025-02-20 18:07:59 +07:00

30 lines
827 B
C++

#include <settings/dns/dns.hpp>
#include <syslog.h>
#include <fstream>
namespace api
{
namespace settings
{
namespace dns
{
void set_dns_servers(nlohmann::json servers)
{
std::ofstream dnsserversfile("/etc/dnsmasq.conf.d/resolv.conf");
for (const nlohmann::json_abi_v3_11_3::json& server : servers)
{
std::string srv = server;
if (server == "")
{
continue;
}
dnsserversfile << "nameserver " << srv << "\n";
}
dnsserversfile.close();
system("rc restart dnsmasq");
syslog(LOG_INFO, "%s", "DNS servers changed");
}
}
}
}