+ if (Req->argc > 0)
+ query = Req->argv[0][0] ? Req->argv[0][0] : '*';
+ else
+ 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);
+ for (con = Conn_First(); con != NONE; con = Conn_Next(con)) {
+ cl = Conn_GetClient(con);
+ if (!cl)
+ continue;
+ if ((Client_Type(cl) == CLIENT_SERVER)
+ || (cl == Client)) {
+ /* Server link or our own connection */
+#ifdef ZLIB
+ if (Conn_Options(con) & CONN_ZIP) {
+ if (!IRC_WriteStrClient
+ (from, RPL_STATSLINKINFOZIP_MSG,
+ Client_ID(from), Client_Mask(cl),
+ Conn_SendQ(con), Conn_SendMsg(con),
+ Zip_SendBytes(con),
+ Conn_SendBytes(con),
+ Conn_RecvMsg(con),
+ Zip_RecvBytes(con),
+ Conn_RecvBytes(con),
+ (long)(time_now - Conn_StartTime(con))))
+ return DISCONNECTED;
+ continue;
+ }
+#endif
+ if (!IRC_WriteStrClient
+ (from, RPL_STATSLINKINFO_MSG,
+ Client_ID(from), Client_Mask(cl),
+ Conn_SendQ(con), Conn_SendMsg(con),
+ Conn_SendBytes(con), Conn_RecvMsg(con),
+ Conn_RecvBytes(con),
+ (long)(time_now - Conn_StartTime(con))))
+ return DISCONNECTED;
+ }
+ }
+ break;
+ case 'm': /* IRC command status (usage count) */
+ case 'M':
+ cmd = Parse_GetCommandStruct();
+ for (; cmd->name; cmd++) {
+ if (cmd->lcount == 0 && cmd->rcount == 0)
+ continue;
+ if (!IRC_WriteStrClient
+ (from, RPL_STATSCOMMANDS_MSG, Client_ID(from),
+ cmd->name, cmd->lcount, cmd->bytes, cmd->rcount))
+ return DISCONNECTED;
+ }
+ break;
+ case 'u': /* Server uptime */
+ case 'U':
+ time_now = time(NULL) - NGIRCd_Start;
+ days = uptime_days(&time_now);
+ hrs = uptime_hrs(&time_now);
+ mins = uptime_mins(&time_now);
+ if (!IRC_WriteStrClient(from, RPL_STATSUPTIME, Client_ID(from),
+ days, hrs, mins, (unsigned int)time_now))
+ return DISCONNECTED;
+ break;
+ }