Compare commits
No commits in common. "4c119c613828b6061863656837be6fd9ee4f5bad" and "8324a496b65f8c2dbfcf307273350fdc65b0adb5" have entirely different histories.
4c119c6138
...
8324a496b6
CMakeLists.txt
driver
myirc
bot.cppchallenge.cppclient.cppconnection.cpp
include
bot.hppc_callback.hppchallenge.hppclient.hppconnection.hppirc_command.hppirc_coroutine.hppircmsg.hpplinebuffer.hppopenssl_utils.hppratelimit.hppref.hppregistration.hppsasl_mechanism.hppsnote.hppstream.hpp
ircmsg.cppopenssl_utils.cppratelimit.cppregistration.cppsasl_mechanism.cppsnote.cpp@ -10,7 +10,7 @@ find_package(OpenSSL REQUIRED)
|
|||||||
|
|
||||||
pkg_check_modules(LIBHS libhs REQUIRED IMPORTED_TARGET)
|
pkg_check_modules(LIBHS libhs REQUIRED IMPORTED_TARGET)
|
||||||
|
|
||||||
set(BOOST_INCLUDE_LIBRARIES asio log signals2 endian beast)
|
set(BOOST_INCLUDE_LIBRARIES asio log signals2 endian)
|
||||||
set(BOOST_ENABLE_CMAKE ON)
|
set(BOOST_ENABLE_CMAKE ON)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
add_executable(xbot
|
add_executable(xbot
|
||||||
main.cpp
|
main.cpp
|
||||||
settings.cpp
|
settings.cpp
|
||||||
web.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(xbot PRIVATE
|
target_link_libraries(xbot PRIVATE
|
||||||
myirc
|
myirc
|
||||||
OpenSSL::SSL
|
OpenSSL::SSL
|
||||||
Boost::signals2 Boost::log Boost::asio Boost::beast
|
Boost::signals2 Boost::log Boost::asio
|
||||||
tomlplusplus_tomlplusplus
|
tomlplusplus_tomlplusplus
|
||||||
PkgConfig::LIBHS
|
PkgConfig::LIBHS
|
||||||
mysocks5 mybase64)
|
mysocks5 mybase64)
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
|
#include "bot.hpp"
|
||||||
|
#include "challenge.hpp"
|
||||||
|
#include "client.hpp"
|
||||||
|
#include "connection.hpp"
|
||||||
|
#include "openssl_utils.hpp"
|
||||||
|
#include "registration.hpp"
|
||||||
|
#include "sasl_mechanism.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "web.hpp"
|
#include "ref.hpp"
|
||||||
|
#include "irc_coroutine.hpp"
|
||||||
#include "myirc/bot.hpp"
|
|
||||||
#include "myirc/challenge.hpp"
|
|
||||||
#include "myirc/client.hpp"
|
|
||||||
#include "myirc/connection.hpp"
|
|
||||||
#include "myirc/openssl_utils.hpp"
|
|
||||||
#include "myirc/registration.hpp"
|
|
||||||
#include "myirc/sasl_mechanism.hpp"
|
|
||||||
#include "myirc/ref.hpp"
|
|
||||||
#include "myirc/irc_coroutine.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
@ -22,16 +19,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
using myirc::SaslMechanism;
|
|
||||||
using myirc::SaslPlain;
|
|
||||||
using myirc::SaslExternal;
|
|
||||||
using myirc::SaslEcdsa;
|
|
||||||
using myirc::Bot;
|
|
||||||
using myirc::Client;
|
|
||||||
using myirc::Connection;
|
|
||||||
using myirc::Registration;
|
|
||||||
using myirc::Challenge;
|
|
||||||
using myirc::Ref;
|
|
||||||
|
|
||||||
auto configure_sasl(const Settings &settings) -> std::unique_ptr<SaslMechanism>
|
auto configure_sasl(const Settings &settings) -> std::unique_ptr<SaslMechanism>
|
||||||
{
|
{
|
||||||
@ -51,7 +38,7 @@ auto configure_sasl(const Settings &settings) -> std::unique_ptr<SaslMechanism>
|
|||||||
not settings.sasl_authcid.empty() &&
|
not settings.sasl_authcid.empty() &&
|
||||||
not settings.sasl_key_file.empty()
|
not settings.sasl_key_file.empty()
|
||||||
) {
|
) {
|
||||||
if (auto sasl_key = myirc::key_from_file(settings.sasl_key_file, settings.sasl_key_password))
|
if (auto sasl_key = key_from_file(settings.sasl_key_file, settings.sasl_key_password))
|
||||||
return std::make_unique<SaslEcdsa>(
|
return std::make_unique<SaslEcdsa>(
|
||||||
settings.sasl_authcid,
|
settings.sasl_authcid,
|
||||||
settings.sasl_authzid,
|
settings.sasl_authzid,
|
||||||
@ -60,22 +47,18 @@ auto configure_sasl(const Settings &settings) -> std::unique_ptr<SaslMechanism>
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto start(
|
static auto start(boost::asio::io_context &io, const Settings &settings) -> void
|
||||||
boost::asio::io_context &io,
|
|
||||||
const Settings &settings,
|
|
||||||
std::shared_ptr<GithubWebhook> webhook
|
|
||||||
) -> void
|
|
||||||
{
|
{
|
||||||
Ref<X509> tls_cert;
|
Ref<X509> tls_cert;
|
||||||
if (settings.use_tls && not settings.tls_cert_file.empty())
|
if (settings.use_tls && not settings.tls_cert_file.empty())
|
||||||
{
|
{
|
||||||
tls_cert = myirc::cert_from_file(settings.tls_cert_file);
|
tls_cert = cert_from_file(settings.tls_cert_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<EVP_PKEY> tls_key;
|
Ref<EVP_PKEY> tls_key;
|
||||||
if (settings.use_tls && not settings.tls_key_file.empty())
|
if (settings.use_tls && not settings.tls_key_file.empty())
|
||||||
{
|
{
|
||||||
tls_key = myirc::key_from_file(settings.tls_key_file, settings.tls_key_password);
|
tls_key = key_from_file(settings.tls_key_file, settings.tls_key_password);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto connection = std::make_shared<Connection>(io);
|
const auto connection = std::make_shared<Connection>(io);
|
||||||
@ -92,25 +75,20 @@ static auto start(
|
|||||||
|
|
||||||
// Configure CHALLENGE on registration if applicable
|
// Configure CHALLENGE on registration if applicable
|
||||||
if (not settings.challenge_username.empty() && not settings.challenge_key_file.empty()) {
|
if (not settings.challenge_username.empty() && not settings.challenge_key_file.empty()) {
|
||||||
if (auto key = myirc::key_from_file(settings.challenge_key_file, settings.challenge_key_password)) {
|
if (auto key = key_from_file(settings.challenge_key_file, settings.challenge_key_password)) {
|
||||||
client->sig_registered.connect([&settings, connection, key = std::move(key)]() {
|
client->sig_registered.connect([&settings, connection, key = std::move(key)]() {
|
||||||
Challenge::start(connection, settings.challenge_username, key);
|
Challenge::start(connection, settings.challenge_username, key);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client->sig_registered.connect([connection, webhook]() {
|
|
||||||
webhook->set_connection(connection);
|
|
||||||
});
|
|
||||||
|
|
||||||
// On disconnect reconnect in 5 seconds
|
// On disconnect reconnect in 5 seconds
|
||||||
// connection is captured in the disconnect handler so it can keep itself alive
|
// connection is captured in the disconnect handler so it can keep itself alive
|
||||||
connection->sig_disconnect.connect(
|
connection->sig_disconnect.connect(
|
||||||
[&io, &settings, connection, webhook]() {
|
[&io, &settings, connection]() {
|
||||||
webhook->clear_connection();
|
|
||||||
auto timer = std::make_shared<boost::asio::steady_timer>(io);
|
auto timer = std::make_shared<boost::asio::steady_timer>(io);
|
||||||
timer->expires_after(5s);
|
timer->expires_after(5s);
|
||||||
timer->async_wait([&io, &settings, timer, webhook](auto) { start(io, settings, webhook); });
|
timer->async_wait([&io, &settings, timer](auto) { start(io, settings); });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -150,15 +128,12 @@ auto main(int argc, char *argv[]) -> int
|
|||||||
{
|
{
|
||||||
//boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning);
|
//boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning);
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 2) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "Bad arguments";
|
BOOST_LOG_TRIVIAL(error) << "Bad arguments";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const auto settings = get_settings(argv[1]);
|
const auto settings = get_settings(argv[1]);
|
||||||
auto io = boost::asio::io_context{};
|
auto io = boost::asio::io_context{};
|
||||||
|
start(io, settings);
|
||||||
auto webhooks = start_webhook(io, argv[2]);
|
|
||||||
|
|
||||||
start(io, settings, webhooks);
|
|
||||||
io.run();
|
io.run();
|
||||||
}
|
}
|
||||||
|
263
driver/web.cpp
263
driver/web.cpp
@ -1,263 +0,0 @@
|
|||||||
#include "web.hpp"
|
|
||||||
|
|
||||||
#include <boost/beast.hpp>
|
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <fstream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace beast = boost::beast; // from <boost/beast.hpp>
|
|
||||||
namespace http = beast::http; // from <boost/beast/http.hpp>
|
|
||||||
namespace net = boost::asio; // from <boost/asio.hpp>
|
|
||||||
namespace websocket = beast::websocket;
|
|
||||||
using tcp = net::ip::tcp; // from <boost/asio/ip/tcp.hpp>
|
|
||||||
|
|
||||||
using namespace std::literals;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
auto report_error(std::exception_ptr eptr) -> void
|
|
||||||
{
|
|
||||||
if (eptr)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::rethrow_exception(eptr);
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "An error occurred: " << e.what();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Body, class Allocator>
|
|
||||||
auto handle_request(
|
|
||||||
std::shared_ptr<GithubWebhook> self,
|
|
||||||
http::request<Body, http::basic_fields<Allocator>> &&req
|
|
||||||
) -> http::message_generator
|
|
||||||
{
|
|
||||||
self->add_event({"project", "message"});
|
|
||||||
|
|
||||||
http::response<http::string_body> res{http::int_to_status(200), req.version()};
|
|
||||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
|
||||||
res.keep_alive(req.keep_alive());
|
|
||||||
|
|
||||||
std::string reply_text = "Hello, world!";
|
|
||||||
res.content_length(reply_text.size());
|
|
||||||
res.body() = std::move(reply_text);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto read_loop(tcp::socket socket, std::shared_ptr<GithubWebhook> self) -> boost::asio::awaitable<void>
|
|
||||||
{
|
|
||||||
beast::tcp_stream stream{std::move(socket)};
|
|
||||||
beast::flat_buffer buffer;
|
|
||||||
http::request<http::string_body> req;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
req.clear();
|
|
||||||
stream.expires_after(30s);
|
|
||||||
|
|
||||||
boost::system::error_code ec;
|
|
||||||
co_await http::async_read(stream, buffer, req, net::redirect_error(net::use_awaitable, ec));
|
|
||||||
if (ec == http::error::end_of_stream)
|
|
||||||
{
|
|
||||||
stream.socket().shutdown(tcp::socket::shutdown_send, ec);
|
|
||||||
co_return;
|
|
||||||
}
|
|
||||||
else if (ec)
|
|
||||||
{
|
|
||||||
co_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto msg = handle_request(self, std::move(req));
|
|
||||||
const auto keep_alive = msg.keep_alive();
|
|
||||||
|
|
||||||
co_await beast::async_write(stream, std::move(msg), net::use_awaitable);
|
|
||||||
|
|
||||||
if (!keep_alive)
|
|
||||||
{
|
|
||||||
stream.socket().shutdown(tcp::socket::shutdown_send, ec);
|
|
||||||
co_return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto accept_loop(
|
|
||||||
tcp::acceptor acceptor,
|
|
||||||
std::shared_ptr<GithubWebhook> self
|
|
||||||
) -> boost::asio::awaitable<void>
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
auto socket = co_await acceptor.async_accept(net::use_awaitable);
|
|
||||||
boost::asio::co_spawn(
|
|
||||||
acceptor.get_executor(),
|
|
||||||
read_loop(std::move(socket), self),
|
|
||||||
report_error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto spawn_webhook(
|
|
||||||
boost::asio::io_context &io,
|
|
||||||
const std::shared_ptr<GithubWebhook> webhook
|
|
||||||
) -> boost::asio::awaitable<void>
|
|
||||||
{
|
|
||||||
tcp::resolver resolver{io};
|
|
||||||
auto results = co_await resolver.async_resolve(webhook->settings_.host, webhook->settings_.service, tcp::resolver::passive, boost::asio::use_awaitable);
|
|
||||||
|
|
||||||
for (auto &&result : results)
|
|
||||||
{
|
|
||||||
const auto endpoint = result.endpoint();
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "HTTP: Listening on " << endpoint;
|
|
||||||
tcp::acceptor acceptor{io};
|
|
||||||
acceptor.open(endpoint.protocol());
|
|
||||||
acceptor.set_option(net::socket_base::reuse_address(true));
|
|
||||||
acceptor.bind(endpoint);
|
|
||||||
acceptor.listen(net::socket_base::max_listen_connections);
|
|
||||||
boost::asio::co_spawn(io, accept_loop(std::move(acceptor), webhook), report_error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
auto start_webhook(
|
|
||||||
boost::asio::io_context &io,
|
|
||||||
const char * webhook_settings_filename
|
|
||||||
) -> std::shared_ptr<GithubWebhook>
|
|
||||||
{
|
|
||||||
std::ifstream webhook_settings_file{webhook_settings_filename};
|
|
||||||
if (!webhook_settings_file)
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Unable to open webhook settings file";
|
|
||||||
std::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto webhook_settings = toml::parse(webhook_settings_file);
|
|
||||||
WebhookSettings settings = WebhookSettings::from_toml(webhook_settings);
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "Webhook settings: " << settings.to_toml();
|
|
||||||
auto webhook = std::make_shared<GithubWebhook>(std::move(settings));
|
|
||||||
boost::asio::co_spawn(io, spawn_webhook(io, webhook), report_error);
|
|
||||||
return webhook;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto GithubWebhook::write_event(WebhookEvent event) -> void
|
|
||||||
{
|
|
||||||
connection_->send_notice("glguy", event.channel + ": " + event.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ProjectSettings::from_toml(const toml::table &v) -> ProjectSettings
|
|
||||||
{
|
|
||||||
ProjectSettings result;
|
|
||||||
result.channel = v["channel"].value_or(""s);
|
|
||||||
result.credential_name = v["credential_name"].value_or(""s);
|
|
||||||
result.enabled = v["enabled"].value_or(false);
|
|
||||||
|
|
||||||
if (const auto events = v["events"].as_array())
|
|
||||||
{
|
|
||||||
for (const auto &event : *events)
|
|
||||||
{
|
|
||||||
result.events.insert(event.value_or(""s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const auto accounts = v["authorized_accounts"].as_array())
|
|
||||||
{
|
|
||||||
for (const auto &account : *accounts)
|
|
||||||
{
|
|
||||||
result.authorized_accounts.insert(account.value_or(""s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ProjectSettings::to_toml() const -> toml::table
|
|
||||||
{
|
|
||||||
toml::array events_array;
|
|
||||||
for (const auto &event : events)
|
|
||||||
{
|
|
||||||
events_array.emplace_back(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
toml::array authorized_accounts_array;
|
|
||||||
for (const auto &account : authorized_accounts)
|
|
||||||
{
|
|
||||||
authorized_accounts_array.emplace_back(account);
|
|
||||||
}
|
|
||||||
\
|
|
||||||
return toml::table{
|
|
||||||
{"channel", channel},
|
|
||||||
{"credential_name", credential_name},
|
|
||||||
{"enabled", enabled},
|
|
||||||
{"events", std::move(events_array)},
|
|
||||||
{"authorized_accounts", std::move(authorized_accounts_array)}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto WebhookSettings::from_toml(const toml::table &v) -> WebhookSettings
|
|
||||||
{
|
|
||||||
WebhookSettings result;
|
|
||||||
result.host = v["host"].value_or(""s);
|
|
||||||
result.service = v["service"].value_or("http"s);
|
|
||||||
|
|
||||||
if (const auto credentials = v["credentials"].as_array())
|
|
||||||
{
|
|
||||||
for (const auto &credential : *credentials)
|
|
||||||
{
|
|
||||||
if (auto credential_table = credential.as_table())
|
|
||||||
{
|
|
||||||
result.credentials.emplace(
|
|
||||||
(*credential_table)["name"].value_or(""s),
|
|
||||||
(*credential_table)["key"].value_or(""s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const auto projects = v["projects"].as_array())
|
|
||||||
{
|
|
||||||
for (const auto &project : *projects)
|
|
||||||
{
|
|
||||||
if (auto project_table = project.as_table())
|
|
||||||
{
|
|
||||||
result.projects.emplace(
|
|
||||||
(*project_table)["name"].value_or(""s),
|
|
||||||
ProjectSettings::from_toml(*project_table));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto WebhookSettings::to_toml() const -> toml::table
|
|
||||||
{
|
|
||||||
toml::array credential_tables;
|
|
||||||
for (const auto &[name, key] : credentials)
|
|
||||||
{
|
|
||||||
credential_tables.emplace_back(toml::table {
|
|
||||||
{"name", name},
|
|
||||||
{"key", key}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toml::array project_tables;
|
|
||||||
for (const auto &[name, project] : projects)
|
|
||||||
{
|
|
||||||
auto tab = project.to_toml();
|
|
||||||
tab.emplace("name", name);
|
|
||||||
project_tables.emplace_back(std::move(tab));
|
|
||||||
}
|
|
||||||
|
|
||||||
return toml::table{
|
|
||||||
{"host", host},
|
|
||||||
{"service", service},
|
|
||||||
{"credentials", std::move(credential_tables)},
|
|
||||||
{"projects", std::move(project_tables)}
|
|
||||||
};
|
|
||||||
}
|
|
100
driver/web.hpp
100
driver/web.hpp
@ -1,100 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <myirc/connection.hpp>
|
|
||||||
|
|
||||||
#include <toml++/toml.hpp>
|
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
|
||||||
#include <boost/signals2.hpp>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
struct ProjectSettings {
|
|
||||||
// *** Administrative settings ***
|
|
||||||
|
|
||||||
// IRC channel to announce to
|
|
||||||
std::string channel;
|
|
||||||
|
|
||||||
// name extracted from notify/$user
|
|
||||||
std::string credential_name;
|
|
||||||
|
|
||||||
// Authorized accounts can edit the event list
|
|
||||||
std::set<std::string> authorized_accounts;
|
|
||||||
|
|
||||||
// *** User settings ***
|
|
||||||
|
|
||||||
// Events to announce
|
|
||||||
std::set<std::string> events;
|
|
||||||
|
|
||||||
// Whether to announce events
|
|
||||||
bool enabled;
|
|
||||||
|
|
||||||
auto to_toml() const -> toml::table;
|
|
||||||
static auto from_toml(const toml::table &v) -> ProjectSettings;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WebhookSettings {
|
|
||||||
std::string host;
|
|
||||||
std::string service;
|
|
||||||
|
|
||||||
std::map<std::string, std::string> credentials;
|
|
||||||
std::map<std::string, ProjectSettings> projects;
|
|
||||||
|
|
||||||
auto to_toml() const -> toml::table;
|
|
||||||
static auto from_toml(const toml::table &v) -> WebhookSettings;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WebhookEvent {
|
|
||||||
std::string channel;
|
|
||||||
std::string message;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GithubWebhook {
|
|
||||||
// IRC connection to announce on; could be empty
|
|
||||||
std::shared_ptr<myirc::Connection> connection_;
|
|
||||||
|
|
||||||
// Buffered events in case connection was inactive when event was received
|
|
||||||
std::vector<WebhookEvent> events_;
|
|
||||||
|
|
||||||
|
|
||||||
// Actually write the event to the connection.
|
|
||||||
// Only call when there is a connection.
|
|
||||||
auto write_event(WebhookEvent event) -> void;
|
|
||||||
|
|
||||||
public:
|
|
||||||
WebhookSettings settings_;
|
|
||||||
|
|
||||||
GithubWebhook(WebhookSettings settings)
|
|
||||||
: settings_(std::move(settings))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Either emit the event now or save it until a connection is set
|
|
||||||
auto add_event(WebhookEvent event) -> void
|
|
||||||
{
|
|
||||||
if (connection_) {
|
|
||||||
write_event(std::move(event));
|
|
||||||
} else {
|
|
||||||
events_.emplace_back(std::move(event));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto set_connection(std::shared_ptr<myirc::Connection> connection) -> void
|
|
||||||
{
|
|
||||||
connection_ = std::move(connection);
|
|
||||||
for (auto &&event : events_)
|
|
||||||
{
|
|
||||||
write_event(event);
|
|
||||||
}
|
|
||||||
events_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto clear_connection() -> void
|
|
||||||
{
|
|
||||||
connection_.reset();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
auto start_webhook(boost::asio::io_context &io, const char *) -> std::shared_ptr<GithubWebhook>;
|
|
@ -1,9 +1,7 @@
|
|||||||
#include "myirc/bot.hpp"
|
#include "bot.hpp"
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
auto Bot::start(std::shared_ptr<Client> self) -> std::shared_ptr<Bot>
|
auto Bot::start(std::shared_ptr<Client> self) -> std::shared_ptr<Bot>
|
||||||
{
|
{
|
||||||
const auto thread = std::make_shared<Bot>(std::move(self));
|
const auto thread = std::make_shared<Bot>(std::move(self));
|
||||||
@ -79,5 +77,3 @@ auto Bot::shutdown() -> void
|
|||||||
{
|
{
|
||||||
sig_command.disconnect_all_slots();
|
sig_command.disconnect_all_slots();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "myirc/challenge.hpp"
|
#include "challenge.hpp"
|
||||||
|
|
||||||
#include "myirc/openssl_utils.hpp"
|
#include "openssl_utils.hpp"
|
||||||
|
|
||||||
#include <mybase64.hpp>
|
#include <mybase64.hpp>
|
||||||
|
|
||||||
@ -12,8 +12,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
Challenge::Challenge(Ref<EVP_PKEY> key, std::shared_ptr<Connection> connection)
|
Challenge::Challenge(Ref<EVP_PKEY> key, std::shared_ptr<Connection> connection)
|
||||||
: key_{std::move(key)}
|
: key_{std::move(key)}
|
||||||
, connection_{std::move(connection)}
|
, connection_{std::move(connection)}
|
||||||
@ -31,7 +29,7 @@ auto Challenge::on_ircmsg(IrcCommand cmd, const IrcMsg &msg) -> void {
|
|||||||
break;
|
break;
|
||||||
case IrcCommand::RPL_YOUREOPER:
|
case IrcCommand::RPL_YOUREOPER:
|
||||||
slot_.disconnect();
|
slot_.disconnect();
|
||||||
//connection_->send_ping("mitigation");
|
connection_->send_ping("mitigation");
|
||||||
break;
|
break;
|
||||||
case IrcCommand::RPL_ENDOFRSACHALLENGE2:
|
case IrcCommand::RPL_ENDOFRSACHALLENGE2:
|
||||||
finish_challenge();
|
finish_challenge();
|
||||||
@ -91,5 +89,3 @@ auto Challenge::start(std::shared_ptr<Connection> connection, const std::string_
|
|||||||
connection->send_challenge(user);
|
connection->send_challenge(user);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
#include "myirc/client.hpp"
|
#include "client.hpp"
|
||||||
|
|
||||||
#include "myirc/connection.hpp"
|
#include "connection.hpp"
|
||||||
#include "myirc/sasl_mechanism.hpp"
|
|
||||||
|
|
||||||
#include <mybase64.hpp>
|
#include <mybase64.hpp>
|
||||||
|
|
||||||
#include <boost/container/flat_map.hpp>
|
#include <boost/container/flat_map.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
auto Client::on_welcome(const IrcMsg &irc) -> void
|
auto Client::on_welcome(const IrcMsg &irc) -> void
|
||||||
@ -428,5 +425,3 @@ auto Client::on_cap(const IrcMsg &msg) -> void
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#include "myirc/connection.hpp"
|
#include "connection.hpp"
|
||||||
|
|
||||||
#include "myirc/linebuffer.hpp"
|
#include "boost/asio/steady_timer.hpp"
|
||||||
#include "myirc/snote.hpp"
|
#include "linebuffer.hpp"
|
||||||
|
|
||||||
#include <mybase64.hpp>
|
#include <mybase64.hpp>
|
||||||
|
|
||||||
#include <boost/asio/steady_timer.hpp>
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
namespace myirc {
|
namespace {
|
||||||
|
|
||||||
#include "irc_commands.inc"
|
#include "irc_commands.inc"
|
||||||
|
|
||||||
using tcp_type = boost::asio::ip::tcp::socket;
|
using tcp_type = boost::asio::ip::tcp::socket;
|
||||||
using tls_type = boost::asio::ssl::stream<tcp_type>;
|
using tls_type = boost::asio::ssl::stream<tcp_type>;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
Connection::Connection(boost::asio::io_context &io)
|
Connection::Connection(boost::asio::io_context &io)
|
||||||
@ -518,10 +518,7 @@ auto Connection::connect(
|
|||||||
// Name resolution
|
// Name resolution
|
||||||
auto resolver = boost::asio::ip::tcp::resolver{stream_.get_executor()};
|
auto resolver = boost::asio::ip::tcp::resolver{stream_.get_executor()};
|
||||||
const auto endpoints = co_await resolver.async_resolve(settings.host, std::to_string(settings.port), boost::asio::use_awaitable);
|
const auto endpoints = co_await resolver.async_resolve(settings.host, std::to_string(settings.port), boost::asio::use_awaitable);
|
||||||
for (auto e : endpoints) {
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << "DNS: " << e.endpoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect to the IRC server
|
// Connect to the IRC server
|
||||||
auto& socket = stream_.reset();
|
auto& socket = stream_.reset();
|
||||||
const auto endpoint = co_await boost::asio::async_connect(socket, endpoints, boost::asio::use_awaitable);
|
const auto endpoint = co_await boost::asio::async_connect(socket, endpoints, boost::asio::use_awaitable);
|
||||||
@ -607,5 +604,3 @@ auto Connection::start(Settings settings) -> void
|
|||||||
self->sig_disconnect.disconnect_all_slots();
|
self->sig_disconnect.disconnect_all_slots();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
struct Bot : std::enable_shared_from_this<Bot>
|
struct Bot : std::enable_shared_from_this<Bot>
|
||||||
{
|
{
|
||||||
struct Command
|
struct Command
|
||||||
@ -36,5 +34,3 @@ struct Bot : std::enable_shared_from_this<Bot>
|
|||||||
|
|
||||||
auto shutdown() -> void;
|
auto shutdown() -> void;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
template <typename> struct CCallback_;
|
template <typename> struct CCallback_;
|
||||||
template <typename F, typename R, typename... Ts>
|
template <typename F, typename R, typename... Ts>
|
||||||
struct CCallback_<R (F::*) (Ts...) const>
|
struct CCallback_<R (F::*) (Ts...) const>
|
||||||
@ -16,5 +14,3 @@ struct CCallback_<R (F::*) (Ts...) const>
|
|||||||
/// @tparam F Type of the closure
|
/// @tparam F Type of the closure
|
||||||
template <typename F>
|
template <typename F>
|
||||||
using CCallback = CCallback_<decltype(&F::operator())>;
|
using CCallback = CCallback_<decltype(&F::operator())>;
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -8,8 +8,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
/// @brief Implements the CHALLENGE command protocol to identify as an operator.
|
/// @brief Implements the CHALLENGE command protocol to identify as an operator.
|
||||||
class Challenge : std::enable_shared_from_this<Challenge>
|
class Challenge : std::enable_shared_from_this<Challenge>
|
||||||
{
|
{
|
||||||
@ -31,5 +29,3 @@ public:
|
|||||||
/// @return Handle to the challenge object.
|
/// @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>;
|
static auto start(std::shared_ptr<Connection>, std::string_view user, Ref<EVP_PKEY> key) -> std::shared_ptr<Challenge>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -1,14 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "myirc/connection.hpp"
|
#include "connection.hpp"
|
||||||
#include "myirc/sasl_mechanism.hpp"
|
#include "sasl_mechanism.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
||||||
namespace myirc {
|
struct Connection;
|
||||||
|
|
||||||
struct IrcMsg;
|
struct IrcMsg;
|
||||||
|
|
||||||
enum class Casemap
|
enum class Casemap
|
||||||
@ -102,5 +101,3 @@ public:
|
|||||||
|
|
||||||
auto shutdown() -> void;
|
auto shutdown() -> void;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -4,6 +4,7 @@
|
|||||||
#include "ircmsg.hpp"
|
#include "ircmsg.hpp"
|
||||||
#include "ratelimit.hpp"
|
#include "ratelimit.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
|
#include "snote.hpp"
|
||||||
#include "stream.hpp"
|
#include "stream.hpp"
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
@ -13,10 +14,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
struct SnoteMatch;
|
|
||||||
|
|
||||||
class Connection : public std::enable_shared_from_this<Connection>
|
class Connection : public std::enable_shared_from_this<Connection>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -139,5 +136,3 @@ auto Connection::write_irc(std::string front, std::string_view next, Args... res
|
|||||||
front += next;
|
front += next;
|
||||||
write_irc(std::move(front), rest...);
|
write_irc(std::move(front), rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -1,7 +1,3 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
enum class IrcCommand
|
enum class IrcCommand
|
||||||
{
|
{
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
@ -284,5 +280,3 @@ enum class IrcCommand
|
|||||||
TOPIC,
|
TOPIC,
|
||||||
WALLOPS,
|
WALLOPS,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "myirc/connection.hpp"
|
#include "connection.hpp"
|
||||||
#include "myirc/snote.hpp"
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <coroutine>
|
#include <coroutine>
|
||||||
@ -9,8 +8,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
struct irc_promise;
|
struct irc_promise;
|
||||||
|
|
||||||
/// A coroutine that can co_await on various IRC events
|
/// A coroutine that can co_await on various IRC events
|
||||||
@ -278,5 +275,3 @@ inline auto irc_coroutine::exception() -> std::exception_ptr
|
|||||||
{
|
{
|
||||||
return promise().exception_;
|
return promise().exception_;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -4,8 +4,6 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
struct irctag
|
struct irctag
|
||||||
{
|
{
|
||||||
std::string_view key;
|
std::string_view key;
|
||||||
@ -74,5 +72,3 @@ struct irc_parse_error : public std::exception
|
|||||||
auto parse_irc_message(char *msg) -> IrcMsg;
|
auto parse_irc_message(char *msg) -> IrcMsg;
|
||||||
|
|
||||||
auto parse_irc_tags(char *msg) -> std::vector<irctag>;
|
auto parse_irc_tags(char *msg) -> std::vector<irctag>;
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -16,8 +16,6 @@
|
|||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fixed-size buffer with line-oriented dispatch
|
* @brief Fixed-size buffer with line-oriented dispatch
|
||||||
*
|
*
|
||||||
@ -101,5 +99,3 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -4,10 +4,6 @@
|
|||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
auto log_openssl_errors(const std::string_view prefix) -> void;
|
auto log_openssl_errors(const std::string_view prefix) -> void;
|
||||||
auto key_from_file(const std::string &filename, const std::string_view password) -> Ref<EVP_PKEY>;
|
auto key_from_file(const std::string &filename, const std::string_view password) -> Ref<EVP_PKEY>;
|
||||||
auto cert_from_file(const std::string &filename) -> Ref<X509>;
|
auto cert_from_file(const std::string &filename) -> Ref<X509>;
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -3,8 +3,6 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
struct RateLimit {
|
struct RateLimit {
|
||||||
virtual ~RateLimit();
|
virtual ~RateLimit();
|
||||||
auto virtual query(size_t want_to_send) -> std::pair<std::chrono::milliseconds, size_t> = 0;
|
auto virtual query(size_t want_to_send) -> std::pair<std::chrono::milliseconds, size_t> = 0;
|
||||||
@ -20,5 +18,3 @@ struct Rfc1459RateLimit final : RateLimit
|
|||||||
|
|
||||||
auto query(size_t want_to_send) -> std::pair<std::chrono::milliseconds, size_t> override;
|
auto query(size_t want_to_send) -> std::pair<std::chrono::milliseconds, size_t> override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
// Specializations must Free to release a reference
|
// Specializations must Free to release a reference
|
||||||
// Specializations can implement UpRef to increase a reference count on copy
|
// Specializations can implement UpRef to increase a reference count on copy
|
||||||
template <typename> struct RefTraits {};
|
template <typename> struct RefTraits {};
|
||||||
@ -58,5 +56,3 @@ struct Ref : std::unique_ptr<T, RefDeleter<T>>
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -7,8 +7,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
class Registration : public std::enable_shared_from_this<Registration>
|
class Registration : public std::enable_shared_from_this<Registration>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -46,5 +44,3 @@ public:
|
|||||||
std::shared_ptr<Client>
|
std::shared_ptr<Client>
|
||||||
) -> std::shared_ptr<Registration>;
|
) -> std::shared_ptr<Registration>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -10,8 +10,6 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
class SaslMechanism
|
class SaslMechanism
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -110,5 +108,3 @@ public:
|
|||||||
return stage_ == 2;;
|
return stage_ == 2;;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -12,8 +12,6 @@
|
|||||||
struct hs_database;
|
struct hs_database;
|
||||||
struct hs_scratch;
|
struct hs_scratch;
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
enum class SnoteTag
|
enum class SnoteTag
|
||||||
{
|
{
|
||||||
ClientConnecting,
|
ClientConnecting,
|
||||||
@ -97,5 +95,3 @@ struct SnoteCore
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern SnoteCore snoteCore;
|
extern SnoteCore snoteCore;
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -6,8 +6,6 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
/// @brief Abstraction over plain-text and TLS streams.
|
/// @brief Abstraction over plain-text and TLS streams.
|
||||||
class Stream : private
|
class Stream : private
|
||||||
std::variant<
|
std::variant<
|
||||||
@ -114,5 +112,3 @@ public:
|
|||||||
socket.lowest_layer().close(err);
|
socket.lowest_layer().close(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace myirc
|
|
@ -1,8 +1,8 @@
|
|||||||
#include "myirc/ircmsg.hpp"
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
#include "ircmsg.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
@ -104,8 +104,6 @@ std::string_view unescape_tag_value(char *const val)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
auto parse_irc_tags(char *str) -> std::vector<irctag>
|
auto parse_irc_tags(char *str) -> std::vector<irctag>
|
||||||
{
|
{
|
||||||
std::vector<irctag> tags;
|
std::vector<irctag> tags;
|
||||||
@ -186,5 +184,3 @@ auto operator<<(std::ostream &out, irc_error_code code) -> std::ostream &
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "myirc/openssl_utils.hpp"
|
#include "openssl_utils.hpp"
|
||||||
|
|
||||||
#include "myirc/c_callback.hpp"
|
#include "c_callback.hpp"
|
||||||
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
auto log_openssl_errors(const std::string_view prefix) -> void
|
auto log_openssl_errors(const std::string_view prefix) -> void
|
||||||
{
|
{
|
||||||
auto err_cb = [prefix](const char *str, size_t len) -> int {
|
auto err_cb = [prefix](const char *str, size_t len) -> int {
|
||||||
@ -67,5 +65,3 @@ auto key_from_file(const std::string &filename, const std::string_view password)
|
|||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
#include "myirc/ratelimit.hpp"
|
#include "ratelimit.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
using ms = std::chrono::milliseconds;
|
using ms = std::chrono::milliseconds;
|
||||||
|
|
||||||
@ -24,5 +21,3 @@ auto Rfc1459RateLimit::query(size_t want_to_send) -> std::pair<ms, size_t>
|
|||||||
return {cost_ - gap, 1};
|
return {cost_ - gap, 1};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#include "myirc/registration.hpp"
|
#include "registration.hpp"
|
||||||
|
|
||||||
#include "myirc/connection.hpp"
|
#include "connection.hpp"
|
||||||
#include "myirc/ircmsg.hpp"
|
#include "ircmsg.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
Registration::Registration(
|
Registration::Registration(
|
||||||
Settings settings,
|
Settings settings,
|
||||||
std::shared_ptr<Client> client
|
std::shared_ptr<Client> client
|
||||||
@ -144,5 +142,3 @@ auto Registration::on_ircmsg(const IrcCommand cmd, const IrcMsg &msg) -> void
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#include "myirc/sasl_mechanism.hpp"
|
#include "sasl_mechanism.hpp"
|
||||||
|
#include "openssl_utils.hpp"
|
||||||
#include "myirc/openssl_utils.hpp"
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
auto SaslPlain::step(std::string_view msg) -> StepResult {
|
auto SaslPlain::step(std::string_view msg) -> StepResult {
|
||||||
if (complete_) {
|
if (complete_) {
|
||||||
return Failure{};
|
return Failure{};
|
||||||
@ -75,5 +72,3 @@ auto SaslEcdsa::step(std::string_view msg) -> StepResult {
|
|||||||
return Failure{};
|
return Failure{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "myirc/snote.hpp"
|
#include "snote.hpp"
|
||||||
|
|
||||||
#include "myirc/c_callback.hpp"
|
#include "c_callback.hpp"
|
||||||
|
|
||||||
#include <hs.h>
|
#include <hs.h>
|
||||||
|
|
||||||
@ -13,9 +13,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
namespace myirc {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct SnotePattern
|
struct SnotePattern
|
||||||
@ -281,5 +278,3 @@ auto SnoteCore::ScratchDeleter::operator()(hs_scratch_t *scratch) const -> void
|
|||||||
}
|
}
|
||||||
|
|
||||||
SnoteCore snoteCore;
|
SnoteCore snoteCore;
|
||||||
|
|
||||||
} // namespace myirc
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user