31 lines
859 B
C++
31 lines
859 B
C++
|
#pragma once
|
||
|
|
||
|
#include <memory>
|
||
|
#include <string>
|
||
|
#include <unordered_map>
|
||
|
#include <unordered_set>
|
||
|
|
||
|
class Connection;
|
||
|
class CommandEvent;
|
||
|
|
||
|
class PrivThread : std::enable_shared_from_this<PrivThread>
|
||
|
{
|
||
|
Connection& connection_;
|
||
|
std::unordered_map<std::string, std::unordered_set<std::string>> oper_privs;
|
||
|
std::unordered_map<std::string, std::unordered_set<std::string>> account_privs;
|
||
|
|
||
|
auto on_command(CommandEvent&) -> void;
|
||
|
|
||
|
auto check(
|
||
|
std::unordered_map<std::string, std::unordered_set<std::string>> const& privs,
|
||
|
std::string const& priv,
|
||
|
std::string const& name) -> bool;
|
||
|
|
||
|
public:
|
||
|
PrivThread(Connection&);
|
||
|
auto check_command(CommandEvent& event, std::string priv) -> bool;
|
||
|
|
||
|
static constexpr char const* owner_priv = "owner";
|
||
|
|
||
|
static auto start(Connection&) -> std::shared_ptr<PrivThread>;
|
||
|
};
|