#pragma once #include "event.hpp" #include #include #include #include class Connection; struct hs_database; struct hs_scratch; enum class SnoteTag { ClientConnecting, ClientExiting, RejectingKlined, NickChange, CreateChannel, TemporaryKlineExpired, PropagatedBanExpired, DisconnectingKlined, NewPropagatedKline, NewTemporaryKline, LoginAttempts, PossibleFlooder, Killed, TooManyGlobalConnections, SetVhostOnMarkedAccount, }; class SnoteEvent : public Event { public: SnoteEvent(SnoteTag tag, std::regex const& regex, std::string_view full) : tag_{tag} , components_{std::make_pair(std::ref(regex), full)} {} auto get_tag() const -> SnoteTag; auto get_results() -> std::match_results const&; private: SnoteTag tag_; std::variant, std::match_results> components_; }; struct SnoteThread { struct DbDeleter { auto operator()(hs_database * db) const -> void; }; struct ScratchDeleter { auto operator()(hs_scratch * scratch) const -> void; }; /// @brief Database of server notice patterns std::unique_ptr db_; /// @brief HyperScan scratch space std::unique_ptr scratch_; static auto start(Connection& connection) -> std::shared_ptr; };