m_cap: add support for CAP LS 302
This commit is contained in:
parent
da3e5fcb42
commit
ddf62b10f9
2 changed files with 21 additions and 2 deletions
|
@ -406,6 +406,7 @@ struct ListClient
|
||||||
#define FLAGS_TGCHANGE 0x400000 /* we're allowed to clear something */
|
#define FLAGS_TGCHANGE 0x400000 /* we're allowed to clear something */
|
||||||
#define FLAGS_DYNSPOOF 0x800000 /* dynamic spoof, only opers see ip */
|
#define FLAGS_DYNSPOOF 0x800000 /* dynamic spoof, only opers see ip */
|
||||||
#define FLAGS_TGEXCESSIVE 0x1000000 /* whether the client has attemped to change targets excessively fast */
|
#define FLAGS_TGEXCESSIVE 0x1000000 /* whether the client has attemped to change targets excessively fast */
|
||||||
|
#define FLAGS_CLICAP_DATA 0x2000000 /* requested CAP LS 302 */
|
||||||
|
|
||||||
/* flags for local clients, this needs stuff moved from above to here at some point */
|
/* flags for local clients, this needs stuff moved from above to here at some point */
|
||||||
#define LFLAGS_SSL 0x00000001
|
#define LFLAGS_SSL 0x00000001
|
||||||
|
|
|
@ -171,6 +171,10 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea
|
||||||
|
|
||||||
DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict)
|
DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict)
|
||||||
{
|
{
|
||||||
|
size_t caplen = 0;
|
||||||
|
struct ClientCapability *clicap = entry->ownerdata;
|
||||||
|
const char *data = NULL;
|
||||||
|
|
||||||
if(flags)
|
if(flags)
|
||||||
{
|
{
|
||||||
if(!IsCapableEntry(source_p, entry))
|
if(!IsCapableEntry(source_p, entry))
|
||||||
|
@ -183,8 +187,15 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea
|
||||||
if (!clicap_visible(entry))
|
if (!clicap_visible(entry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
caplen = strlen(entry->cap);
|
||||||
|
if (!flags && (source_p->flags & FLAGS_CLICAP_DATA) && clicap != NULL && clicap->data != NULL)
|
||||||
|
data = clicap->data();
|
||||||
|
|
||||||
|
if (data != NULL)
|
||||||
|
caplen += strlen(data) + 1;
|
||||||
|
|
||||||
/* \r\n\0, possible "-~=", space, " *" */
|
/* \r\n\0, possible "-~=", space, " *" */
|
||||||
if(buflen + strlen(entry->cap) >= BUFSIZE - 10)
|
if(buflen + caplen >= BUFSIZE - 10)
|
||||||
{
|
{
|
||||||
/* remove our trailing space -- if buflen == mlen
|
/* remove our trailing space -- if buflen == mlen
|
||||||
* here, we didnt even succeed in adding one.
|
* here, we didnt even succeed in adding one.
|
||||||
|
@ -205,7 +216,11 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags, int clea
|
||||||
buflen++;
|
buflen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
curlen = sprintf(p, "%s ", entry->cap);
|
if (data == NULL)
|
||||||
|
curlen = sprintf(p, "%s ", entry->cap);
|
||||||
|
else
|
||||||
|
curlen = sprintf(p, "%s=%s ", entry->cap, data);
|
||||||
|
|
||||||
p += curlen;
|
p += curlen;
|
||||||
buflen += curlen;
|
buflen += curlen;
|
||||||
}
|
}
|
||||||
|
@ -289,6 +304,9 @@ cap_ls(struct Client *source_p, const char *arg)
|
||||||
if(!IsRegistered(source_p))
|
if(!IsRegistered(source_p))
|
||||||
source_p->flags |= FLAGS_CLICAP;
|
source_p->flags |= FLAGS_CLICAP;
|
||||||
|
|
||||||
|
if (arg != NULL && !strcmp(arg, "302"))
|
||||||
|
source_p->flags |= FLAGS_CLICAP_DATA;
|
||||||
|
|
||||||
/* list of what we support */
|
/* list of what we support */
|
||||||
clicap_generate(source_p, "LS", 0, 0);
|
clicap_generate(source_p, "LS", 0, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue