void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
{
+#ifndef DISABLE_NON_FFI_DQ_BINDINGS
/* DNSQuestion */
/* PowerDNS DNSQuestion compat */
luaCtx.registerMember<const ComboAddress (DNSQuestion::*)>("localaddr", [](const DNSQuestion& dq) -> const ComboAddress { return *dq.local; }, [](DNSQuestion& dq, const ComboAddress newLocal) { (void) newLocal; });
checkParameterBound("setNegativeAndAdditionalSOA", minimum, std::numeric_limits<uint32_t>::max());
return setNegativeAndAdditionalSOA(dq, nxd, DNSName(zone), ttl, DNSName(mname), DNSName(rname), serial, refresh, retry, expire, minimum);
});
+#endif /* DISABLE_NON_FFI_DQ_BINDINGS */
}
}
return string("No exception");
});
+#ifndef DISABLE_POLICIES_BINDINGS
/* ServerPolicy */
luaCtx.writeFunction("newServerPolicy", [](string name, ServerPolicy::policyfunc_t policy) { return std::make_shared<ServerPolicy>(name, policy, true);});
luaCtx.registerMember("name", &ServerPolicy::d_name);
luaCtx.writeVariable("whashed", ServerPolicy{"whashed", whashed, false});
luaCtx.writeVariable("chashed", ServerPolicy{"chashed", chashed, false});
luaCtx.writeVariable("leastOutstanding", ServerPolicy{"leastOutstanding", leastOutstanding, false});
+#endif /* DISABLE_POLICIES_BINDINGS */
/* ServerPool */
luaCtx.registerFunction<void(std::shared_ptr<ServerPool>::*)(std::shared_ptr<DNSDistPacketCache>)>("setCache", [](std::shared_ptr<ServerPool> pool, std::shared_ptr<DNSDistPacketCache> cache) {
luaCtx.registerFunction("getECS", &ServerPool::getECS);
luaCtx.registerFunction("setECS", &ServerPool::setECS);
+#ifndef DISABLE_DOWNSTREAM_BINDINGS
/* DownstreamState */
luaCtx.registerFunction<void(DownstreamState::*)(int)>("setQPS", [](DownstreamState& s, int lim) { s.qps = lim ? QPSLimiter(lim, lim) : QPSLimiter(); });
luaCtx.registerFunction<void(std::shared_ptr<DownstreamState>::*)(string)>("addPool", [](std::shared_ptr<DownstreamState> s, string pool) {
luaCtx.registerMember("order", &DownstreamState::order);
luaCtx.registerMember<const std::string(DownstreamState::*)>("name", [](const DownstreamState& backend) -> const std::string { return backend.getName(); }, [](DownstreamState& backend, const std::string& newName) { backend.setName(newName); });
luaCtx.registerFunction<std::string(DownstreamState::*)()const>("getID", [](const DownstreamState& s) { return boost::uuids::to_string(s.id); });
+#endif /* DISABLE_DOWNSTREAM_BINDINGS */
+#ifndef DISABLE_DNSHEADER_BINDINGS
/* dnsheader */
luaCtx.registerFunction<void(dnsheader::*)(bool)>("setRD", [](dnsheader& dh, bool v) {
dh.rd=v;
luaCtx.registerFunction<void(dnsheader::*)(bool)>("setQR", [](dnsheader& dh, bool v) {
dh.qr=v;
});
+#endif /* DISABLE_DNSHEADER_BINDINGS */
+#ifndef DISABLE_COMBO_ADDR_BINDINGS
/* ComboAddress */
luaCtx.writeFunction("newCA", [](const std::string& name) { return ComboAddress(name); });
luaCtx.writeFunction("newCAFromRaw", [](const std::string& raw, boost::optional<uint16_t> port) {
luaCtx.registerFunction<bool(ComboAddress::*)()const>("isMappedIPv4", [](const ComboAddress& ca) { return ca.isMappedIPv4(); });
luaCtx.registerFunction<ComboAddress(ComboAddress::*)()const>("mapToIPv4", [](const ComboAddress& ca) { return ca.mapToIPv4(); });
luaCtx.registerFunction<bool(nmts_t::*)(const ComboAddress&)>("match", [](nmts_t& s, const ComboAddress& ca) { return s.match(ca); });
+#endif /* DISABLE_COMBO_ADDR_BINDINGS */
+#ifndef DISABLE_DNSNAME_BINDINGS
/* DNSName */
luaCtx.registerFunction("isPartOf", &DNSName::isPartOf);
luaCtx.registerFunction<bool(DNSName::*)()>("chopOff", [](DNSName&dn ) { return dn.chopOff(); });
luaCtx.registerFunction("size",(size_t (DNSNameSet::*)() const) &DNSNameSet::size);
luaCtx.registerFunction("clear",(void (DNSNameSet::*)()) &DNSNameSet::clear);
luaCtx.registerFunction("empty",(bool (DNSNameSet::*)() const) &DNSNameSet::empty);
+#endif /* DISABLE_DNSNAME_BINDINGS */
+#ifndef DISABLE_SUFFIX_MATCH_BINDINGS
/* SuffixMatchNode */
luaCtx.registerFunction<void (SuffixMatchNode::*)(const boost::variant<DNSName, string, vector<pair<int, DNSName>>, vector<pair<int, string>>> &name)>("add", [](SuffixMatchNode &smn, const boost::variant<DNSName, string, vector<pair<int, DNSName>>, vector<pair<int, string>>> &name) {
if (name.type() == typeid(DNSName)) {
});
luaCtx.registerFunction("check",(bool (SuffixMatchNode::*)(const DNSName&) const) &SuffixMatchNode::check);
+#endif /* DISABLE_SUFFIX_MATCH_BINDINGS */
+#ifndef DISABLE_NETMASK_BINDINGS
/* Netmask */
luaCtx.writeFunction("newNetmask", [](boost::variant<std::string,ComboAddress> s, boost::optional<uint8_t> bits) {
if (s.type() == typeid(ComboAddress)) {
luaCtx.registerFunction("clear", &NetmaskGroup::clear);
luaCtx.registerFunction<string(NetmaskGroup::*)()const>("toString", [](const NetmaskGroup& nmg ) { return "NetmaskGroup " + nmg.toString(); });
luaCtx.registerFunction<string(NetmaskGroup::*)()const>("__tostring", [](const NetmaskGroup& nmg ) { return "NetmaskGroup " + nmg.toString(); });
+#endif /* DISABLE_NETMASK_BINDINGS */
+#ifndef DISABLE_QPS_LIMITER_BINDINGS
/* QPSLimiter */
luaCtx.writeFunction("newQPSLimiter", [](int rate, int burst) { return QPSLimiter(rate, burst); });
luaCtx.registerFunction("check", &QPSLimiter::check);
+#endif /* DISABLE_QPS_LIMITER_BINDINGS */
+#ifndef DISABLE_CLIENT_STATE_BINDINGS
/* ClientState */
luaCtx.registerFunction<std::string(ClientState::*)()const>("toString", [](const ClientState& fe) {
setLuaNoSideEffect();
frontend.detachFilter();
});
#endif /* HAVE_EBPF */
+#endif /* DISABLE_CLIENT_STATE_BINDINGS */
/* BPF Filter */
#ifdef HAVE_EBPF
});
std::vector<std::pair<int, vector<boost::variant<string,double>>>> ret;
- ret.reserve(std::min(rcounts.size(), top + 1U));
+ ret.reserve(std::min(rcounts.size(), static_cast<size_t>(top + 1U)));
uint64_t count = 1;
unsigned int rest = 0;
for(const auto& rc : rcounts) {
bool reusePort = false;
int tcpFastOpenQueueSize = 0;
int tcpListenQueueSize = 0;
- size_t maxInFlightQueriesPerConn = 0;
- size_t tcpMaxConcurrentConnections = 0;
+ uint64_t maxInFlightQueriesPerConn = 0;
+ uint64_t tcpMaxConcurrentConnections = 0;
std::string interface;
std::set<int> cpus;
bool reusePort = false;
int tcpFastOpenQueueSize = 0;
int tcpListenQueueSize = 0;
- size_t maxInFlightQueriesPerConn = 0;
- size_t tcpMaxConcurrentConnections = 0;
+ uint64_t maxInFlightQueriesPerConn = 0;
+ uint64_t tcpMaxConcurrentConnections = 0;
std::string interface;
std::set<int> cpus;
DynBlockMaintenance::s_expiredDynBlocksPurgeInterval = interval;
});
+#ifdef HAVE_DNSCRYPT
luaCtx.writeFunction("addDNSCryptBind", [](const std::string& addr, const std::string& providerName, boost::variant<std::string, std::vector<std::pair<int, std::string>>> certFiles, boost::variant<std::string, std::vector<std::pair<int, std::string>>> keyFiles, boost::optional<localbind_t> vars) {
if (g_configurationDone) {
g_outputBuffer = "addDNSCryptBind cannot be used at runtime!\n";
return;
}
-#ifdef HAVE_DNSCRYPT
bool reusePort = false;
int tcpFastOpenQueueSize = 0;
int tcpListenQueueSize = 0;
- size_t maxInFlightQueriesPerConn = 0;
- size_t tcpMaxConcurrentConnections = 0;
+ uint64_t maxInFlightQueriesPerConn = 0;
+ uint64_t tcpMaxConcurrentConnections = 0;
std::string interface;
std::set<int> cpus;
std::vector<DNSCryptContext::CertKeyPaths> certKeys;
errlog(e.what());
g_outputBuffer = "Error: " + string(e.what()) + "\n";
}
-#else
- g_outputBuffer = "Error: DNSCrypt support is not enabled.\n";
-#endif
});
luaCtx.writeFunction("showDNSCryptBinds", []() {
setLuaNoSideEffect();
-#ifdef HAVE_DNSCRYPT
ostringstream ret;
boost::format fmt("%1$-3d %2% %|25t|%3$-20.20s");
ret << (fmt % "#" % "Address" % "Provider Name") << endl;
}
g_outputBuffer = ret.str();
-#else
- g_outputBuffer = "Error: DNSCrypt support is not enabled.\n";
-#endif
});
luaCtx.writeFunction("getDNSCryptBind", [](uint64_t idx) {
setLuaNoSideEffect();
-#ifdef HAVE_DNSCRYPT
std::shared_ptr<DNSCryptContext> ret = nullptr;
if (idx < g_dnsCryptLocals.size()) {
ret = g_dnsCryptLocals.at(idx);
}
return ret;
-#else
- g_outputBuffer = "Error: DNSCrypt support is not enabled.\n";
-#endif
});
luaCtx.writeFunction("getDNSCryptBindCount", []() {
setLuaNoSideEffect();
return g_dnsCryptLocals.size();
});
+#endif /* HAVE_DNSCRYPT */
luaCtx.writeFunction("showPools", []() {
setLuaNoSideEffect();
g_outputBuffer = "dnsdist " + std::string(VERSION) + "\n";
});
- luaCtx.writeFunction("showSecurityStatus", []() {
- setLuaNoSideEffect();
- g_outputBuffer = std::to_string(g_stats.securityStatus) + "\n";
- });
-
#ifdef HAVE_EBPF
luaCtx.writeFunction("setDefaultBPFFilter", [](std::shared_ptr<BPFFilter> bpf) {
if (g_configurationDone) {
});
#endif /* HAVE_NET_SNMP */
+#ifndef DISABLE_POLICIES_BINDINGS
luaCtx.writeFunction("setServerPolicy", [](const ServerPolicy& policy) {
setLuaSideEffect();
g_policy.setState(policy);
g_outputBuffer = poolObj->policy->getName() + "\n";
}
});
+#endif /* DISABLE_POLICIES_BINDINGS */
luaCtx.writeFunction("setTCPDownstreamCleanupInterval", [](uint64_t interval) {
setLuaSideEffect();
return;
}
setLuaSideEffect();
- g_proxyProtocolMaximumSize = std::max(static_cast<size_t>(16), size);
+ g_proxyProtocolMaximumSize = std::max(static_cast<uint64_t>(16), size);
});
+#ifndef DISABLE_RECVMMSG
luaCtx.writeFunction("setUDPMultipleMessagesVectorSize", [](uint64_t vSize) {
if (g_configurationDone) {
errlog("setUDPMultipleMessagesVectorSize() cannot be used at runtime!");
g_outputBuffer = "recvmmsg support is not available!\n";
#endif
});
+#endif /* DISABLE_RECVMMSG */
luaCtx.writeFunction("setAddEDNSToSelfGeneratedResponses", [](bool add) {
g_addEDNSToSelfGeneratedResponses = add;
});
#ifndef DISABLE_SECPOLL
+ luaCtx.writeFunction("showSecurityStatus", []() {
+ setLuaNoSideEffect();
+ g_outputBuffer = std::to_string(g_stats.securityStatus) + "\n";
+ });
+
luaCtx.writeFunction("setSecurityPollSuffix", [](const std::string& suffix) {
if (g_configurationDone) {
g_outputBuffer = "setSecurityPollSuffix() cannot be used at runtime!\n";
bool reusePort = false;
int tcpFastOpenQueueSize = 0;
int tcpListenQueueSize = 0;
- size_t maxInFlightQueriesPerConn = 0;
- size_t tcpMaxConcurrentConnections = 0;
+ uint64_t maxInFlightQueriesPerConn = 0;
+ uint64_t tcpMaxConcurrentConnections = 0;
std::string interface;
std::set<int> cpus;
bool reusePort = false;
int tcpFastOpenQueueSize = 0;
int tcpListenQueueSize = 0;
- size_t maxInFlightQueriesPerConn = 0;
- size_t tcpMaxConcurrentConns = 0;
+ uint64_t maxInFlightQueriesPerConn = 0;
+ uint64_t tcpMaxConcurrentConns = 0;
std::string interface;
std::set<int> cpus;
return true;
}
+#ifndef DISABLE_RECVMMSG
#if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE)
static void queueResponse(const ClientState& cs, const PacketBuffer& response, const ComboAddress& dest, const ComboAddress& remote, struct mmsghdr& outMsg, struct iovec* iov, cmsgbuf_aligned* cbuf)
{
}
}
#endif /* defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) */
+#endif /* DISABLE_RECVMMSG */
/* self-generated responses or cache hits */
static bool prepareOutgoingResponse(LocalHolders& holders, ClientState& cs, DNSQuestion& dq, bool cacheHit)
// the buffer might have been invalidated by now (resized)
struct dnsheader* dh = dq.getHeader();
if (result == ProcessQueryResult::SendAnswer) {
+#ifndef DISABLE_RECVMMSG
#if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE)
if (dq.delayMsec == 0 && responsesVect != nullptr) {
queueResponse(cs, query, dest, remote, responsesVect[*queuedResponses], respIOV, respCBuf);
return;
}
#endif /* defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) */
+#endif /* DISABLE_RECVMMSG */
/* we use dest, always, because we don't want to use the listening address to send a response since it could be 0.0.0.0 */
sendUDPResponse(cs.udpFD, query, dq.delayMsec, dest, remote);
return;
}
}
+#ifndef DISABLE_RECVMMSG
#if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE)
static void MultipleMessagesUDPClientThread(ClientState* cs, LocalHolders& holders)
{
}
}
#endif /* defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) */
+#endif /* DISABLE_RECVMMSG */
// listens to incoming queries, sends out to downstream servers, noting the intended return path
static void udpClientThread(ClientState* cs)
try {
setThreadName("dnsdist/udpClie");
LocalHolders holders;
-
+#ifndef DISABLE_RECVMMSG
#if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE)
if (g_udpVectorSize > 1) {
MultipleMessagesUDPClientThread(cs, holders);
}
else
#endif /* defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) */
+#endif /* DISABLE_RECVMMSG */
{
/* the actual buffer is larger because:
- we may have to add EDNS and/or ECS
#ifdef HAVE_RE2
cout<<"re2 ";
#endif
+#ifndef DISABLE_RECVMMSG
#if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE)
cout<<"recvmmsg/sendmmsg ";
#endif
+#endif /* DISABLE_RECVMMSG */
#ifdef HAVE_NET_SNMP
cout<<"snmp ";
#endif
return res;
});
+
+#ifndef DISABLE_PACKETCACHE_BINDINGS
luaCtx.registerFunction<std::string(std::shared_ptr<DNSDistPacketCache>::*)()const>("toString", [](const std::shared_ptr<DNSDistPacketCache>& cache) {
if (cache) {
return cache->toString();
g_outputBuffer += "Dumped " + std::to_string(records) + " records\n";
}
});
+#endif /* DISABLE_PACKETCACHE_BINDINGS */
}
void setupLuaWeb(LuaContext& luaCtx)
{
+#ifndef DISABLE_LUA_WEB_HANDLERS
luaCtx.writeFunction("registerWebHandler", [](const std::string& path, std::function<void(const YaHTTP::Request*, YaHTTP::Response*)> handler) {
/* LuaWrapper does a copy for objects passed by reference, so we pass a pointer */
registerWebHandler(path, [handler](const YaHTTP::Request& req, YaHTTP::Response& resp) { handler(&req, &resp); });
resp.headers.insert({entry.first, entry.second});
}
});
+#endif /* DISABLE_LUA_WEB_HANDLERS */
}