From fde16193c48a4909a6031b9169e11f24aa923d27 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 20 Apr 2009 09:36:55 -0500 Subject: [PATCH] Allow for capabilities to be marked as "required". If capability negotiation fails on these capabilities, then the server link is dropped. --- include/s_serv.h | 1 + modules/m_capab.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/s_serv.h b/include/s_serv.h index 1d4296c..c52c78d 100644 --- a/include/s_serv.h +++ b/include/s_serv.h @@ -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 */ diff --git a/modules/m_capab.c b/modules/m_capab.c index 3e7de45..650d8ab 100644 --- a/modules/m_capab.c +++ b/modules/m_capab.c @@ -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; }