summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--state.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/state.c b/state.c
index e17d9e6..b786adb 100644
--- a/state.c
+++ b/state.c
@@ -43,6 +43,7 @@ void stateLogin(
 	const char *pass, bool sasl, const char *plain,
 	const char *nick, const char *user, const char *real
 ) {
+	serverFormat("CAP LS\r\n");
 	if (pass) serverFormat("PASS :%s\r\n", pass);
 	if (sasl) {
 		serverFormat("CAP REQ :%s\r\n", capList(CapSASL));
@@ -59,19 +60,25 @@ void stateLogin(
 	}
 	serverFormat("NICK %s\r\n", nick);
 	serverFormat("USER %s 0 * :%s\r\n", user, real);
-	serverFormat("CAP LS\r\n");
 }
 
 static void handleCap(struct Message *msg) {
 	require(msg, false, 3);
 	enum Cap caps = capParse(msg->params[2]);
-	if (!strcmp(msg->params[1], "ACK")) {
+
+	if (!strcmp(msg->params[1], "LS")) {
+		caps &= ~(CapSASL | CapServerTime | CapUnsupported);
+		serverFormat("CAP REQ :%s\r\n", capList(caps));
+
+	} else if (!strcmp(msg->params[1], "ACK")) {
 		stateCaps |= caps;
 		if (caps & CapSASL) {
 			serverFormat(
 				"AUTHENTICATE %s\r\n", (plainBase64 ? "PLAIN" : "EXTERNAL")
 			);
 		}
+		if (!(stateCaps & CapSASL)) serverFormat("CAP END\r\n");
+
 	} else if (!strcmp(msg->params[1], "NAK")) {
 		errx(EX_CONFIG, "server does not support %s", msg->params[2]);
 	}
n>Call static_assert by _Static_assertJune McEnroe OpenBSD doesn't #define static_assert in assert.h and _Static_assert is its real name I guess so why not? 2020-06-07Add OpenBSD to install.shJune McEnroe Straightforward. 2020-06-03Add The Song of AchillesJune McEnroe 2020-06-01Allow redirecting input in everJune McEnroe 2020-05-31Add %c conversion to c scriptJune McEnroe 2020-05-31Add c script to READMEJune McEnroe 2020-05-31Add c scriptJune McEnroe 2020-05-31Update mdoc source URLsJune McEnroe 2020-05-26Remove unfinished PSF fontsJune McEnroe