str<<(*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first);
str<<' '<<now<<"\r\n";
}
- const auto states = g_dstates.getCopy();
- for(const auto& state : states) {
+ auto states = g_dstates.getLocal();
+ for(const auto& state : *states) {
string serverName = state->name.empty() ? (state->remote.toString() + ":" + std::to_string(state->remote.getPort())) : state->getName();
boost::replace_all(serverName, ".", "_");
const string base = "dnsdist." + hostname + ".main.servers." + serverName + ".";
const string base = "dnsdist." + hostname + ".main.frontends." + frontName + ".";
str<<base<<"queries" << ' ' << front->queries.load() << " " << now << "\r\n";
}
- const auto localPools = g_pools.getCopy();
- for (const auto& entry : localPools) {
+ auto localPools = g_pools.getLocal();
+ for (const auto& entry : *localPools) {
string poolName = entry.first;
boost::replace_all(poolName, ".", "_");
if (poolName.empty()) {
setLuaNoSideEffect();
vector<string> vec;
- g_ACL.getCopy().toStringVector(&vec);
+ g_ACL.getLocal()->toStringVector(&vec);
for(const auto& s : vec)
g_outputBuffer+=s+"\n";
uint64_t totQPS{0}, totQueries{0}, totDrops{0};
int counter=0;
- auto states = g_dstates.getCopy();
- for(const auto& s : states) {
+ auto states = g_dstates.getLocal();
+ for(const auto& s : *states) {
string status = s->getStatus();
string pools;
for(auto& p : s->pools) {
/* get a copy of the shared_ptrs so they are not
destroyed while we process the request */
- const auto& dstates = g_dstates.getCopy();
+ auto dstates = g_dstates.getLocal();
s_servers.clear();
- s_servers.reserve(dstates.size());
- for (const auto& server : dstates) {
+ s_servers.reserve(dstates->size());
+ for (const auto& server : *dstates) {
s_servers.push_back(server);
}
static void apiSaveACL(const NetmaskGroup& nmg)
{
vector<string> vec;
- g_ACL.getCopy().toStringVector(&vec);
+ g_ACL.getLocal()->toStringVector(&vec);
string acl;
for(const auto& s : vec) {
using namespace json11;
Json::array responseRules;
int num=0;
- auto localResponseRules = someResponseRules->getCopy();
- for(const auto& a : localResponseRules) {
+ auto localResponseRules = someResponseRules->getLocal();
+ for(const auto& a : *localResponseRules) {
Json::object rule{
{"id", num++},
{"uuid", boost::uuids::to_string(a.d_id)},
}
else if(command=="dynblocklist") {
Json::object obj;
- auto slow = g_dynblockNMG.getCopy();
+ auto nmg = g_dynblockNMG.getLocal();
struct timespec now;
gettime(&now);
- for(const auto& e: slow) {
+ for(const auto& e: *nmg) {
if(now < e->second.until ) {
Json::object thing{
{"reason", e->second.reason},
}
}
- auto slow2 = g_dynblockSMT.getCopy();
- slow2.visit([&now,&obj](const SuffixMatchTree<DynBlock>& node) {
+ auto smt = g_dynblockSMT.getLocal();
+ smt->visit([&now,&obj](const SuffixMatchTree<DynBlock>& node) {
if(now <node.d_value.until) {
string dom("empty");
if(!node.d_value.domain.empty())
resp.status=200;
Json::array servers;
- auto localServers = g_dstates.getCopy();
+ auto localServers = g_dstates.getLocal();
int num=0;
- for(const auto& a : localServers) {
+ for(const auto& a : *localServers) {
string status;
if(a->availability == DownstreamState::Availability::Up)
status = "UP";
}
Json::array pools;
- auto localPools = g_pools.getCopy();
+ auto localPools = g_pools.getLocal();
num=0;
- for(const auto& pool :localPools) {
+ for(const auto& pool : *localPools) {
const auto& cache = pool.second->packetCache;
Json::object entry {
{ "id", num++ },
}
Json::array rules;
- auto localRules = g_rulactions.getCopy();
+ auto localRules = g_rulactions.getLocal();
num=0;
- for(const auto& a : localRules) {
+ for(const auto& a : *localRules) {
Json::object rule{
{"id", num++},
{"uuid", boost::uuids::to_string(a.d_id)},
string acl;
vector<string> vec;
- g_ACL.getCopy().toStringVector(&vec);
+ g_ACL.getLocal()->toStringVector(&vec);
for(const auto& s : vec) {
if(!acl.empty()) acl += ", ";
Json::array doc;
typedef boost::variant<bool, double, std::string> configentry_t;
std::vector<std::pair<std::string, configentry_t> > configEntries {
- { "acl", g_ACL.getCopy().toString() },
+ { "acl", g_ACL.getLocal()->toString() },
{ "control-socket", g_serverControl.toStringWithPort() },
{ "ecs-override", g_ECSOverride },
{ "ecs-source-prefix-v4", (double) g_ECSSourcePrefixV4 },
if (resp.status == 200) {
Json::array acl;
vector<string> vec;
- g_ACL.getCopy().toStringVector(&vec);
+ g_ACL.getLocal()->toStringVector(&vec);
for(const auto& s : vec) {
acl.push_back(s);
counter++;
if (counter >= g_cacheCleaningDelay) {
- const auto localPools = g_pools.getCopy();
+ auto localPools = g_pools.getLocal();
std::shared_ptr<DNSDistPacketCache> packetCache = nullptr;
- for (const auto& entry : localPools) {
+ for (const auto& entry : *localPools) {
packetCache = entry.second->packetCache;
if (packetCache) {
size_t upTo = (packetCache->getMaxEntries()* (100 - g_cacheCleaningPercentage)) / 100;
if(g_tcpclientthreads->getQueuedCount() > 1 && !g_tcpclientthreads->hasReachedMaxThreads())
g_tcpclientthreads->addTCPClientThread();
- for(auto& dss : g_dstates.getCopy()) { // this points to the actual shared_ptrs!
+ auto states = g_dstates.getLocal(); // this points to the actual shared_ptrs!
+ for(auto& dss : *states) {
if(dss->availability==DownstreamState::Availability::Auto) {
bool newState=upCheck(*dss);
if (newState) {
{
/* stdin, stdout, stderr */
size_t requiredFDsCount = 3;
- const auto backends = g_dstates.getCopy();
+ auto backends = g_dstates.getLocal();
/* UDP sockets to backends */
size_t backendUDPSocketsCount = 0;
- for (const auto& backend : backends) {
+ for (const auto& backend : *backends) {
backendUDPSocketsCount += backend->sockets.size();
}
requiredFDsCount += backendUDPSocketsCount;
/* TCP sockets to backends */
- requiredFDsCount += (backends.size() * g_maxTCPClientThreads);
+ requiredFDsCount += (backends->size() * g_maxTCPClientThreads);
/* listening sockets */
requiredFDsCount += udpBindsCount;
requiredFDsCount += tcpBindsCount;
warnlog("dnsdist %s comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it according to the terms of the GPL version 2", VERSION);
vector<string> vec;
std::string acls;
- g_ACL.getCopy().toStringVector(&vec);
+ g_ACL.getLocal()->toStringVector(&vec);
for(const auto& s : vec) {
if (!acls.empty())
acls += ", ";
}
g_pools.setState(localPools);
- if(g_dstates.getCopy().empty()) {
+ if(g_dstates.getLocal()->empty()) {
errlog("No downstream servers defined: all packets will get dropped");
// you might define them later, but you need to know
}