aboutsummaryrefslogtreecommitdiff
path: root/staging/hostlist/filterlist.hpp
blob: 24243e5b001e064eae6b055e9019fe14f2e0ca0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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://library.iserlohn-fortress.net/aqua/smolbote.git
 *
 * SPDX-License-Identifier: GPL-3.0
 */

#pragma once

#include <map>
#include <smolbote/filterinterface.hpp>

namespace Hostlist
{

class Filterlist final : public Filter
{
public:
    Filterlist() = default;
    ~Filterlist() = default;

    [[nodiscard]] bool filter(QWebEngineUrlRequestInfo &info) const
    {
        return false;
    }
    [[nodiscard]] bool isUpToDate() const
    {
        return true;
    }

    typedef uint DomainHash;
    struct Rule {
        QString domain;
        QString redirect;
    };

    [[nodiscard]] static std::map<DomainHash, Rule> parseRule(const QString &line);

private:
    std::map<DomainHash, Rule> rules;
};
} // namespace Hostlist