summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2020-08-12 09:40:36 +0200
committerlouiz’ <louiz@louiz.org>2020-08-12 09:40:36 +0200
commit063e6b127ecf92ca5bf8c4ecb137b60e3e7aa216 (patch)
tree7e9898c0f100d87c3480016b3ec5400828469116 /src
parent4d6fdb0795b0d7e306988c6ff32f51545c2fd7f4 (diff)
downloadbiboumi-9.0-rc1.tar.gz
biboumi-9.0-rc1.tar.bz2
biboumi-9.0-rc1.tar.xz
biboumi-9.0-rc1.zip
Handle SASL failures by displaying a message and aborting the connection9.0-rc1
Diffstat (limited to 'src')
-rw-r--r--src/irc/irc_client.cpp25
-rw-r--r--src/irc/irc_client.hpp3
2 files changed, 26 insertions, 2 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 351f9f8..3ae5ac6 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -85,8 +85,14 @@ static const std::unordered_map<std::string,
{"CAP", {&IrcClient::on_cap, {3, 0}}},
#ifdef WITH_SASL
{"AUTHENTICATE", {&IrcClient::on_authenticate, {1, 0}}},
- {"903", {&IrcClient::on_sasl_success, {0, 0}}},
{"900", {&IrcClient::on_sasl_login, {3, 0}}},
+ {"902", {&IrcClient::on_sasl_failure, {2, 0}}},
+ {"903", {&IrcClient::on_sasl_success, {0, 0}}},
+ {"904", {&IrcClient::on_sasl_failure, {2, 0}}},
+ {"905", {&IrcClient::on_sasl_failure, {2, 0}}},
+ {"906", {&IrcClient::on_sasl_failure, {2, 0}}},
+ {"907", {&IrcClient::on_sasl_failure, {2, 0}}},
+ {"908", {&IrcClient::on_sasl_failure, {2, 0}}},
#endif
{"401", {&IrcClient::on_generic_error, {2, 0}}},
{"402", {&IrcClient::on_generic_error, {2, 0}}},
@@ -238,6 +244,7 @@ void IrcClient::on_connection_failed(const std::string& reason)
"cancel", "item-not-found",
"", reason);
}
+ this->channels_to_join.clear();
}
else // try the next port
this->start();
@@ -1372,6 +1379,22 @@ void IrcClient::on_sasl_success(const IrcMessage &)
this->cap_end();
}
+void IrcClient::on_sasl_failure(const IrcMessage& message)
+{
+ this->sasl_state = SaslState::failure;
+ const auto reason = message.arguments[1];
+ // Send an error message for all room that the user wanted to join
+ for (const auto& tuple: this->channels_to_join)
+ {
+ Iid iid(std::get<0>(tuple) + "%" + this->hostname, this->chantypes);
+ this->bridge.send_presence_error(iid, this->current_nick,
+ "cancel", "item-not-found",
+ "", reason);
+ }
+ this->channels_to_join.clear();
+ this->send_quit_command(reason);
+}
+
void IrcClient::on_sasl_login(const IrcMessage &message)
{
const auto& login = message.arguments[2];
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 9f77e29..ac2f6a9 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -247,8 +247,9 @@ private:
public:
#ifdef WITH_SASL
void on_authenticate(const IrcMessage& message);
- void on_sasl_success(const IrcMessage& message);
void on_sasl_login(const IrcMessage& message);
+ void on_sasl_success(const IrcMessage& message);
+ void on_sasl_failure(const IrcMessage& message);
#endif
/**
* The channel has been completely joined (self presence, topic, all names