diff options
author | June McEnroe <june@causal.agency> | 2019-11-09 20:17:43 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-11-09 20:17:43 -0500 |
commit | d4ff0457718b573d2c9d20000c63014666bf5791 (patch) | |
tree | 0d7ffe78cdd734dbce769629ecf18b689a669b21 /state.c | |
parent | Parse capabilities (diff) | |
download | pounce-d4ff0457718b573d2c9d20000c63014666bf5791.tar.gz pounce-d4ff0457718b573d2c9d20000c63014666bf5791.zip |
Maintain stateCaps and offer them to clients
Diffstat (limited to '')
-rw-r--r-- | state.c | 16 |
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) { |