}
#endif /* defined(HAVE_LMDB) || defined(HAVE_CDB) */
-#ifdef HAVE_DNS_OVER_HTTPS
std::shared_ptr<DNSAction> getHTTPStatusAction(uint16_t status, PacketBuffer&& body, const std::string& contentType, const dnsdist::ResponseConfig& responseConfig)
{
+#if defined(HAVE_DNS_OVER_HTTPS)
return std::shared_ptr<DNSAction>(new HTTPStatusAction(status, std::move(body), contentType, responseConfig));
+#else
+ throw std::runtime_error("Unsupported HTTPStatus action");
+#endif
}
-#endif
std::shared_ptr<DNSResponseAction> getLimitTTLResponseAction(uint32_t min, uint32_t max, std::unordered_set<QType> types)
{
std::shared_ptr<DNSResponseAction> getLuaFFIResponseAction(dnsdist::actions::LuaResponseActionFFIFunction function);
std::shared_ptr<DNSAction> getContinueAction(std::shared_ptr<DNSAction> action);
-#ifdef HAVE_DNS_OVER_HTTPS
std::shared_ptr<DNSAction> getHTTPStatusAction(uint16_t status, PacketBuffer&& body, const std::string& contentType, const dnsdist::ResponseConfig& responseConfig);
-#endif
std::shared_ptr<DNSAction> getNegativeAndSOAAction(bool nxd, const DNSName& zone, uint32_t ttl, const DNSName& mname, const DNSName& rname, const SOAParams& params, bool soaInAuthority, dnsdist::ResponseConfig responseConfig);
std::shared_ptr<DNSAction> getSetProxyProtocolValuesAction(const std::vector<std::pair<uint8_t, std::string>>& values);
std::shared_ptr<DNSAction> getRCodeAction(uint8_t rcode, const dnsdist::ResponseConfig& responseConfig);
frontend->d_tlsConfig = std::move(tlsConfig);
state.tlsFrontend = std::move(frontend);
}
+#if defined(HAVE_DNS_OVER_QUIC)
else if (protocol == "doq") {
auto frontend = std::make_shared<DOQFrontend>();
frontend->d_local = ComboAddress(std::string(bind.listen_address), 853);
frontend->d_internalPipeBufferSize = bind.quic.internal_pipe_buffer_size;
state.doqFrontend = std::move(frontend);
}
+#endif /* HAVE_DNS_OVER_QUIC */
+#if defined(HAVE_DNS_OVER_HTTP3)
else if (protocol == "doh3") {
auto frontend = std::make_shared<DOH3Frontend>();
frontend->d_local = ComboAddress(std::string(bind.listen_address), 443);
frontend->d_internalPipeBufferSize = bind.quic.internal_pipe_buffer_size;
state.doh3Frontend = std::move(frontend);
}
+#endif /* HAVE_DNS_OVER_HTTP3 */
else if (protocol == "doh") {
auto frontend = std::make_shared<DOHFrontend>();
frontend->d_tlsContext.d_provider = std::string(bind.tls.provider);
void dnsdist_ffi_dnsquestion_set_device_id(dnsdist_ffi_dnsquestion_t* dq, const char* value, size_t valueSize) __attribute__ ((visibility ("default")));
void dnsdist_ffi_dnsquestion_set_device_name(dnsdist_ffi_dnsquestion_t* dq, const char* value, size_t valueSize) __attribute__ ((visibility ("default")));
-void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* dq, uint16_t statusCode, const char* body, size_t bodyLen, const char* contentType) __attribute__ ((visibility ("default")));
+void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* ref, uint16_t statusCode, const char* body, size_t bodyLen, const char* contentType) __attribute__ ((visibility ("default")));
void dnsdist_ffi_dnsquestion_set_extended_dns_error(dnsdist_ffi_dnsquestion_t* dnsQuestion, uint16_t infoCode, const char* extraText, size_t extraTextSize) __attribute__ ((visibility ("default")));
return totalCount;
}
-size_t dnsdist_ffi_dnsquestion_get_http_headers(dnsdist_ffi_dnsquestion_t* dq, [[maybe_unused]] const dnsdist_ffi_http_header_t** out)
+size_t dnsdist_ffi_dnsquestion_get_http_headers(dnsdist_ffi_dnsquestion_t* ref, [[maybe_unused]] const dnsdist_ffi_http_header_t** out)
{
#if defined(HAVE_DNS_OVER_HTTPS) || defined(HAVE_DNS_OVER_HTTP3)
- const auto processHeaders = [&dq](const std::unordered_map<std::string, std::string>& headers) {
+ const auto processHeaders = [&ref](const std::unordered_map<std::string, std::string>& headers) {
if (headers.empty()) {
return;
}
- dq->httpHeaders = std::make_unique<std::unordered_map<std::string, std::string>>(headers);
- if (!dq->httpHeadersVect) {
- dq->httpHeadersVect = std::make_unique<std::vector<dnsdist_ffi_http_header_t>>();
+ ref->httpHeaders = std::make_unique<std::unordered_map<std::string, std::string>>(headers);
+ if (!ref->httpHeadersVect) {
+ ref->httpHeadersVect = std::make_unique<std::vector<dnsdist_ffi_http_header_t>>();
}
- dq->httpHeadersVect->clear();
- dq->httpHeadersVect->resize(dq->httpHeaders->size());
+ ref->httpHeadersVect->clear();
+ ref->httpHeadersVect->resize(ref->httpHeaders->size());
size_t pos = 0;
- for (const auto& header : *dq->httpHeaders) {
- dq->httpHeadersVect->at(pos).name = header.first.c_str();
- dq->httpHeadersVect->at(pos).value = header.second.c_str();
+ for (const auto& header : *ref->httpHeaders) {
+ ref->httpHeadersVect->at(pos).name = header.first.c_str();
+ ref->httpHeadersVect->at(pos).value = header.second.c_str();
++pos;
}
};
#if defined(HAVE_DNS_OVER_HTTPS)
- if (dq->dq->ids.du) {
- const auto& headers = dq->dq->ids.du->getHTTPHeaders();
+ if (ref->dq->ids.du) {
+ const auto& headers = ref->dq->ids.du->getHTTPHeaders();
processHeaders(headers);
}
#endif /* HAVE_DNS_OVER_HTTPS */
#if defined(HAVE_DNS_OVER_HTTP3)
- if (dq->dq->ids.doh3u) {
- const auto& headers = dq->dq->ids.doh3u->getHTTPHeaders();
+ if (ref->dq->ids.doh3u) {
+ const auto& headers = ref->dq->ids.doh3u->getHTTPHeaders();
processHeaders(headers);
}
#endif /* HAVE_DNS_OVER_HTTP3 */
- if (!dq->httpHeadersVect) {
+ if (!ref->httpHeadersVect) {
return 0;
}
- if (!dq->httpHeadersVect->empty()) {
- *out = dq->httpHeadersVect->data();
+ if (!ref->httpHeadersVect->empty()) {
+ *out = ref->httpHeadersVect->data();
}
- return dq->httpHeadersVect->size();
+ return ref->httpHeadersVect->size();
#else /* HAVE_DNS_OVER_HTTPS || HAVE_DNS_OVER_HTTP3 */
return 0;
#endif /* HAVE_DNS_OVER_HTTPS || HAVE_DNS_OVER_HTTP3 */
dq->result = std::string(str, strSize);
}
-void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* dq, [[maybe_unused]] uint16_t statusCode, [[maybe_unused]] const char* body, [[maybe_unused]] size_t bodyLen, [[maybe_unused]] const char* contentType)
+void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* ref, [[maybe_unused]] uint16_t statusCode, [[maybe_unused]] const char* body, [[maybe_unused]] size_t bodyLen, [[maybe_unused]] const char* contentType)
{
#if defined(HAVE_DNS_OVER_HTTPS)
- if (dq->dq->ids.du) {
+ if (ref->dq->ids.du) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): C API
PacketBuffer bodyVect(body, body + bodyLen);
- dq->dq->ids.du->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
- dnsdist::PacketMangling::editDNSHeaderFromPacket(dq->dq->getMutableData(), [](dnsheader& header) {
+ ref->dq->ids.du->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
+ dnsdist::PacketMangling::editDNSHeaderFromPacket(ref->dq->getMutableData(), [](dnsheader& header) {
header.qr = true;
return true;
});
}
#endif
#if defined(HAVE_DNS_OVER_HTTP3)
- if (dq->dq->ids.doh3u) {
+ if (ref->dq->ids.doh3u) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): C API
PacketBuffer bodyVect(body, body + bodyLen);
- dq->dq->ids.doh3u->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
- dnsdist::PacketMangling::editDNSHeaderFromPacket(dq->dq->getMutableData(), [](dnsheader& header) {
+ ref->dq->ids.doh3u->setHTTPResponse(statusCode, std::move(bodyVect), contentType);
+ dnsdist::PacketMangling::editDNSHeaderFromPacket(ref->dq->getMutableData(), [](dnsheader& header) {
header.qr = true;
return true;
});
luaCtx.registerMember<std::string(YaHTTP::Request::*)>("path", [](const YaHTTP::Request& req) -> std::string { return req.url.path; }, [](YaHTTP::Request& req, const std::string& path) { (void)req; (void) path; });
luaCtx.registerMember<int(YaHTTP::Request::*)>("version", [](const YaHTTP::Request& req) -> int { return req.version; }, [](YaHTTP::Request& req, int version) { (void)req; (void)version; });
luaCtx.registerMember<std::string(YaHTTP::Request::*)>("method", [](const YaHTTP::Request& req) -> std::string { return req.method; }, [](YaHTTP::Request& req, const std::string& method) { (void)req; (void) method; });
- luaCtx.registerMember<std::string(YaHTTP::Request::*)>("body", [](const YaHTTP::Request& req) -> const std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void)req; (void)body; });
+ luaCtx.registerMember<std::string(YaHTTP::Request::*)>("body", [](const YaHTTP::Request& req) -> std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void)req; (void)body; });
luaCtx.registerMember<LuaAssociativeTable<std::string>(YaHTTP::Request::*)>("getvars", [](const YaHTTP::Request& req) {
LuaAssociativeTable<std::string> values;
for (const auto& entry : req.getvars) {
#endif /* HAVE_DNS_OVER_HTTPS && HAVE_NGHTTP2 */
}
-bool sendH2Query([[maybe_unused]] const std::shared_ptr<DownstreamState>& ds, [[maybe_unused]] std::unique_ptr<FDMultiplexer>& mplexer, [[maybe_unused]] std::shared_ptr<TCPQuerySender>& sender, [[maybe_unused]] InternalQuery&& query, [[maybe_unused]] bool healthCheck)
+bool sendH2Query([[maybe_unused]] const std::shared_ptr<DownstreamState>& downstream, [[maybe_unused]] std::unique_ptr<FDMultiplexer>& mplexer, [[maybe_unused]] std::shared_ptr<TCPQuerySender>& sender, [[maybe_unused]] InternalQuery&& query, [[maybe_unused]] bool healthCheck)
{
#if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2)
struct timeval now
if (healthCheck) {
/* always do health-checks over a new connection */
- auto newConnection = std::make_shared<DoHConnectionToBackend>(ds, mplexer, now, std::move(query.d_proxyProtocolPayload));
+ auto newConnection = std::make_shared<DoHConnectionToBackend>(downstream, mplexer, now, std::move(query.d_proxyProtocolPayload));
newConnection->setHealthCheck(healthCheck);
newConnection->queueQuery(sender, std::move(query));
}
else {
- auto connection = t_downstreamDoHConnectionsManager.getConnectionToDownstream(mplexer, ds, now, std::move(query.d_proxyProtocolPayload));
+ auto connection = t_downstreamDoHConnectionsManager.getConnectionToDownstream(mplexer, downstream, now, std::move(query.d_proxyProtocolPayload));
connection->queueQuery(sender, std::move(query));
}
proxySent
};
-static void prepareQueryForSending(TCPQuery& query, uint16_t id, ConnectionState connectionState)
+static void prepareQueryForSending(TCPQuery& query, uint16_t queryID, ConnectionState connectionState)
{
if (connectionState == ConnectionState::needProxy) {
if (query.d_proxyProtocolPayload.size() > 0 && !query.d_proxyProtocolPayloadAdded) {
getSerialFromIXFRQuery(query);
}
- editPayloadID(query.d_buffer, id, query.d_proxyProtocolPayloadAdded ? query.d_idstate.d_proxyProtocolPayloadSize : 0, true);
+ editPayloadID(query.d_buffer, queryID, query.d_proxyProtocolPayloadAdded ? query.d_idstate.d_proxyProtocolPayloadSize : 0, true);
}
IOState TCPConnectionToBackend::queueNextQuery(std::shared_ptr<TCPConnectionToBackend>& conn)
{
}
- void release(bool removeFromCache)
+ static void release(bool removeFromCache)
{
(void)removeFromCache;
}