2025-01-28 19:02:30 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "connection.hpp"
|
|
|
|
#include "ref.hpp"
|
|
|
|
|
|
|
|
#include <boost/signals2/connection.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
2025-01-30 09:28:28 -08:00
|
|
|
/// @brief Implements the CHALLENGE command protocol to identify as an operator.
|
2025-01-28 19:02:30 -08:00
|
|
|
class Challenge : std::enable_shared_from_this<Challenge>
|
|
|
|
{
|
2025-01-30 11:47:26 -08:00
|
|
|
Ref<EVP_PKEY> key_;
|
2025-01-28 19:02:30 -08:00
|
|
|
Connection &connection_;
|
|
|
|
boost::signals2::scoped_connection slot_;
|
|
|
|
std::string buffer_;
|
|
|
|
|
|
|
|
auto on_ircmsg(IrcCommand cmd, const IrcMsg &msg) -> void;
|
2025-01-29 09:54:17 -08:00
|
|
|
auto finish_challenge() -> void;
|
2025-01-28 19:02:30 -08:00
|
|
|
|
|
|
|
public:
|
2025-01-30 11:47:26 -08:00
|
|
|
Challenge(Ref<EVP_PKEY>, Connection &);
|
2025-01-30 09:28:28 -08:00
|
|
|
|
|
|
|
/// @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.
|
2025-01-30 11:47:26 -08:00
|
|
|
static auto start(Connection &, std::string_view user, Ref<EVP_PKEY> key) -> std::shared_ptr<Challenge>;
|
2025-01-28 19:02:30 -08:00
|
|
|
};
|