Add an option to stop the connection when SASL fails.

This commit is contained in:
LemonBoy 2016-07-12 13:59:46 +02:00
commit 91c9e871c7
3 changed files with 25 additions and 0 deletions

View file

@ -23,6 +23,9 @@
#include "signals.h"
#include "levels.h"
#include "irc-servers.h"
#include "settings.h"
#include "printtext.h"
static void sig_sasl_success(IRC_SERVER_REC *server)
@ -35,14 +38,28 @@ static void sig_sasl_failure(IRC_SERVER_REC *server, const char *reason)
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_SASL_ERROR, reason);
}
static void sig_cap_end(IRC_SERVER_REC *server)
{
/* The negotiation has now been terminated, if we didn't manage to
* authenticate successfully with the server just disconnect. */
if (server->sasl_success == FALSE &&
settings_get_bool("sasl_disconnect_on_failure"))
server_disconnect(SERVER(server));
}
void fe_sasl_init(void)
{
settings_add_bool("server", "sasl_disconnect_on_failure", TRUE);
signal_add("server sasl success", (SIGNAL_FUNC) sig_sasl_success);
signal_add("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure);
signal_add_first("server cap end", (SIGNAL_FUNC) sig_cap_end);
}
void fe_sasl_deinit(void)
{
signal_remove("server sasl success", (SIGNAL_FUNC) sig_sasl_success);
signal_remove("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure);
signal_remove("server cap end", (SIGNAL_FUNC) sig_cap_end);
}