summary refs log tree commit diff
path: root/state.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-27 23:33:55 -0400
committerJune McEnroe <june@causal.agency>2019-10-27 23:33:55 -0400
commitffac333812563763aa1605181120938c4a914cfe (patch)
tree402d0ac958faae8b3945b6e55202a8b495d9055d /state.c
parentOnly increment consumer after successful send (diff)
downloadpounce-ffac333812563763aa1605181120938c4a914cfe.tar.gz
pounce-ffac333812563763aa1605181120938c4a914cfe.zip
Wait for SASL success before sending CAP END
Also refuse to continue logging in if SASL authentication fails.

I should really just move all of log in and authentication from server.c
to state.c...
Diffstat (limited to 'state.c')
-rw-r--r--state.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/state.c b/state.c
index 01829a4..c63a6b2 100644
--- a/state.c
+++ b/state.c
@@ -130,6 +130,16 @@ static void handleAuthenticate(struct Message *msg) {
 	serverAuth();
 }
 
+static void handleReplyLoggedIn(struct Message *msg) {
+	(void)msg;
+	serverFormat("CAP END\r\n");
+}
+
+static void handleErrorSASLFail(struct Message *msg) {
+	if (!msg->params[1]) errx(EX_PROTOCOL, "RPL_SASLFAIL without message");
+	errx(EX_CONFIG, "%s", msg->params[1]);
+}
+
 static void handleReplyWelcome(struct Message *msg) {
 	if (!msg->params[1]) errx(EX_PROTOCOL, "RPL_WELCOME without message");
 	set(&intro.origin, msg->origin);
@@ -233,6 +243,10 @@ static const struct {
 	{ "005", handleReplyISupport },
 	{ "332", handleReplyTopic },
 	{ "433", handleErrorNicknameInUse },
+	{ "900", handleReplyLoggedIn },
+	{ "904", handleErrorSASLFail },
+	{ "905", handleErrorSASLFail },
+	{ "906", handleErrorSASLFail },
 	{ "AUTHENTICATE", handleAuthenticate },
 	{ "CAP", handleCap },
 	{ "ERROR", handleError },