diff --git a/challenge.cpp b/challenge.cpp index 05501e6..88aef6d 100644 --- a/challenge.cpp +++ b/challenge.cpp @@ -29,10 +29,9 @@ auto Challenge::on_ircmsg(IrcCommand cmd, const IrcMsg &msg) -> void { break; case IrcCommand::RPL_YOUREOPER: slot_.disconnect(); - BOOST_LOG_TRIVIAL(error) << "Challenge: Already oper"; + connection_.send_ping("mitigation"); break; case IrcCommand::RPL_ENDOFRSACHALLENGE2: - slot_.disconnect(); finish_challenge(); break; } @@ -81,7 +80,7 @@ auto Challenge::finish_challenge() -> void mybase64::encode(std::string_view{(char*)digest, digestlen}, buffer_.data() + 1); connection_.send_challenge(buffer_); - connection_.send_ping("oper_up mitigation"); + buffer_.clear(); } auto Challenge::start(Connection &connection, const std::string_view user, EVP_PKEY_Ref ref) -> std::shared_ptr diff --git a/irc_coroutine.hpp b/irc_coroutine.hpp index 30b16fd..eb58dd9 100644 --- a/irc_coroutine.hpp +++ b/irc_coroutine.hpp @@ -126,7 +126,6 @@ public: template class Wait { - // State associated with each wait mode std::tuple modes_; diff --git a/main.cpp b/main.cpp index 72cf552..875a14d 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -60,6 +61,9 @@ static auto start(boost::asio::io_context &io, const Settings &settings) -> void bot->sig_command.connect([connection](const Command &cmd) { std::cout << "COMMAND " << cmd.command << " from " << cmd.account << std::endl; + if (cmd.oper == "glguy" && cmd.command == "ping") { + connection->send_notice("glguy", cmd.arguments); + } }); connection->start({ @@ -87,6 +91,7 @@ static auto get_settings(const char *filename) -> Settings auto main(int argc, char *argv[]) -> int { + boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning); if (argc != 2) { BOOST_LOG_TRIVIAL(error) << "Bad arguments"; return 1; diff --git a/snote.cpp b/snote.cpp index 14cd58a..d68caee 100644 --- a/snote.cpp +++ b/snote.cpp @@ -17,7 +17,7 @@ namespace { struct SnotePattern { - SnotePattern(SnoteTag tag, const char *expression, unsigned flags = 0) + SnotePattern(SnoteTag tag, const char *expression) : tag{tag} , expression{expression} , regex{expression, std::regex_constants::ECMAScript | std::regex_constants::optimize} @@ -29,6 +29,8 @@ struct SnotePattern std::regex regex; }; +using namespace std::literals; + const SnotePattern static patterns[] = { {SnoteTag::ClientConnecting, R"(^Client connecting: ([^ ]+) \(([^@ ]+)@([^) ]+)\) \[(.*)\] \{([^ ]*)\} <([^ ]*)> \[(.*)\]$)"}, @@ -72,23 +74,56 @@ const SnotePattern static patterns[] = { {SnoteTag::TooManyGlobalConnections, R"(^Too many global connections for ([^ ]+)\[([^ ]+)@([^ ]+)\] \[(.*)\]$)"}, + {SnoteTag::TooManyUserConnections, + R"(^Too many user connections for ([^ ]+)\[([^ ]+)@([^ ]+)\] \[(.*)\]$)"}, + {SnoteTag::SetVhostOnMarkedAccount, "^\x02([^ ]+)\x02 set vhost ([^ ]+) on the \x02MARKED\x02 account ([^ ]+).$"}, {SnoteTag::IsNowOper, R"(^([^ ]+) \(([^ ]+)!([^ ]+)@([^ ]+)\) is now an operator$)"}, - {SnoteTag::NickCollision, - R"(^Nick collision due to services forced nick change on ([^ ]+)$)"}, - {SnoteTag::OperspyWhois, R"(^OPERSPY ([^ ]+)!([^ ]+)@([^ ]+)\{([^ ]+)\} WHOIS ([^ ]+)!([^ ]+)@([^ ]+) ([^ ]+)$)"}, {SnoteTag::Freeze, - R"(^([^ ]+) froze the account ([^ ]+) \((.*)\)\.$)"}, + "^\x02([^ ]+)\x02 froze the account \x02([^ ]+)\x02 \\((.*)\\)\\.$"}, + + {SnoteTag::DroppedChannel, + "^\x02([^ ]+)\x02 dropped the channel \x02([^ ]+)\x02$"}, {SnoteTag::Spambot, - R"(User ([^ ]+) \(([^ ]+)@([^ ]+)\) trying to join ([^ ]+) is a possible spambot)"}, + R"(^User ([^ ]+) \(([^ ]+)@([^ ]+)\) trying to join ([^ ]+) is a possible spambot$)"}, + + {SnoteTag::SaveMessage, + R"(^Received SAVE message for ([^ ]+) from ([^ ]+)$)"}, + + {SnoteTag::NickCollisionServices, + R"(^Nick collision due to services forced nick change on ([^ ]+)$)"}, + + {SnoteTag::NickCollision, + R"(^Nick collision on ([^ ]+)\(([^ ]+) <- ([^ ]+)\)\(([^ ]+) <- ([^ ]+)\)\(([^ ]+)\)$)"}, + + {SnoteTag::TemporaryDline, + R"(^([^ ]+) added temporary ([^ ]+) min\. D-Line for \[([^ ]+)\] \[(.*)\]$)"}, + + {SnoteTag::FailedChallengeMissingSecure, + R"(^Failed CHALLENGE attempt - missing secure connection by ([^ ]+) \(([^ ]+)@([^ ]+)\)$)"}, + + {SnoteTag::FailedChallenge, + R"(^Failed CHALLENGE attempt by ([^ ]+) \(([^ ]+)@([^ ]+)\)$)"}, + + {SnoteTag::FailedChallengeHostMismatch, + R"(^Failed CHALLENGE attempt - host mismatch by ([^ ]+) \(([^ ]+)@([^ ]+)\)$)"}, + + {SnoteTag::FailedChallengeNoBlock, + R"(^Failed CHALLENGE attempt - user@host mismatch or no operator block for ([^ ]+) by ([^ ]+) \(([^ ]+)@([^ ]+)\)$)"}, + + {SnoteTag::FailedChallengeTls, + R"(^Failed CHALLENGE attempt - missing SSL/TLS by ([^ ]+) \(([^ ]+)@([^ ]+)\)$)"}, + + {SnoteTag::FailedChallengeFingerprintMismatch, + R"(^Failed CHALLENGE attempt - client certificate fingerprint mismatch by ([^ ]+) \(([^ ]+)@([^ ]+)\)$)"} }; static auto setup_database() -> hs_database_t * diff --git a/snote.hpp b/snote.hpp index c12abab..81cff91 100644 --- a/snote.hpp +++ b/snote.hpp @@ -28,12 +28,23 @@ enum class SnoteTag PossibleFlooder, Killed, TooManyGlobalConnections, + TooManyUserConnections, SetVhostOnMarkedAccount, IsNowOper, NickCollision, OperspyWhois, Freeze, Spambot, + FailedChallenge, + FailedChallengeHostMismatch, + FailedChallengeNoBlock, + FailedChallengeTls, + FailedChallengeFingerprintMismatch, + FailedChallengeMissingSecure, + SaveMessage, + NickCollisionServices, + DroppedChannel, + TemporaryDline }; class SnoteMatch