handleRuntimeDefaults(startupLog);
if (auto ttl = ::arg().asNum("system-resolver-ttl"); ttl != 0) {
- pdns::RecResolve::setInstanceParameters(ttl, []() { reloadZoneConfiguration(g_yamlSettings); });
+ // Cannot use SyncRes::s_serverID, it is nt set yet
+ pdns::RecResolve::setInstanceParameters(arg()["server-id"], ttl, []() { reloadZoneConfiguration(g_yamlSettings); });
}
g_recCache = std::make_unique<MemRecursorCache>(::arg().asNum("record-cache-shards"));
#include "logging.hh"
#include "noinitvector.hh"
#include "threadname.hh"
-#include "syncres.hh"
namespace
{
}
} // anonymous namespace
-std::function<void()> pdns::RecResolve::s_callback;
+std::string pdns::RecResolve::s_serverID;
time_t pdns::RecResolve::s_ttl{0};
+std::function<void()> pdns::RecResolve::s_callback;
-void pdns::RecResolve::setInstanceParameters(time_t ttl, const std::function<void()>& callback)
+void pdns::RecResolve::setInstanceParameters(std::string serverID, time_t ttl, const std::function<void()>& callback)
{
+ pdns::RecResolve::s_serverID = std::move(serverID);
pdns::RecResolve::s_ttl = ttl;
pdns::RecResolve::s_callback = callback;
}
if (lastSelfCheck < time(nullptr) - 3600) {
lastSelfCheck = time(nullptr);
auto resolvedServerID = serverID();
- if (resolvedServerID == SyncRes::s_serverID) {
+ if (resolvedServerID == s_serverID) {
auto log = g_slog->withName("system-resolver");
- log->info(Logr::Error, "id.server/CH/TXT resolves to my own server identidy", "id.server", Logging::Loggable(resolvedServerID));
+ log->info(Logr::Error, "id.server/CH/TXT resolves to my own server identity", "id.server", Logging::Loggable(resolvedServerID));
}
}
changes = d_resolver.refresh(time(nullptr));
{
public:
// Should be called before any getInstance() call is done
- static void setInstanceParameters(time_t ttl, const std::function<void()>& callback);
+ static void setInstanceParameters(std::string serverID, time_t ttl, const std::function<void()>& callback);
static RecResolve& getInstance();
RecResolve(time_t ttl = 60, const std::function<void()>& callback = nullptr);
Refresher d_refresher;
+ static std::string s_serverID;
static std::function<void()> s_callback;
static time_t s_ttl;
};
serde_yaml = "0.9"
ipnet = "2.8"
once_cell = "1.18.0"
-hostname-validator = "1.1.1"
+hostname-validator = "1.1.1" # This is temporary. PR 13819 has the infra to call C++ from, so we can arrange for DNSName::ishostname() to be called instead of importing another crate aftyer that one is merged.
[build-dependencies]
cxx-build = "1.0"
BOOST_AUTO_TEST_CASE(test_basic_resolve)
{
- pdns::RecResolve::setInstanceParameters(60, nullptr);
+ pdns::RecResolve::setInstanceParameters("foo", 60, nullptr);
auto& sysResolve = pdns::RecResolve::getInstance();
auto address = sysResolve.lookupAndRegister("localhost", time(nullptr));