From c74367d82c1c7bec393548d2e5014c794333822f Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 16 Oct 2018 17:25:40 +0200 Subject: urlfilter: Add FilterTree class FilterTree is a class that holds filter rules, sorted by the domain they are to be applied on. The rules are to follow FilterLeaf as interface. - Add a hostlist rule format to FilterTree. - Add a test for hostlist format. --- lib/urlfilter/filterleaf.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/urlfilter/filterleaf.h (limited to 'lib/urlfilter/filterleaf.h') diff --git a/lib/urlfilter/filterleaf.h b/lib/urlfilter/filterleaf.h new file mode 100644 index 0000000..6d9caae --- /dev/null +++ b/lib/urlfilter/filterleaf.h @@ -0,0 +1,43 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#ifndef SMOLBOTE_FILTERLEAF_H +#define SMOLBOTE_FILTERLEAF_H + +#include +#include + +class FilterLeaf +{ +public: + enum Action { + NotMatched, + Allow, + Block, + Redirect + }; + + FilterLeaf(FilterLeaf &&other); + FilterLeaf& operator=(FilterLeaf &&other); + ~FilterLeaf() = default; + + virtual bool match(const QString &requestUrl) const = 0; + virtual Action action() const = 0; + + const QString request() const; + const QString redirect() const; + +protected: + explicit FilterLeaf() = default; + + bool m_isBlocking; + std::string m_request; + std::string m_redirect; +}; + +#endif // SMOLBOTE_FILTERLEAF_H -- cgit v1.2.1