PDNS_CHECK_SQLITE3
AM_CONDITIONAL([SQLITE3], [test "x$needsqlite3" = "xyes"])
+PDNS_CHECK_RE2
+
for a in $modules; do
AC_MSG_CHECKING([whether we can build module "${a}"])
if [[ -d "$srcdir/modules/${a}backend" ]]; then
--- /dev/null
+AC_DEFUN([PDNS_CHECK_RE2], [
+ PKG_CHECK_MODULES([RE2], [re2], [HAVE_RE2=1], [HAVE_RE2=0])
+ AM_CONDITIONAL([HAVE_RE2], [test "$HAVE_RE2" -eq 1])
+ AS_IF([test "$HAVE_RE2" -eq 1], [AC_DEFINE([HAVE_RE2], [1], [Define if using RE2.])])
+
+])
AM_CPPFLAGS += $(SQLITE3_CFLAGS)
endif
+if HAVE_RE2
+AM_CPPFLAGS += $(RE2_CFLAGS)
+endif
+
if LUA
AM_CPPFLAGS +=$(LUA_CFLAGS)
endif
$(LIBSODIUM_LIBS) \
$(OPENSSL_LIBS)
+if HAVE_RE2
+dnsdist_LDADD += $(RE2_LIBS)
+endif
+
htmlfiles.h: $(srcdir)/dnsdistdist/html/*
$(srcdir)/dnsdistdist/incfiles $(srcdir)/dnsdistdist > $@
endif
return std::shared_ptr<DNSRule>(new RegexRule(str));
});
+#ifdef HAVE_RE2
+ g_lua.writeFunction("RE2Rule", [](const std::string& str) {
+ return std::shared_ptr<DNSRule>(new RE2Rule(str));
+ });
+#endif
+
g_lua.writeFunction("SuffixMatchNodeRule", [](const SuffixMatchNode& smn) {
return std::shared_ptr<DNSRule>(new SuffixMatchNodeRule(smn));
});
min_js: $(MIN_JS_FILES)
+if HAVE_RE2
+AM_CPPFLAGS += $(RE2_CFLAGS)
+endif
+
+
EXTRA_DIST=dnslabeltext.rl \
dnsdistconf.lua \
README.md \
$(LIBSODIUM_LIBS) \
$(SANITIZER_FLAGS)
+if HAVE_RE2
+dnsdist_LDADD += $(RE2_LIBS)
+endif
+
testrunner_SOURCES = \
base64.hh \
BOOST_REQUIRE([1.35])
BOOST_FOREACH
PDNS_ENABLE_UNIT_TESTS
+PDNS_CHECK_RE2
DNSDIST_ENABLE_DNSCRYPT
AC_SUBST([YAHTTP_CFLAGS], ['-I$(top_srcdir)/ext/yahttp'])
--- /dev/null
+../../../m4/pdns_check_re2.m4
\ No newline at end of file
string toString() const override
{
- return "Regex qname: "+d_visual;
+ return "Regex: "+d_visual;
}
private:
Regex d_regex;
string d_visual;
};
+#ifdef HAVE_RE2
+#include <re2/re2.h>
+class RE2Rule : public DNSRule
+{
+public:
+ RE2Rule(const std::string& re2) : d_re2(re2, RE2::Latin1), d_visual(re2)
+ {
+
+ }
+ bool matches(const DNSQuestion* dq) const override
+ {
+ return RE2::FullMatch(dq->qname->toStringNoDot(), d_re2);
+ }
+
+ string toString() const override
+ {
+ return "RE2 match: "+d_visual;
+ }
+private:
+ RE2 d_re2;
+ string d_visual;
+};
+#endif
+
class SuffixMatchNodeRule : public DNSRule
{