Module: ngircd.git Branch: master Commit: fc82efc3e8931e1670972e594140e03671370c1f URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=fc82e...
Author: Alexander Barton alex@barton.de Date: Sun Dec 25 14:50:19 2011 +0100
Implement IRC "STATS g" and "STATS k" command
---
src/ngircd/irc-info.c | 26 ++++++++++++++++++++++++++ src/ngircd/messages.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 301da53..736412f 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -28,8 +28,10 @@ #include "conn-func.h" #include "conn-zip.h" #include "channel.h" +#include "class.h" #include "conf.h" #include "defines.h" +#include "lists.h" #include "log.h" #include "messages.h" #include "match.h" @@ -478,6 +480,8 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) COMMAND *cmd; time_t time_now; unsigned int days, hrs, mins; + struct list_head list; + struct list_elem *list_item;
assert(Client != NULL); assert(Req != NULL); @@ -516,6 +520,28 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) query = '*';
switch (query) { + case 'g': /* Network-wide bans ("G-Lines") */ + case 'G': + case 'k': /* Server-local bans ("K-Lines") */ + case 'K': + if (!Client_HasMode(from, 'o')) + return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG, + Client_ID(from)); + if (query == 'g' || query == 'G') + list = Class_GetList(CLASS_GLINE); + else + list = Class_GetList(CLASS_KLINE); + list_item = Lists_GetFirst(&list); + while (list_item) { + if (!IRC_WriteStrClient(from, RPL_STATSXLINE_MSG, + Client_ID(from), query, + Lists_GetMask(list_item), + Lists_GetValidity(list_item), + Lists_GetReason(list_item))) + return DISCONNECTED; + list_item = Lists_GetNext(list_item); + } + break; case 'l': /* Link status (servers and own link) */ case 'L': time_now = time(NULL); diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index 78ac068..7bf7367 100644 --- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -29,6 +29,7 @@ #define RPL_TRACESERVER_MSG "206 %s Serv 1 0S 0C %s[%s@%s] *!*@%s :V%s" #define RPL_STATSLINKINFO_MSG "211 %s %s %d %ld %ld %ld %ld :%ld" #define RPL_STATSCOMMANDS_MSG "212 %s %s %ld %ld %ld" +#define RPL_STATSXLINE_MSG "216 %s %c %s %ld :%s" #define RPL_ENDOFSTATS_MSG "219 %s %c :End of STATS report" #define RPL_UMODEIS_MSG "221 %s +%s" #define RPL_SERVLIST_MSG "234 %s %s %s %s %d %d :%s"