diff --git a/pdns/dnsdistdist/dnsdist-rules-factory.hh b/pdns/dnsdistdist/dnsdist-rules-factory.hh index 6801ffb62702a..163a82c8c13da 100644 --- a/pdns/dnsdistdist/dnsdist-rules-factory.hh +++ b/pdns/dnsdistdist/dnsdist-rules-factory.hh @@ -557,7 +557,6 @@ public: }; #endif /* HAVE_RE2 */ -#ifdef HAVE_DNS_OVER_HTTPS class HTTPHeaderRule : public DNSRule { public: @@ -593,7 +592,6 @@ private: Regex d_regex; std::string d_visual; }; -#endif class SNIRule : public DNSRule { diff --git a/pdns/dnsdistdist/dnsdist-rules.cc b/pdns/dnsdistdist/dnsdist-rules.cc index b305b69f68342..1450e2248ebc0 100644 --- a/pdns/dnsdistdist/dnsdist-rules.cc +++ b/pdns/dnsdistdist/dnsdist-rules.cc @@ -25,14 +25,17 @@ std::atomic LuaFFIPerThreadRule::s_functionsCounter = 0; thread_local std::map LuaFFIPerThreadRule::t_perThreadStates; -#ifdef HAVE_DNS_OVER_HTTPS HTTPHeaderRule::HTTPHeaderRule(const std::string& header, const std::string& regex) : d_header(toLower(header)), d_regex(regex), d_visual("http[" + header + "] ~ " + regex) { +#if !defined(HAVE_DNS_OVER_HTTPS) + throw std::runtime_error("Using HTTPHeaderRule while DoH support is not enabled"); +#endif /* HAVE_DNS_OVER_HTTPS */ } bool HTTPHeaderRule::matches(const DNSQuestion* dq) const { +#if defined(HAVE_DNS_OVER_HTTPS) if (!dq->ids.du) { return false; } @@ -43,6 +46,7 @@ bool HTTPHeaderRule::matches(const DNSQuestion* dq) const return d_regex.match(header.second); } } +#endif /* HAVE_DNS_OVER_HTTPS */ return false; } @@ -54,16 +58,23 @@ string HTTPHeaderRule::toString() const HTTPPathRule::HTTPPathRule(std::string path) : d_path(std::move(path)) { +#if !defined(HAVE_DNS_OVER_HTTPS) + throw std::runtime_error("Using HTTPPathRule while DoH support is not enabled"); +#endif /* HAVE_DNS_OVER_HTTPS */ } bool HTTPPathRule::matches(const DNSQuestion* dq) const { +#if defined(HAVE_DNS_OVER_HTTPS) if (!dq->ids.du) { return false; } const auto path = dq->ids.du->getHTTPPath(); return d_path == path; +#else + return false; +#endif /* HAVE_DNS_OVER_HTTPS */ } string HTTPPathRule::toString() const @@ -74,15 +85,22 @@ string HTTPPathRule::toString() const HTTPPathRegexRule::HTTPPathRegexRule(const std::string& regex) : d_regex(regex), d_visual("http path ~ " + regex) { +#if !defined(HAVE_DNS_OVER_HTTPS) + throw std::runtime_error("Using HTTPRegexRule while DoH support is not enabled"); +#endif /* HAVE_DNS_OVER_HTTPS */ } bool HTTPPathRegexRule::matches(const DNSQuestion* dq) const { +#if defined(HAVE_DNS_OVER_HTTPS) if (!dq->ids.du) { return false; } return d_regex.match(dq->ids.du->getHTTPPath()); +#else + return false; +#endif /* HAVE_DNS_OVER_HTTPS */ } string HTTPPathRegexRule::toString() const @@ -90,8 +108,6 @@ string HTTPPathRegexRule::toString() const return d_visual; } -#endif /* HAVE_DNS_OVER_HTTPS */ - namespace dnsdist::selectors { std::shared_ptr getQClassSelector(const std::string& qclassStr, uint16_t qclassCode) diff --git a/tasks.py b/tasks.py index 849db035cdc2c..65e6765065cb0 100644 --- a/tasks.py +++ b/tasks.py @@ -82,6 +82,7 @@ 'libnghttp2-dev', 'libre2-dev', 'libsnmp-dev', + 'python-yaml', ] dnsdist_xdp_build_deps = [ 'libbpf-dev',