Handle CAP requests from clients, reply with no capabilities
This commit is contained in:
parent
7ab58b5b72
commit
e382d31b67
27
src/irc.c
27
src/irc.c
@ -1030,6 +1030,31 @@ static int irc_cli_pass(bip_t *bip, struct link_client *ic, struct line *line)
|
||||
return OK_FORGET;
|
||||
}
|
||||
|
||||
static int irc_cli_cap(bip_t *bip, struct link_client *ic, struct line *line)
|
||||
{
|
||||
if (irc_line_count(line) < 2)
|
||||
return ERR_PROTOCOL;
|
||||
|
||||
/* When we decide to enable actual capabilities, we'll have to handle CAP
|
||||
* version, add a flag cap_started or similar, and handle CAP END.
|
||||
*/
|
||||
if (irc_line_elem_equals(line, 1, "LS")) {
|
||||
WRITE_LINE2(CONN(ic), NULL, "CAP", "*", "LS");
|
||||
} else if (irc_line_elem_equals(line, 1, "LIST")) {
|
||||
WRITE_LINE3(CONN(ic), NULL, "CAP", "*", "LIST", "");
|
||||
} else if (irc_line_elem_equals(line, 1, "REQ")) {
|
||||
char *caps = irc_line_to_string_skip(line, 2);
|
||||
if (caps) {
|
||||
caps++;
|
||||
WRITE_LINE3(CONN(ic), NULL, "CAP", "*", "NAK", caps);
|
||||
}
|
||||
}
|
||||
|
||||
if ((ic->state & IRCC_READY) == IRCC_READY)
|
||||
return irc_cli_startup(bip, ic, line);
|
||||
return OK_FORGET;
|
||||
}
|
||||
|
||||
static int irc_cli_quit(struct link_client *ic, struct line *line)
|
||||
{
|
||||
(void)ic;
|
||||
@ -1408,6 +1433,8 @@ static int irc_dispatch_logging_client(bip_t *bip, struct link_client *ic,
|
||||
return irc_cli_user(bip, ic, line);
|
||||
} else if (irc_line_elem_equals(line, 0, "PASS")) {
|
||||
return irc_cli_pass(bip, ic, line);
|
||||
} else if (irc_line_elem_equals(line, 0, "CAP")) {
|
||||
return irc_cli_cap(bip, ic, line);
|
||||
}
|
||||
return OK_FORGET;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user