Skip to content

Commit

Permalink
dnsdist: Fix compilation in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Dec 4, 2024
1 parent 7534aa2 commit a383553
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pdns/dnsdistdist/dnsdist-rules-factory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ public:
};
#endif /* HAVE_RE2 */

#ifdef HAVE_DNS_OVER_HTTPS
class HTTPHeaderRule : public DNSRule
{
public:
Expand Down Expand Up @@ -593,7 +592,6 @@ private:
Regex d_regex;
std::string d_visual;
};
#endif

class SNIRule : public DNSRule
{
Expand Down
22 changes: 19 additions & 3 deletions pdns/dnsdistdist/dnsdist-rules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
std::atomic<uint64_t> LuaFFIPerThreadRule::s_functionsCounter = 0;
thread_local std::map<uint64_t, LuaFFIPerThreadRule::PerThreadState> 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;
}
Expand All @@ -43,6 +46,7 @@ bool HTTPHeaderRule::matches(const DNSQuestion* dq) const
return d_regex.match(header.second);
}
}
#endif /* HAVE_DNS_OVER_HTTPS */
return false;
}

Expand All @@ -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
Expand All @@ -74,24 +85,29 @@ 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
{
return d_visual;
}

#endif /* HAVE_DNS_OVER_HTTPS */

namespace dnsdist::selectors
{
std::shared_ptr<QClassRule> getQClassSelector(const std::string& qclassStr, uint16_t qclassCode)
Expand Down
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
'libnghttp2-dev',
'libre2-dev',
'libsnmp-dev',
'python-yaml',
]
dnsdist_xdp_build_deps = [
'libbpf-dev',
Expand Down

0 comments on commit a383553

Please sign in to comment.