Allow for capabilities to be marked as "required".

If capability negotiation fails on these capabilities, then the server link is dropped.
This commit is contained in:
William Pitcock 2009-04-20 09:36:55 -05:00
parent 5f8d323c59
commit c6240d7940
2 changed files with 19 additions and 1 deletions

View file

@ -51,6 +51,7 @@ struct Capability
{
const char *name; /* name of capability */
unsigned int cap; /* mask value */
unsigned int required; /* 1 if required, 0 if not */
};
#define CAP_CAP 0x00001 /* received a CAP to begin with */

View file

@ -1,6 +1,6 @@
/*
* ircd-ratbox: A slightly useful ircd.
* m_away.c: Negotiates capabilities with a remote server.
* m_capab.c: Negotiates capabilities with a remote server.
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
@ -96,6 +96,23 @@ mr_capab(struct Client *client_p, struct Client *source_p, int parc, const char
}
}
/* check to ensure any "required" caps are set. --nenolod */
for (cap = captab; cap->name; cap++)
{
if (!cap->required)
continue;
if (!(client_p->localClient->caps & cap->cap))
{
char exitbuf[BUFSIZE];
rb_snprintf(exitbuf, BUFSIZE, "Missing required CAPAB [%s]", cap->cap);
exit_client(client_p, client_p, client_p, exitbuf);
return 0;
}
}
return 0;
}