From 189015afb4632bd1dc78c1bd87bed1ca4cc48b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 29 Jul 2020 00:37:24 +0200 Subject: Conditionally compile the SASL code only with botan and database --- src/irc/irc_client.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/irc/irc_client.cpp') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 183a9d8..351f9f8 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -83,11 +83,11 @@ static const std::unordered_mapbridge.get_bare_jid(), this->get_hostname()); - const auto& sasl_password = options.col(); const auto& server_password = options.col(); if (!server_password.empty()) this->send_pass_command(options.col()); +#endif +#ifdef WITH_SASL + const auto& sasl_password = options.col(); if (!sasl_password.empty()) { this->capabilities["sasl"] = { @@ -325,10 +327,8 @@ void IrcClient::on_connected() this->send_user_command(username, realname); } else - this->send_user_command(this->username, this->realname); -#else - this->send_user_command(this->username, this->realname); #endif + this->send_user_command(this->username, this->realname); } void IrcClient::on_connection_close(const std::string& error_msg) @@ -1346,9 +1346,11 @@ void IrcClient::on_cap(const IrcMessage &message) else if (sub_command == "NACK") capability.on_nack(); this->capabilities.erase(it); - this->cap_end(); + if (this->capabilities.empty()) + this->cap_end(); } +#ifdef WITH_SASL void IrcClient::on_authenticate(const IrcMessage &) { if (this->sasl_state == SaslState::unneeded) @@ -1356,13 +1358,12 @@ void IrcClient::on_authenticate(const IrcMessage &) log_warning("Received an AUTHENTICATE command but we don’t intend to authenticate…"); return; } -#ifdef USE_DATABASE + auto options = Database::get_irc_server_options(this->bridge.get_bare_jid(), this->get_hostname()); const auto auth_string = '\0' + options.col() + '\0' + options.col(); const auto base64_auth_string = base64::encode(auth_string); this->send_message({"AUTHENTICATE", {base64_auth_string}}); -#endif } void IrcClient::on_sasl_success(const IrcMessage &) @@ -1379,15 +1380,15 @@ void IrcClient::on_sasl_login(const IrcMessage &message) text = message.arguments[3]; this->bridge.send_xmpp_message(this->hostname, message.prefix, text); } +#endif void IrcClient::cap_end() { - if (!this->capabilities.empty()) - return; +#ifdef WITH_SASL // If we are currently authenticating through sasl, finish that before sending CAP END if (this->sasl_state == SaslState::needed) return; - +#endif this->send_message({"CAP", {"END"}}); this->bridge.on_irc_client_connected(this->get_hostname()); } -- cgit v1.2.3