str<<base<<"senderrors" << ' ' << s->sendErrors.load() << " " << now << "\r\n";
str<<base<<"outstanding" << ' ' << s->outstanding.load() << " " << now << "\r\n";
}
+ for(const auto& front : g_frontends) {
+ if (front->udpFD == -1 && front->tcpFD == -1)
+ continue;
+
+ string frontName = front->local.toStringWithPort() + (front->udpFD >= 0 ? "_udp" : "_tcp");
+ boost::replace_all(frontName, ".", "_");
+ const string base = "dnsdist." + hostname + ".main.frontends." + frontName + ".";
+ str<<base<<"queries" << ' ' << front->queries.load() << " " << now << "\r\n";
+ }
const string msg = str.str();
int ret = waitForRWData(s.getHandle(), false, 1 , 0);
GlobalStateHolder<NetmaskGroup> g_ACL;
string g_outputBuffer;
vector<std::pair<ComboAddress, bool>> g_locals;
+vector<ClientState *> g_frontends;
/* UDP: the grand design. Per socket we listen on for incoming queries there is one thread.
Then we have a bunch of connected sockets for talking to downstream servers.
try {
len = recvmsg(cs->udpFD, &msgh, 0);
+ cs->queries++;
+ g_stats.queries++;
+
if(len < (int)sizeof(struct dnsheader)) {
g_stats.nonCompliantQueries++;
continue;
continue;
}
- g_stats.queries++;
if(!acl->match(remote)) {
vinfolog("Query from %s dropped because of ACL", remote.toStringWithPort());
g_stats.aclDrops++;
SBind(cs->udpFD, cs->local);
toLaunch.push_back(cs);
+ g_frontends.push_back(cs);
}
for(const auto& local : g_locals) {
- ClientState* cs = new ClientState;
if(!local.second) { // no TCP/IP
warnlog("Not providing TCP/IP service on local address '%s'", local.first.toStringWithPort());
continue;
}
+ ClientState* cs = new ClientState;
cs->local= local.first;
cs->tcpFD = SSocket(cs->local.sin4.sin_family, SOCK_STREAM, 0);
warnlog("Listening on %s",cs->local.toStringWithPort());
toLaunch.push_back(cs);
+ g_frontends.push_back(cs);
}
uid_t newgid=0;
struct ClientState
{
ComboAddress local;
+ std::atomic<uint64_t> queries{0};
int udpFD{-1};
int tcpFD{-1};
};
extern ComboAddress g_serverControl; // not changed during runtime
extern std::vector<std::pair<ComboAddress, bool>> g_locals; // not changed at runtime (we hope XXX)
+extern vector<ClientState*> g_frontends;
extern std::string g_key; // in theory needs locking
extern bool g_truncateTC;
extern int g_tcpRecvTimeout;