Skip to content
API Documentation
BastionGuard™
WebProbe.hpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#pragma once
22#include <string>
23#include <functional>
24#include <shared_mutex>
25
26class WebProbe {
27public:
28 using NotifyCb = std::function<void(const std::string&, const std::string&, bool)>;
29
30 explicit WebProbe(const std::string& blocklist_path_hint = "", int warning_port = 81);
32
33 std::string check_url(const std::string& url);
34 void reload_blocklist(const std::string& path_hint);
36
37private:
38 std::string extract_host(const std::string& raw);
39 std::string build_local_warning_redirect(const std::string& url) const;
40
42 mutable std::shared_mutex mutex_;
44};
NotifyCb notify_cb_
Definition WebProbe.hpp:43
void register_callback(NotifyCb cb)
Definition WebProbe.cpp:227
std::string build_local_warning_redirect(const std::string &url) const
Definition WebProbe.cpp:178
std::string check_url(const std::string &url)
Definition WebProbe.cpp:185
void reload_blocklist(const std::string &path_hint)
Definition WebProbe.cpp:232
int warning_port_
Definition WebProbe.hpp:41
WebProbe(const std::string &blocklist_path_hint="", int warning_port=81)
Definition WebProbe.cpp:139
std::shared_mutex mutex_
Definition WebProbe.hpp:42
std::function< void(const std::string &, const std::string &, bool)> NotifyCb
Definition WebProbe.hpp:28
std::string extract_host(const std::string &raw)
Definition WebProbe.cpp:147