-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBlockList.cpp
More file actions
29 lines (26 loc) · 813 Bytes
/
Copy pathBlockList.cpp
File metadata and controls
29 lines (26 loc) · 813 Bytes
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
#include "BlockList.h"
#include <boost/filesystem.hpp>
#include <iostream>
#include <fstream>
namespace fs = boost::filesystem;
using namespace std;
BlockList::BlockList(const string& block_dir) {
if (!fs::exists(block_dir)) {
cerr << "[-] " << block_dir << " doesn't exist." << endl;
return;
}
for (auto& p : fs::directory_iterator(block_dir)) {
cout << "[ ] Parsing block list " << p << endl;
string line;
ifstream file{ p.path().string() };
if (file.is_open()) {
while(getline(file, line)) {
block_list.insert(line);
}
} else {
cout << "[-] Unable to open " << p << endl;
}
}
cout << "[+] Parsed " << block_list.size() << " blocked domains." << endl;
}
const std::unordered_set<std::string>& BlockList::list() const { return block_list; }