xbot/myirc/include/challenge.hpp

32 lines
942 B
C++

#pragma once
#include "connection.hpp"
#include "ref.hpp"
#include <boost/signals2/connection.hpp>
#include <memory>
#include <string>
/// @brief Implements the CHALLENGE command protocol to identify as an operator.
class Challenge : std::enable_shared_from_this<Challenge>
{
Ref<EVP_PKEY> key_;
std::shared_ptr<Connection> connection_;
boost::signals2::scoped_connection slot_;
std::string buffer_;
auto on_ircmsg(IrcCommand cmd, const IrcMsg &msg) -> void;
auto finish_challenge() -> void;
public:
Challenge(Ref<EVP_PKEY>, std::shared_ptr<Connection>);
/// @brief Starts the CHALLENGE protocol.
/// @param connection Registered connection.
/// @param user Operator username
/// @param key Operator private RSA key
/// @return Handle to the challenge object.
static auto start(std::shared_ptr<Connection>, std::string_view user, Ref<EVP_PKEY> key) -> std::shared_ptr<Challenge>;
};