Skip to content

Commit b43ce38

Browse files
authored
add SASL EXTERNAL support
1 parent ed5c381 commit b43ce38

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

kirc.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
static int conn; /* connection socket */
2020
static char chan_default[MSG_MAX]; /* default channel for PRIVMSG */
2121
static int verb = 0; /* verbose output (e.g. raw stream) */
22+
static int sasl = 0; /* SASL method (PLAIN=0, EXTERNAL=1) */
2223
static size_t cmax = 80; /* max number of chars per line */
2324
static size_t gutl = 20; /* max char width of left column */
2425
static char * host = "irc.freenode.org"; /* irc host address */
@@ -144,11 +145,6 @@ raw_parser(char *string) {
144145
return;
145146
}
146147

147-
if (!strncmp(string, "AUTHENTICATE +", 14)) {
148-
raw("AUTHENTICATE %s\r\n", auth);
149-
return;
150-
}
151-
152148
if (string[0] != ':') return;
153149

154150
if (olog) log_append(string, olog);
@@ -164,8 +160,6 @@ raw_parser(char *string) {
164160
strcpy(chan_default, tok);
165161
raw("JOIN #%s\r\n", tok);
166162
} return;
167-
} else if (!strncmp(command, "90", 2)) {
168-
raw("CAP END\r\n");
169163
} else if (!strncmp(command, "QUIT", 4) || !strncmp(command, "PART", 4)) {
170164
printf("%*s<-- \x1b[34;1m%s\x1b[0m\n", g - 3, "", nickname);
171165
return;
@@ -275,7 +269,7 @@ static void
275269
usage(void) {
276270
fputs("kirc [-s hostname] [-p port] [-c channel] [-n nick] \
277271
[-r real_name] [-u username] [-k password] [-a token] [-x init_command] \
278-
[-w columns] [-W columns] [-o path] [-h|v|V]\n", stderr);
272+
[-w columns] [-W columns] [-o path] [-e|v|V]\n", stderr);
279273
exit(EXIT_FAILURE);
280274
}
281275

@@ -284,9 +278,10 @@ main(int argc, char **argv) {
284278

285279
int cval;
286280

287-
while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:W:a:hvV")) != -1) {
281+
while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:W:a:hevV")) != -1) {
288282
switch (cval) {
289-
case 'V' : verb = 1; break;
283+
case 'V' : ++verb; break;
284+
case 'e' : ++sasl; break;
290285
case 's' : host = optarg; break;
291286
case 'p' : port = optarg; break;
292287
case 'r' : real = optarg; break;
@@ -313,10 +308,12 @@ main(int argc, char **argv) {
313308
return EXIT_FAILURE;
314309
}
315310

316-
if (auth) raw("CAP REQ :sasl\r\n");
311+
if (auth || sasl) raw("CAP REQ :sasl\r\n");
317312
raw("NICK %s\r\n", nick);
318313
raw("USER %s - - :%s\r\n", (user ? user : nick), (real ? real : nick));
319-
if (auth) raw("AUTHENTICATE PLAIN\r\n");
314+
if (auth || sasl) raw("AUTHENTICATE %s\r\n", (sasl ? "EXTERNAL" : "PLAIN"));
315+
if (auth || sasl) raw("AUTHENTICATE %s\r\n", (sasl ? "+" : auth));
316+
if (auth || sasl) raw("CAP END\r\n");
320317
if (pass) raw("PASS %s\r\n", pass);
321318
if (inic) raw("%s\r\n", inic);
322319

0 commit comments

Comments
 (0)