Skip to content
API Documentation
BastionGuard™
AutomaticResponseSink.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <atomic>
6#include <condition_variable>
7#include <deque>
8#include <filesystem>
9#include <mutex>
10#include <set>
11#include <string>
12#include <thread>
13
15
16class AutomaticResponseSink final : public IEventSink {
17public:
18 explicit AutomaticResponseSink(IEventSink& downstream,
19 bool autoBlockSystemServices);
20 ~AutomaticResponseSink() override;
21
24
25 void onEvent(const rg_event& event) noexcept override;
26 void setAutoBlockSystemServices(bool enabled) noexcept;
27
28private:
29 void workerLoop() noexcept;
30 void enqueueService(const std::filesystem::path& path,
31 const rg_event& source) noexcept;
32 void emitServiceResult(const std::filesystem::path& path,
33 const rg_event& source,
34 bool success) noexcept;
35
37 std::filesystem::path path;
39 };
40
42 std::atomic<bool> autoBlockSystemServices_{true};
43 std::mutex mutex_;
44 std::condition_variable condition_;
45 std::deque<PendingService> queue_;
46 std::set<std::string> queuedPaths_;
47 bool stopping_{};
48 std::thread worker_;
49};
50
51} // namespace bastionguard::rootguard
void emitServiceResult(const std::filesystem::path &path, const rg_event &source, bool success) noexcept
AutomaticResponseSink & operator=(const AutomaticResponseSink &)=delete
AutomaticResponseSink(IEventSink &downstream, bool autoBlockSystemServices)
AutomaticResponseSink(const AutomaticResponseSink &)=delete
void enqueueService(const std::filesystem::path &path, const rg_event &source) noexcept
void onEvent(const rg_event &event) noexcept override