blob: 483ba7ddd2e4e20f8932349a49f8148f244dc554 (
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
|
/*
* 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
*/
#include "filterlist.hpp"
#include <QIODevice>
#include <QTextStream>
using namespace Hostlist;
std::map<Filterlist::DomainHash, Filterlist::Rule> Filterlist::parseRule(const QString &line)
{
auto parts = line.trimmed().split(' ');
if(parts.size() < 2) {
return {};
}
const auto redirect = (parts[0] == "0.0.0.0") ? QString() : parts[0];
std::map<DomainHash, Rule> r;
for(int i = 1; i < parts.size(); ++i) {
r.emplace(qHash(parts[i], 0), Filterlist::Rule{ parts[i], redirect });
}
return r;
}
|