s_misc.c \
s_numeric.c \
s_serv.c \
+ s_stats.c \
s_user.c \
send.c \
sprintf_irc.c \
../include/numnicks.h ../include/opercmds.h ../include/s_bsd.h \
../include/s_conf.h ../include/s_debug.h ../include/s_misc.h \
../include/s_serv.h ../include/s_user.h ../include/send.h \
- ../include/userload.h
+ ../include/userload.h ../include/s_stats.h
m_time.o: m_time.c ../include/client.h ../include/dbuf.h \
../include/ircd_defs.h ../include/ircd_handler.h ../include/ircd.h \
../config/config.h ../config/setup.h ../include/struct.h \
#include "client.h"
#include "ircd.h"
#include "ircd_alloc.h"
+#include "ircd_reply.h"
#include "ircd_string.h"
#include "match.h"
#include "numeric.h"
#include "s_misc.h"
#include "send.h"
#include "struct.h"
+#include "support.h"
+#include "msg.h"
+#include "numnicks.h"
+#include "numeric.h"
#include "sys.h" /* FALSE bleah */
#include <assert.h>
+#include <string.h>
struct Gline* GlobalGlineList = 0;
struct Gline* BadChanGlineList = 0;
make_gline(char *userhost, char *reason, time_t expire, time_t lastmod,
unsigned int flags)
{
- struct Gline *agline;
+ struct Gline *gline;
char *user, *host;
- agline = (struct Gline *)MyMalloc(sizeof(struct Gline)); /* alloc memory */
- assert(0 != agline);
+ gline = (struct Gline *)MyMalloc(sizeof(struct Gline)); /* alloc memory */
+ assert(0 != gline);
gline->gl_expire = expire; /* initialize gline... */
gline->gl_lastmod = lastmod;
gline->gl_next = BadChanGlineList; /* then link it into list */
gline->gl_prev_p = &BadChanGlineList;
if (BadChanGlineList)
- BadChanGlineList->gl_prev_p = &agline->gl_next;
- BadChanGlineList = agline;
+ BadChanGlineList->gl_prev_p = &gline->gl_next;
+ BadChanGlineList = gline;
} else {
canon_userhost(userhost, &user, &host, "*"); /* find user and host */
gline->gl_next = GlobalGlineList; /* then link it into list */
gline->gl_prev_p = &GlobalGlineList;
if (GlobalGlineList)
- GlobalGlineList->gl_prev_p = &agline->gl_next;
- GlobalGlineList = agline;
+ GlobalGlineList->gl_prev_p = &gline->gl_next;
+ GlobalGlineList = gline;
}
- return agline;
+ return gline;
}
static int
if (!acptr->user)
continue;
- if ((GlineIsIpMask(gline) ? match(gline->host, acptr->sock_ip) :
- match(gline->host, acptr->sockhost)) == 0 &&
+ if ((GlineIsIpMask(gline) ? match(gline->gl_host, acptr->sock_ip) :
+ match(gline->gl_host, acptr->sockhost)) == 0 &&
(!acptr->user->username ||
- match(gline->name, acptr->user->username) == 0)) {
+ match(gline->gl_user, acptr->user->username) == 0)) {
/* ok, here's one that got G-lined */
sendto_one(acptr, ":%s %d %s :*** %s.", me.name, ERR_YOUREBANNEDCREEP,
- acptr->name, gline->reason);
+ acptr->name, gline->gl_reason);
/* let the ops know about it */
sendto_op_mask(SNO_GLINE, "G-line active for %s",
/* and get rid of him */
if ((tval = exit_client_msg(cptr, acptr, &me, "G-lined (%s)",
- gline->reason)))
+ gline->gl_reason)))
retval = tval; /* retain killed status */
}
}
if (gline->gl_expire <= TStime())
gline_free(gline);
- else if (match(gline->host, host) == 0 &&
- ((!user && ircd_strcmp(gline->user, "*") == 0) ||
- match(gline->user, user) == 0))
+ else if (match(gline->gl_host, host) == 0 &&
+ ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
+ match(gline->gl_user, user) == 0))
break;
}
}
/* send gline information along */
- sendto_one(sptr, rpl_str(GLIST), me.name, sptr->name, gline->gl_user,
+ sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host, gline->gl_expire,
GlineIsLocal(gline) ? me.name : "*",
if (gline->gl_expire <= TStime())
gline_free(gline);
else
- sendto_one(sptr, rpl_str(GLIST), me.name, sptr->name, gline->gl_user,
+ sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
"@", gline->gl_host, gline->gl_expire,
GlineIsLocal(gline) ? me.name : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
if (gline->gl_expire <= TStime())
gline_free(gline);
else
- sendto_one(sptr, rpl_str(GLIST), me.name, sptr->name, gline->gl_user,
+ sendto_one(sptr, rpl_str(RPL_GLIST), me.name, sptr->name, gline->gl_user,
"", "", gline->gl_expire,
GlineIsLocal(gline) ? me.name : "*",
GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
}
/* end of gline information */
- sendto_one(cptr, rpl_str(RPL_ENDOFGLIST), me.name, sptr->name);
+ sendto_one(sptr, rpl_str(RPL_ENDOFGLIST), me.name, sptr->name);
return 0;
}
flags |= GLINE_LOCAL;
}
- if (*server == '-')
- server++;
- else if (*server == '+') {
+ if (*mask == '-')
+ mask++;
+ else if (*mask == '+') {
flags |= GLINE_ACTIVE;
- server++;
+ mask++;
} else
flags |= GLINE_ACTIVE;
struct Channel* chptr;
char* name;
char* keysOrTS = NULL;
- int i = 0;
int zombie = 0;
int sendcreate = 0;
unsigned int flags = 0;
/*
* XXX - ack!!!
*/
+#include "s_stats.h"
#include "channel.h"
#include "class.h"
#include "client.h"
#include <stdlib.h>
#include <string.h>
-/*
- * Help info displayed when user provides no stats parameter. --Gte
- */
-const char *statsinfo[] = {
- "The following statistics are available:",
- "U - Service server & nick jupes information.",
- "u - Current uptime & highest connection count.",
- "p - Listening ports.",
- "i - Connection authorisation lines.",
- "y - Connection classes.",
- "c - Remote server connection lines.",
- "h - Hubs information (Oper only).",
- "d - Dynamic routing configuration.",
- "l - Current connections information.",
- "g - Global bans (G-lines).",
- "k - Local bans (K-Lines).",
- "o - Operator information.",
- "m - Message usage information.",
- "t - Local connection statistics (Total SND/RCV, etc).",
- "w - Userload statistics.",
- "M - Memory allocation & leak monitoring.",
- "z - Memory/Structure allocation information.",
- "r - System resource usage (Debug only).",
- "x - List usage information (Debug only).",
- 0,
-};
/*
* m_stats - generic message handler
static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :" TIME_T_FMT;
struct Message *mptr;
struct Client *acptr;
- struct Gline* gline;
struct ConfItem *aconf;
char stat = parc > 1 ? parv[1][0] : '\0';
const char **infotext = statsinfo;
int i;
-/* m_stats is so obnoxiously full of special cases that the different
- * hunt_server() possiblites were becoming very messy. It now uses a
- * switch() so as to be easier to read and update as params change.
- * -Ghostwolf
- */
- switch (stat)
- {
- /* open to all, standard # of params */
- case 'U':
- case 'u':
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
-
- /* open to all, varying # of params */
- case 'k':
- case 'K':
- case 'i':
- case 'I':
- case 'p':
- case 'P':
- {
- if (parc > 3)
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- else
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- break;
- }
-
- /* oper only, varying # of params */
- case 'l':
- case 'L':
- case 'M':
- {
- if (parc == 4)
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- else if (parc > 4)
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s %s :%s", 2, parc,
- parv) != HUNTED_ISME)
- return 0;
- }
- else if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
-
- /* oper only, standard # of params */
- default:
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
- }
+ if (hunt_stats(cptr, sptr, parc, parv, stat) != HUNTED_ISME)
+ return 0;
switch (stat)
{
/* Don't return clients when this is a request for `all' */
if (doall && IsUser(acptr))
continue;
- /* Don't show invisible people to unauthorized people when using
- * wildcards -- Is this still needed now /stats is oper only ?
- * Yeah it is -- non opers can /stats l, just not remotely.
- */
- if (IsInvisible(acptr) && (doall || wilds) &&
- !(MyConnect(sptr) && IsOper(sptr)) &&
- !IsAnOper(acptr) && (acptr != sptr))
+ /* Don't show invisible people to non opers unless they know the nick */
+ if (IsInvisible(acptr) && (doall || wilds) && !IsAnOper(acptr) && (acptr != sptr))
continue;
/* Only show the ones that match the given mask - if any */
if (!doall && wilds && match(name, acptr->name))
break;
case 'G':
case 'g': /* send glines */
- gline_remove_expired(TStime());
- for (gline = GlobalGlineList; gline; gline = gline->next) {
- sendto_one(sptr, rpl_str(RPL_STATSGLINE), me.name,
- sptr->name, 'G', gline->name, gline->host,
- gline->expire, gline->reason);
- }
+ gline_stats(sptr);
break;
case 'H':
case 'h':
+ report_configured_links(sptr, CONF_HUB | CONF_LEAF);
break;
case 'I':
case 'i':
int wilds, count;
char *user, *host, *p;
int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
- if ((MyUser(sptr) || IsOper(sptr)) && parc < 4)
+ if (parc < 4)
{
report_configured_links(sptr, conf_status);
break;
}
- if (parc < 4 || *parv[3] == '\0')
- return need_more_params(sptr,
- (conf_status & CONF_KLINE) ? "STATS K" : "STATS I");
wilds = 0;
for (p = parv[3]; *p; p++)
break;
}
}
- if (!(MyConnect(sptr) || IsOper(sptr)))
- {
- wilds = 0;
- count = 3;
- }
- else
- count = 1000;
+
+ count = 1000;
if (conf_status == CONF_CLIENT)
{
(!user || !mmatch(user, aconf->name))))
{
sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name,
- sptr->name, 'K', aconf->host, aconf->passwd, aconf->name,
+ sptr->name, (aconf->status & CONF_KILL) ? 'K' : 'k',
+ aconf->host, aconf->passwd, aconf->name,
aconf->port, get_conf_class(aconf));
if (--count == 0)
break;
/*
* show listener ports
* show hidden ports to opers, if there are more than 3 parameters,
- * interpret the fourth parameter as the port number, limit non-local
- * or non-oper results to 8 ports.
+ * interpret the fourth parameter as the port number.
*/
- show_ports(sptr, IsOper(sptr), (parc > 3) ? atoi(parv[3]) : 0,
- (MyUser(sptr) || IsOper(sptr)) ? 100 : 8);
+ show_ports(sptr, 0, (parc > 3) ? atoi(parv[3]) : 0, 100);
break;
case 'R':
case 'r':
static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :" TIME_T_FMT;
struct Message *mptr;
struct Client *acptr;
- struct Gline* gline;
struct ConfItem *aconf;
char stat = parc > 1 ? parv[1][0] : '\0';
int i;
-/* m_stats is so obnoxiously full of special cases that the different
- * hunt_server() possiblites were becoming very messy. It now uses a
- * switch() so as to be easier to read and update as params change.
- * -Ghostwolf
- */
- switch (stat)
- {
- /* open to all, standard # of params */
- case 'U':
- case 'u':
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
-
- /* open to all, varying # of params */
- case 'k':
- case 'K':
- case 'i':
- case 'I':
- case 'p':
- case 'P':
- {
- if (parc > 3)
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- else
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- break;
- }
-
- /* oper only, varying # of params */
- case 'l':
- case 'L':
- case 'M':
- {
- if (parc == 4)
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- else if (parc > 4)
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s %s :%s", 2, parc,
- parv) != HUNTED_ISME)
- return 0;
- }
- else if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
-
- /* oper only, standard # of params */
- default:
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
- }
+ if (hunt_stats(cptr, sptr, parc, parv, stat) != HUNTED_ISME)
+ return 0;
switch (stat)
{
if (doall && IsUser(acptr))
continue;
/* Don't show invisible people to unauthorized people when using
- * wildcards -- Is this still needed now /stats is oper only ? */
- if (IsInvisible(acptr) && (doall || wilds) &&
- !(MyConnect(sptr) && IsOper(sptr)) &&
- !IsAnOper(acptr) && (acptr != sptr))
- continue;
+ * wildcards -- Is this still needed now /stats is oper only ?
+ * Not here, because ms_stats is specifically a remote command,
+ * thus the check was removed. -Ghostwolf */
/* Only show the ones that match the given mask - if any */
if (!doall && wilds && match(name, acptr->name))
continue;
}
case 'C':
case 'c':
- if (IsAnOper(sptr))
- report_configured_links(sptr, CONF_SERVER);
+ report_configured_links(sptr, CONF_SERVER);
break;
case 'G':
case 'g': /* send glines */
- gline_remove_expired(TStime());
- for (gline = GlobalGlineList; gline; gline = gline->next) {
- sendto_one(sptr, rpl_str(RPL_STATSGLINE), me.name,
- sptr->name, 'G', gline->name, gline->host,
- gline->expire, gline->reason);
- }
+ gline_stats(sptr);
break;
case 'H':
case 'h':
int wilds, count;
char *user, *host, *p;
int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
- if ((MyUser(sptr) || IsOper(sptr)) && parc < 4)
+ if (IsOper(sptr) && parc < 4)
{
report_configured_links(sptr, conf_status);
break;
break;
}
}
- if (!(MyConnect(sptr) || IsOper(sptr)))
+ if (!IsOper(sptr))
{
wilds = 0;
count = 3;
(!user || !mmatch(user, aconf->name))))
{
sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name,
- sptr->name, 'K', aconf->host, aconf->passwd, aconf->name,
+ sptr->name, (aconf->status & CONF_KILL) ? 'K' : 'k',
+ aconf->host, aconf->passwd, aconf->name,
aconf->port, get_conf_class(aconf));
if (--count == 0)
break;
* interpret the fourth parameter as the port number, limit non-local
* or non-oper results to 8 ports.
*/
- show_ports(sptr, IsOper(sptr), (parc > 3) ? atoi(parv[3]) : 0,
- (MyUser(sptr) || IsOper(sptr)) ? 100 : 8);
+ show_ports(sptr, IsOper(sptr), (parc > 3) ? atoi(parv[3]) : 0, IsOper(sptr) ? 100 : 8);
break;
case 'R':
case 'r':
static char Lformat[] = ":%s %d %s %s %u %u %u %u %u :" TIME_T_FMT;
struct Message *mptr;
struct Client *acptr;
- struct Gline* gline;
struct ConfItem *aconf;
char stat = parc > 1 ? parv[1][0] : '\0';
const char **infotext = statsinfo;
int i;
-/* m_stats is so obnoxiously full of special cases that the different
- * hunt_server() possiblites were becoming very messy. It now uses a
- * switch() so as to be easier to read and update as params change.
- * -Ghostwolf
- */
- switch (stat)
- {
- /* open to all, standard # of params */
- case 'U':
- case 'u':
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
-
- /* open to all, varying # of params */
- case 'k':
- case 'K':
- case 'i':
- case 'I':
- case 'p':
- case 'P':
- {
- if (parc > 3)
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- else
- {
- if (hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- break;
- }
-
- /* oper only, varying # of params */
- case 'l':
- case 'L':
- case 'M':
- {
- if (parc == 4)
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- }
- else if (parc > 4)
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s %s :%s", 2, parc,
- parv) != HUNTED_ISME)
- return 0;
- }
- else if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
-
- /* oper only, standard # of params */
- default:
- {
- if (hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv)
- != HUNTED_ISME)
- return 0;
- break;
- }
- }
+ if (hunt_stats(cptr, sptr, parc, parv, stat) != HUNTED_ISME)
+ return 0;
switch (stat)
{
/* Don't return clients when this is a request for `all' */
if (doall && IsUser(acptr))
continue;
- /* Don't show invisible people to unauthorized people when using
- * wildcards -- Is this still needed now /stats is oper only ? */
- if (IsInvisible(acptr) && (doall || wilds) &&
- !(MyConnect(sptr) && IsOper(sptr)) &&
- !IsAnOper(acptr) && (acptr != sptr))
- continue;
/* Only show the ones that match the given mask - if any */
if (!doall && wilds && match(name, acptr->name))
continue;
break;
case 'G':
case 'g': /* send glines */
- gline_remove_expired(TStime());
- for (gline = GlobalGlineList; gline; gline = gline->next) {
- sendto_one(sptr, rpl_str(RPL_STATSGLINE), me.name,
- sptr->name, 'G', gline->name, gline->host,
- gline->expire, gline->reason);
- }
+ gline_stats(sptr);
break;
case 'H':
case 'h':
int wilds, count;
char *user, *host, *p;
int conf_status = (stat == 'k' || stat == 'K') ? CONF_KLINE : CONF_CLIENT;
- if ((MyUser(sptr) || IsOper(sptr)) && parc < 4)
+ if (parc < 4)
{
report_configured_links(sptr, conf_status);
break;
}
- if (parc < 4 || *parv[3] == '\0')
- return need_more_params(sptr,
- (conf_status & CONF_KLINE) ? "STATS K" : "STATS I");
wilds = 0;
for (p = parv[3]; *p; p++)
break;
}
}
- if (!(MyConnect(sptr) || IsOper(sptr)))
- {
- wilds = 0;
- count = 3;
- }
- else
- count = 1000;
+
+ count = 1000;
if (conf_status == CONF_CLIENT)
{
(!user || !mmatch(user, aconf->name))))
{
sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name,
- sptr->name, 'K', aconf->host, aconf->passwd, aconf->name,
+ sptr->name, (aconf->status & CONF_KILL) ? 'K' : 'k',
+ aconf->host, aconf->passwd, aconf->name,
aconf->port, get_conf_class(aconf));
if (--count == 0)
break;
* interpret the fourth parameter as the port number, limit non-local
* or non-oper results to 8 ports.
*/
- show_ports(sptr, IsOper(sptr), (parc > 3) ? atoi(parv[3]) : 0,
- (MyUser(sptr) || IsOper(sptr)) ? 100 : 8);
+ show_ports(sptr, 1, (parc > 3) ? atoi(parv[3]) : 0, 100);
break;
case 'R':
case 'r':
return 0;
}
#endif /* 0 */
+
+
#include "send.h"
#include "struct.h"
+#include <stdio.h> /* sprintf */
void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length)
{
#include <stdlib.h>
#include <sys/time.h>
-/*
- * m_stats/stats_conf
- *
- * Report N/C-configuration lines from this server. This could
- * report other configuration lines too, but converting the
- * status back to "char" is a bit akward--not worth the code
- * it needs...
- *
- * Note: The info is reported in the order the server uses
- * it--not reversed as in ircd.conf!
- */
-
-static unsigned int report_array[17][3] = {
- {CONF_SERVER, RPL_STATSCLINE, 'C'},
- {CONF_CLIENT, RPL_STATSILINE, 'I'},
- {CONF_KILL, RPL_STATSKLINE, 'K'},
- {CONF_IPKILL, RPL_STATSKLINE, 'k'},
- {CONF_LEAF, RPL_STATSLLINE, 'L'},
- {CONF_OPERATOR, RPL_STATSOLINE, 'O'},
- {CONF_HUB, RPL_STATSHLINE, 'H'},
- {CONF_LOCOP, RPL_STATSOLINE, 'o'},
- {CONF_CRULEALL, RPL_STATSDLINE, 'D'},
- {CONF_CRULEAUTO, RPL_STATSDLINE, 'd'},
- {CONF_UWORLD, RPL_STATSULINE, 'U'},
- {CONF_TLINES, RPL_STATSTLINE, 'T'},
- {0, 0}
-};
-
-void report_configured_links(struct Client *sptr, int mask)
-{
- static char null[] = "<NULL>";
- struct ConfItem *tmp;
- unsigned int *p;
- unsigned short int port;
- char c, *host, *pass, *name;
-
- for (tmp = GlobalConfList; tmp; tmp = tmp->next) {
- if ((tmp->status & mask))
- {
- for (p = &report_array[0][0]; *p; p += 3)
- if (*p == tmp->status)
- break;
- if (!*p)
- continue;
- c = (char)*(p + 2);
- host = BadPtr(tmp->host) ? null : tmp->host;
- pass = BadPtr(tmp->passwd) ? null : tmp->passwd;
- name = BadPtr(tmp->name) ? null : tmp->name;
- port = tmp->port;
- /*
- * On K line the passwd contents can be
- * displayed on STATS reply. -Vesa
- */
- /* Special-case 'k' or 'K' lines as appropriate... -Kev */
- if ((tmp->status & CONF_KLINE))
- sendto_one(sptr, rpl_str(p[1]), me.name,
- sptr->name, c, host, pass, name, port, get_conf_class(tmp));
- /*
- * connect rules are classless
- */
- else if ((tmp->status & CONF_CRULE))
- sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name);
- else if ((tmp->status & CONF_TLINES))
- sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, pass);
- else if ((tmp->status & CONF_UWORLD))
- sendto_one(sptr, rpl_str(p[1]),
- me.name, sptr->name, c, host, pass, name, port,
- get_conf_class(tmp));
- else if ((tmp->status & (CONF_SERVER | CONF_HUB)))
- sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, "*", name,
- port, get_conf_class(tmp));
- else
- sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name,
- port, get_conf_class(tmp));
- }
- }
-}
-
char *militime(char* sec, char* usec)
{
struct timeval tv;
/* find active glines */
/* added a check against the user's IP address to find_gline() -Kev */
+ /* FIX ME KEV! gline_find take char *userhost not struct Client! -GW */
else if ((agline = gline_find(cptr, 0)) && GlineIsActive(agline))
sendto_one(cptr, ":%s %d %s :%s.", me.name, ERR_YOUREBANNEDCREEP,
cptr->name, GlineReason(agline));
--- /dev/null
+/*
+ * IRC - Internet Relay Chat, ircd/s_stats.c
+ * Copyright (C) 2000 Joseph Bongaarts
+ *
+ * See file AUTHORS in IRC package for additional names of
+ * the programmers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ */
+
+#include "s_stats.h"
+#include "class.h"
+#include "client.h"
+#include "crule.h"
+#include "ircd.h"
+#include "ircd_chattr.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "listener.h"
+#include "match.h"
+#include "msg.h"
+#include "numeric.h"
+#include "numnicks.h"
+#include "s_conf.h"
+#include "s_user.h"
+#include "send.h"
+#include "struct.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+
+/*
+ * m_stats/s_stats
+ *
+ * Report configuration lines and other statistics from this
+ * server.
+ *
+ * Note: The info is reported in the order the server uses
+ * it--not reversed as in ircd.conf!
+ */
+
+/*
+ * Help info displayed when user provides no stats parameter. --Gte
+ */
+const char *statsinfo[] = {
+ "The following statistics are available:",
+ "U - Service server & nick jupes information.",
+ "u - Current uptime & highest connection count.",
+ "p - Listening ports.",
+ "i - Connection authorisation lines.",
+ "y - Connection classes.",
+ "c - Remote server connection lines.",
+ "h - Hubs information.",
+ "d - Dynamic routing configuration.",
+ "l - Current connections information.",
+ "g - Global bans (G-lines).",
+ "k - Local bans (K-Lines).",
+ "o - Operator information.",
+ "m - Message usage information.",
+ "t - Local connection statistics (Total SND/RCV, etc).",
+ "w - Userload statistics.",
+ "M - Memory allocation & leak monitoring.",
+ "z - Memory/Structure allocation information.",
+ "r - System resource usage (Debug only).",
+ "x - List usage information (Debug only).",
+ 0,
+};
+
+static unsigned int report_array[17][3] = {
+ {CONF_SERVER, RPL_STATSCLINE, 'C'},
+ {CONF_CLIENT, RPL_STATSILINE, 'I'},
+ {CONF_KILL, RPL_STATSKLINE, 'K'},
+ {CONF_IPKILL, RPL_STATSKLINE, 'k'},
+ {CONF_LEAF, RPL_STATSLLINE, 'L'},
+ {CONF_OPERATOR, RPL_STATSOLINE, 'O'},
+ {CONF_HUB, RPL_STATSHLINE, 'H'},
+ {CONF_LOCOP, RPL_STATSOLINE, 'o'},
+ {CONF_CRULEALL, RPL_STATSDLINE, 'D'},
+ {CONF_CRULEAUTO, RPL_STATSDLINE, 'd'},
+ {CONF_UWORLD, RPL_STATSULINE, 'U'},
+ {CONF_TLINES, RPL_STATSTLINE, 'T'},
+ {0, 0}
+};
+
+void report_configured_links(struct Client *sptr, int mask)
+{
+ static char null[] = "<NULL>";
+ struct ConfItem *tmp;
+ unsigned int *p;
+ unsigned short int port;
+ char c, *host, *pass, *name;
+
+
+ for (tmp = GlobalConfList; tmp; tmp = tmp->next)
+ {
+ if ((tmp->status & mask))
+ {
+ for (p = &report_array[0][0]; *p; p += 3)
+ if (*p == tmp->status)
+ break;
+ if (!*p)
+ continue;
+ c = (char)*(p + 2);
+ host = BadPtr(tmp->host) ? null : tmp->host;
+ pass = BadPtr(tmp->passwd) ? null : tmp->passwd;
+ name = BadPtr(tmp->name) ? null : tmp->name;
+ port = tmp->port;
+ /*
+ * On K line the passwd contents can be
+ * displayed on STATS reply. -Vesa
+ */
+ /* Special-case 'k' or 'K' lines as appropriate... -Kev */
+ if ((tmp->status & CONF_KLINE))
+ sendto_one(sptr, rpl_str(p[1]), me.name,
+ sptr->name, c, host, pass, name, port, get_conf_class(tmp));
+ /*
+ * connect rules are classless
+ */
+ else if ((tmp->status & CONF_CRULE))
+ sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name);
+ else if ((tmp->status & CONF_TLINES))
+ sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, pass);
+ else if ((tmp->status & CONF_UWORLD))
+ sendto_one(sptr, rpl_str(p[1]),
+ me.name, sptr->name, c, host, pass, name, port,
+ get_conf_class(tmp));
+ else if ((tmp->status & (CONF_SERVER | CONF_HUB)))
+ sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, "*", name,
+ port, get_conf_class(tmp));
+ else
+ sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name,
+ port, get_conf_class(tmp));
+ }
+ }
+}
+
+/* m_stats is so obnoxiously full of special cases that the different
+ * hunt_server() possiblites were becoming very messy. It now uses a
+ * switch() so as to be easier to read and update as params change.
+ * -Ghostwolf
+ */
+int hunt_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[], char stat)
+{
+ switch (stat)
+ {
+ /* open to all, standard # of params */
+ case 'U':
+ case 'u':
+ return hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv);
+
+ /* open to all, varying # of params */
+ case 'k':
+ case 'K':
+ case 'i':
+ case 'I':
+ case 'p':
+ case 'P':
+ {
+ if (parc > 3)
+ return hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv);
+ else
+ return hunt_server(0, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv);
+ }
+
+ /* oper only, varying # of params */
+ case 'l':
+ case 'L':
+ case 'M':
+ {
+ if (parc == 4)
+ return hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s :%s", 2, parc, parv);
+ else if (parc > 4)
+ return hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s %s %s :%s", 2, parc, parv);
+ else
+ return hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv);
+ }
+
+ /* oper only, standard # of params */
+ default:
+ return hunt_server(1, cptr, sptr, "%s%s " TOK_STATS " %s :%s", 2, parc, parv);
+ }
+}
+
#include "version.h"
#include "whowas.h"
+#include "handlers.h" /* m_motd and m_lusers */
+
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>