summary refs log tree commit diff
path: root/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'state.c')
-rw-r--r--state.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/state.c b/state.c
index da5c96f..e17d9e6 100644
--- a/state.c
+++ b/state.c
@@ -45,7 +45,7 @@ void stateLogin(
 ) {
 	if (pass) serverFormat("PASS :%s\r\n", pass);
 	if (sasl) {
-		serverFormat("CAP REQ :sasl\r\n");
+		serverFormat("CAP REQ :%s\r\n", capList(CapSASL));
 		if (plain) {
 			byte buf[1 + strlen(plain)];
 			buf[0] = 0;
@@ -59,14 +59,22 @@ 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);
-	if (strcmp(msg->params[1], "ACK") || strncmp(msg->params[2], "sasl", 4)) {
-		errx(EX_CONFIG, "server does not support SASL");
+	enum Cap caps = capParse(msg->params[2]);
+	if (!strcmp(msg->params[1], "ACK")) {
+		stateCaps |= caps;
+		if (caps & CapSASL) {
+			serverFormat(
+				"AUTHENTICATE %s\r\n", (plainBase64 ? "PLAIN" : "EXTERNAL")
+			);
+		}
+	} else if (!strcmp(msg->params[1], "NAK")) {
+		errx(EX_CONFIG, "server does not support %s", msg->params[2]);
 	}
-	serverFormat("AUTHENTICATE %s\r\n", (plainBase64 ? "PLAIN" : "EXTERNAL"));
 }
 
 static void handleAuthenticate(struct Message *msg) {
c?id=97778aa8d14644dabe08df95fba51d2544540a3d&follow=1'>Process htagml file line by lineJune McEnroe 2021-01-12Split fields by tab onlyJune McEnroe 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe 2021-01-09Add c -t flag to print expression typeJune McEnroe 2021-01-05Update taglineJune McEnroe