commit latest changes, mainly module core interaction
This commit is contained in:
parent
91b0701635
commit
a04ec54806
57 changed files with 2252 additions and 1846 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -273,7 +273,6 @@ src/modules/statserv/database.c -text
|
|||
src/modules/statserv/global.h -text
|
||||
src/modules/statserv/html/index.tpl -text
|
||||
src/modules/statserv/htmlstats.c -text
|
||||
src/modules/statserv/m_stats.h -text
|
||||
src/modules/statserv/md5.c -text
|
||||
src/modules/statserv/md5.h -text
|
||||
src/modules/statserv/sqlstats.h -text
|
||||
|
|
20
ChangeLog
20
ChangeLog
|
@ -4,6 +4,26 @@ Anything we add/remove/fix/change is in here (even our rants)
|
|||
Fish (F), Mark (M)
|
||||
===============================================================================
|
||||
* NeoStats * Version 3.0.genesis
|
||||
- StatServ: Optimise database save to further reduce code required and get
|
||||
back a little CPU.
|
||||
- StatServ: Adjust exclusions so that counts are accurate. The exclusions
|
||||
produced cases where the current channel count was greater than the network
|
||||
record! (M)
|
||||
- IRCd version suffix now handled by configure rather than code. (M)
|
||||
- Introduce new debug.log system to store all current messages and debug info
|
||||
to avoid corrupting main system logs when in debug mode and allow users to
|
||||
submit this file for support rather than multiple ones from modules plus
|
||||
core. (M)
|
||||
- StatServ: reorganised code so stats code is encapsulated from module
|
||||
specifics and introduced new burst request system during init. (M)
|
||||
- Begin implementing "burst" request interface for modules to get current
|
||||
user/channel/server etc lists. (M)
|
||||
- Homogenize init error messages. (M)
|
||||
- Update core support functions to use new run level system to determine
|
||||
current module removing the need for modules to pass their module pointer
|
||||
when adding bots/timers/socks etc. (M)
|
||||
- Replace old segv_module system with new run level system. (M)
|
||||
- Keeper subdirs are now subdirs of main data dir. (M)
|
||||
- ConnectServ: reverse colour define so default is disabled. (M)
|
||||
- Core modules now use core config loading system (M)
|
||||
- All socket code now in socks.c for easier upgrade (M)
|
||||
|
|
12
configure.in
12
configure.in
|
@ -185,6 +185,7 @@ AC_ARG_ENABLE(unreal31, [ --enable-unreal31 - enable Unreal 3.1.x IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(UNREAL, 1, 'Enable Unreal 3.1.x Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Unreal 3.1")
|
||||
PROTOCOL="unreal"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -199,6 +200,7 @@ AC_ARG_ENABLE(unreal32, [ --enable-unreal32 - enable Unreal 3.2.x IRCD Support],
|
|||
yes)
|
||||
AC_DEFINE(UNREAL, 1, 'Enable Unreal 3.1.x Support')
|
||||
AC_DEFINE(UNREAL32, 1, 'Enable Unreal 3.2.x Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Unreal 3.2")
|
||||
PROTOCOL="unreal"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -214,6 +216,7 @@ AC_ARG_ENABLE(ultimate2, [ --enable-ultimate2 - enable Ultimate 2.x.x IRCD Suppo
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(ULTIMATE, 1, 'Enable Ultimate Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Ultimate 2.x.x")
|
||||
PROTOCOL="ultimate"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -229,6 +232,7 @@ AC_ARG_ENABLE(ultimate3, [ --enable-ultimate3 - enable Ultimate 3.x.x IRCD Suppo
|
|||
yes)
|
||||
AC_DEFINE(ULTIMATE, 1, 'Enable Ultimate 2.x.x Support')
|
||||
AC_DEFINE(ULTIMATE3, 1, "Enable Ultimate 3.x.x Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Ultimate 3.x.x")
|
||||
PROTOCOL="ultimate"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -244,6 +248,7 @@ AC_ARG_ENABLE(hybrid7, [ --enable-hybrid7 - enable Hybrid7 IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(HYBRID7, 1, 'Enable hybrid7 IRCD support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Hybrid 7")
|
||||
PROTOCOL="hybrid7"
|
||||
AC_MSG_CHECKING(Auto-Enabling ServiceRoots Authentication Module)
|
||||
do_serviceroots=yes
|
||||
|
@ -265,6 +270,7 @@ AC_ARG_ENABLE(neoircd, [ --enable-neoircd - enable NeoIRCd IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(NEOIRCD, 1, 'Enable NeoIRCd IRCD support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "NeoIRCd")
|
||||
PROTOCOL="neoircd"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -281,6 +287,7 @@ AC_ARG_ENABLE(quantum, [ --enable-quantum - enable Quantum IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(QUANTUM, 1, 'Enable Quantum Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Quantum")
|
||||
PROTOCOL="quantum"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -296,6 +303,7 @@ AC_ARG_ENABLE(mystic, [ --enable-mystic - enable Mystic IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(MYSTIC, 1, 'Enable Mystic Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Mystic")
|
||||
PROTOCOL="mystic"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -311,6 +319,7 @@ AC_ARG_ENABLE(bahamut, [ --enable-bahamut - enable Bahamut IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(BAHAMUT, 1, 'Enable Bahamut Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Bahamut")
|
||||
PROTOCOL="bahamut"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -327,6 +336,7 @@ AC_ARG_ENABLE(ircu, [ --enable-ircu - enable IRCu IRCD Support],
|
|||
yes)
|
||||
dnl AC_MSG_ERROR('Sorry IRCu support isnt complete yet')
|
||||
AC_DEFINE(IRCU, 1, 'Enable IRCu Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "IRCu")
|
||||
PROTOCOL="ircu"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -342,6 +352,7 @@ AC_ARG_ENABLE(liquid, [ --enable-liquid - enable Liquid IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(LIQUID, 1, 'Enable Liquid IRCd Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Liquid")
|
||||
PROTOCOL="liquid"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
@ -358,6 +369,7 @@ AC_ARG_ENABLE(viagra, [ --enable-viagra - enable Viagra IRCD Support],
|
|||
[ case "$enableval" in
|
||||
yes)
|
||||
AC_DEFINE(VIAGRA, 1, 'Enable Viagra IRCd Support')
|
||||
AC_DEFINE_UNQUOTED(NS_PROTOCOL, "Viagra")
|
||||
PROTOCOL="viagra"
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
|
|
|
@ -36,13 +36,9 @@ new_ban (const char *mask)
|
|||
hnode_t *bansnode;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
ban = calloc (sizeof (Ban), 1);
|
||||
bzero(ban, sizeof(Ban));
|
||||
ban = scalloc (sizeof (Ban));
|
||||
strlcpy (ban->mask, mask, MAXHOST);
|
||||
bansnode = hnode_create (ban);
|
||||
if (!bansnode) {
|
||||
nlog (LOG_WARNING, "bans hash is broken\n");
|
||||
}
|
||||
if (hash_isfull (banshash)) {
|
||||
nlog (LOG_WARNING, "bans hash is full!\n");
|
||||
} else {
|
||||
|
@ -259,7 +255,7 @@ InitBans (void)
|
|||
{
|
||||
banshash = hash_create (-1, 0, 0);
|
||||
if (!banshash) {
|
||||
nlog (LOG_CRITICAL, "Create bans hash failed\n");
|
||||
nlog (LOG_CRITICAL, "Unable to create bans hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
#ifdef SQLSRV
|
||||
|
|
65
src/bots.c
65
src/bots.c
|
@ -144,6 +144,34 @@ del_chan_bot (char *bot, char *chan)
|
|||
}
|
||||
}
|
||||
|
||||
/** @brief dump list of module bots and channels
|
||||
*
|
||||
* @param u
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
int
|
||||
list_bot_chans (CmdParams* cmdparams)
|
||||
{
|
||||
hscan_t hs;
|
||||
hnode_t *hn;
|
||||
lnode_t *ln;
|
||||
ChanBot *mod_chan_bot;
|
||||
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "BotChanDump:");
|
||||
hash_scan_begin (&hs, bch);
|
||||
while ((hn = hash_scan_next (&hs)) != NULL) {
|
||||
mod_chan_bot = hnode_get (hn);
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "%s:--------------------------------", mod_chan_bot->chan);
|
||||
ln = list_first (mod_chan_bot->bots);
|
||||
while (ln) {
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Bot Name: %s", (char *)lnode_get (ln));
|
||||
ln = list_next (mod_chan_bot->bots, ln);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int process_origin(CmdParams * cmdparams, char* origin)
|
||||
{
|
||||
cmdparams->source.user = finduser (origin);
|
||||
|
@ -295,34 +323,6 @@ void bot_chan_private (char *origin, char **av, int ac)
|
|||
free (cmdparams);
|
||||
}
|
||||
|
||||
/** @brief dump list of module bots and channels
|
||||
*
|
||||
* @param u
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
int
|
||||
list_bot_chans (CmdParams* cmdparams)
|
||||
{
|
||||
hscan_t hs;
|
||||
hnode_t *hn;
|
||||
lnode_t *ln;
|
||||
ChanBot *mod_chan_bot;
|
||||
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "BotChanDump:");
|
||||
hash_scan_begin (&hs, bch);
|
||||
while ((hn = hash_scan_next (&hs)) != NULL) {
|
||||
mod_chan_bot = hnode_get (hn);
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "%s:--------------------------------", mod_chan_bot->chan);
|
||||
ln = list_first (mod_chan_bot->bots);
|
||||
while (ln) {
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Bot Name: %s", (char *)lnode_get (ln));
|
||||
ln = list_next (mod_chan_bot->bots, ln);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @brief create a new bot
|
||||
*
|
||||
* @param bot_name string containing bot name
|
||||
|
@ -516,14 +516,16 @@ int del_bots (Module *mod_ptr)
|
|||
*
|
||||
* @return NS_SUCCESS if suceeds, NS_FAILURE if not
|
||||
*/
|
||||
Bot * init_bot (Module* modptr, BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd *bot_cmd_list, bot_setting *bot_setting_list)
|
||||
Bot * init_bot (BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd *bot_cmd_list, bot_setting *bot_setting_list)
|
||||
{
|
||||
Bot * botptr;
|
||||
User *u;
|
||||
long Umode;
|
||||
char* nick;
|
||||
Module* modptr;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
modptr = GET_CUR_MODULE();
|
||||
nick = botinfo->nick;
|
||||
u = finduser (nick);
|
||||
if (u) {
|
||||
|
@ -559,10 +561,7 @@ Bot * init_bot (Module* modptr, BotInfo* botinfo, const char* modes, unsigned in
|
|||
sumode_cmd (nick, nick, UMODE_DEAF);
|
||||
}
|
||||
#endif
|
||||
/* restore segv_inmodule from SIGNON */
|
||||
if(modptr) {
|
||||
SET_SEGV_INMODULE(modptr->info->name);
|
||||
}
|
||||
SET_RUN_LEVEL(modptr);
|
||||
botptr->flags = flags;
|
||||
if (bot_cmd_list) {
|
||||
add_bot_cmd_list (botptr, bot_cmd_list);
|
||||
|
|
|
@ -44,9 +44,9 @@ typedef struct Chanmem {
|
|||
void *moddata[NUM_MODULES];
|
||||
} Chanmem;
|
||||
|
||||
hash_t *ch;
|
||||
static hash_t *ch;
|
||||
|
||||
extern char quitreason[BUFSIZE];
|
||||
static char quitreason[BUFSIZE];
|
||||
|
||||
static void
|
||||
ChanPartHandler (list_t * list, lnode_t * node, void *v)
|
||||
|
@ -54,8 +54,13 @@ ChanPartHandler (list_t * list, lnode_t * node, void *v)
|
|||
part_chan ((User *)v, lnode_get (node), quitreason[0] != 0 ? quitreason : NULL);
|
||||
}
|
||||
|
||||
void PartAllChannels (User* u)
|
||||
void PartAllChannels (User* u, const char* reason)
|
||||
{
|
||||
bzero(quitreason, BUFSIZE);
|
||||
if(reason) {
|
||||
strlcpy(quitreason, reason, BUFSIZE);
|
||||
strip_mirc_codes(quitreason);
|
||||
}
|
||||
list_process (u->chans, u, ChanPartHandler);
|
||||
}
|
||||
|
||||
|
@ -675,7 +680,7 @@ join_chan (const char* nick, const char *chan)
|
|||
if (!ircstrcasecmp ("0", chan)) {
|
||||
/* join 0 is actually part all chans */
|
||||
nlog (LOG_DEBUG2, "join_chan: parting %s from all channels", u->nick);
|
||||
PartAllChannels (u);
|
||||
PartAllChannels (u, NULL);
|
||||
return;
|
||||
}
|
||||
c = findchan (chan);
|
||||
|
@ -1096,8 +1101,10 @@ int
|
|||
InitChannels ()
|
||||
{
|
||||
ch = hash_create (C_TABLE_SIZE, 0, 0);
|
||||
if(!ch)
|
||||
if(!ch) {
|
||||
nlog (LOG_CRITICAL, "Unable to create channel hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
#ifdef SQLSRV
|
||||
/* add the server hash to the sql library */
|
||||
neo_chans.address = ch;
|
||||
|
@ -1105,3 +1112,22 @@ InitChannels ()
|
|||
#endif
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
void FiniChannels (void)
|
||||
{
|
||||
hash_destroy(ch);
|
||||
}
|
||||
|
||||
void GetChannelList(ChannelListHandler handler)
|
||||
{
|
||||
hnode_t *node;
|
||||
hscan_t scan;
|
||||
Channel *c;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
hash_scan_begin(&scan, ch);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
c = hnode_get(node);
|
||||
handler(c);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
void ChanDump (const char *chan);
|
||||
void part_chan (User * u, const char *chan, const char* reason);
|
||||
void PartAllChannels (User* u);
|
||||
void PartAllChannels (User* u, const char* reason);
|
||||
void join_chan (const char* nick, const char *chan);
|
||||
void ChanNickChange (Channel * c, const char *newnick, const char *oldnick);
|
||||
int ChanMode (char *origin, char **av, int ac);
|
||||
|
@ -35,5 +35,6 @@ void ChanUserMode (const char* chan, const char* nick, int add, long mode);
|
|||
void kick_chan (const char *kickby, const char *chan, const char *kicked, const char *kickreason);
|
||||
void SetChanTS (Channel * c, const time_t tstime);
|
||||
int InitChannels (void);
|
||||
void FiniChannels (void);
|
||||
|
||||
#endif /* _CHANS_H_ */
|
||||
|
|
|
@ -476,10 +476,9 @@ run_bot_cmd (CmdParams * cmdparams)
|
|||
nlog (LOG_NORMAL, "%s used %s", cmdparams->source.user->nick, cmdparams->param);
|
||||
/* call handler */
|
||||
if (setjmp (sigvbuf) == 0) {
|
||||
if(cmdparams->dest.bot->moduleptr)
|
||||
SET_SEGV_INMODULE(cmdparams->dest.bot->moduleptr->info->name);
|
||||
SET_RUN_LEVEL(cmdparams->dest.bot->moduleptr);
|
||||
cmdret = cmd_ptr->handler(cmdparams);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
}
|
||||
switch(cmdret) {
|
||||
case NS_ERR_SYNTAX_ERROR:
|
||||
|
|
|
@ -101,13 +101,6 @@ ConfLoad ()
|
|||
return NS_FAILURE;
|
||||
}
|
||||
printf ("Sucessfully loaded config file, booting NeoStats\n");
|
||||
/* if all bots should join the chan */
|
||||
if (GetConf ((void *) &me.allbots, CFGINT, "AllBotsJoinChan") <= 0) {
|
||||
me.allbots = 0;
|
||||
}
|
||||
if (GetConf ((void *) &me.pingtime, CFGINT, "PingServerTime") <= 0) {
|
||||
me.pingtime = 120;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,13 +121,15 @@
|
|||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* IRCd protocol */
|
||||
#undef NS_PROTOCOL
|
||||
|
||||
/* 'Enable Ultimate Support' */
|
||||
#undef ULTIMATE
|
||||
|
||||
/* 'Enable Ultimate Support' */
|
||||
#undef ULTIMATE3
|
||||
|
||||
|
||||
/* 'Enable Unreal Support' */
|
||||
#undef UNREAL
|
||||
|
||||
|
|
17
src/db.c
17
src/db.c
|
@ -41,15 +41,8 @@ int DBOpenDatabase(void)
|
|||
{
|
||||
int index;
|
||||
nlog(LOG_DEBUG1, "DBOpenDatabase");
|
||||
|
||||
index = get_mod_num (segv_inmodule);
|
||||
|
||||
if (index == NS_FAILURE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ircsnprintf(db_list[index].dbname, MAXPATH, "data/%s.db", segv_inmodule);
|
||||
|
||||
index = GET_CUR_MODNUM();
|
||||
ircsnprintf(db_list[index].dbname, MAXPATH, "data/%s.db", GET_CUR_MODNAME());
|
||||
if ((dbret = db_create(&db_list[index].dbp, NULL, 0)) != 0) {
|
||||
nlog(LOG_DEBUG1, "db_create: %s", db_strerror(dbret));
|
||||
return -1;
|
||||
|
@ -66,7 +59,7 @@ void DBCloseDatabase(void)
|
|||
int index;
|
||||
|
||||
nlog(LOG_DEBUG1, "DBCloseDatabase");
|
||||
index = get_mod_num (segv_inmodule);
|
||||
index = GET_CUR_MODNUM();
|
||||
db_list[index].dbp->close(db_list[index].dbp, 0);
|
||||
}
|
||||
|
||||
|
@ -75,7 +68,7 @@ void* DBGetData(char* key)
|
|||
int index;
|
||||
|
||||
nlog(LOG_DEBUG1, "DBGetData %s", key);
|
||||
index = get_mod_num (segv_inmodule);
|
||||
index = GET_CUR_MODNUM();
|
||||
memset(&dbkey, 0, sizeof(dbkey));
|
||||
memset(&dbdata, 0, sizeof(dbdata));
|
||||
dbkey.data = key;
|
||||
|
@ -94,7 +87,7 @@ void DBSetData(char* key, void* data, int size)
|
|||
int index;
|
||||
|
||||
nlog(LOG_DEBUG1, "DBSetData %s %s", key, data);
|
||||
index = get_mod_num (segv_inmodule);
|
||||
index = GET_CUR_MODNUM();
|
||||
memset(&dbkey, 0, sizeof(dbkey));
|
||||
memset(&dbdata, 0, sizeof(dbdata));
|
||||
dbkey.data = key;
|
||||
|
|
80
src/dns.c
80
src/dns.c
|
@ -2,8 +2,6 @@
|
|||
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond
|
||||
** http://www.neostats.net/
|
||||
**
|
||||
**
|
||||
**
|
||||
** 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 2 of the License, or
|
||||
|
@ -36,21 +34,20 @@
|
|||
#include "dns.h"
|
||||
#include "services.h"
|
||||
|
||||
adns_state ads;
|
||||
#define DNS_DATA_SIZE 255
|
||||
|
||||
/** @brief DNS lookup Struct
|
||||
* structure containing all pending DNS lookups and the callback functions
|
||||
*/
|
||||
struct dnslookup_struct {
|
||||
typedef struct DnsLookup {
|
||||
adns_query q; /**< the ADNS query */
|
||||
adns_answer *a; /**< the ADNS result if we have completed */
|
||||
adns_rrtype type; /**< the type we are looking for, only populated if we add to a queue */
|
||||
char data[255]; /**< the User data based to the callback */
|
||||
char data[DNS_DATA_SIZE]; /**< the User data based to the callback */
|
||||
char lookupdata[255]; /**< the look up data, only populated if we add to a queue */
|
||||
void (*callback) (char *data, adns_answer * a);
|
||||
/**< a function pointer to call when we have a result */
|
||||
char mod_name[MAX_MOD_NAME];
|
||||
};
|
||||
Module* modptr;
|
||||
} DnsLookup;
|
||||
|
||||
adns_state ads;
|
||||
|
||||
struct DNSStats {
|
||||
int totalq;
|
||||
|
@ -60,22 +57,16 @@ struct DNSStats {
|
|||
int failure;
|
||||
} DNSStats;
|
||||
|
||||
|
||||
/** @brief DNS structures
|
||||
*/
|
||||
typedef struct dnslookup_struct DnsLookup;
|
||||
|
||||
/** @brief List of DNS queryies
|
||||
* Contains DnsLookup entries
|
||||
*/
|
||||
list_t *dnslist;
|
||||
static list_t *dnslist;
|
||||
|
||||
/** @brief list of DNS queries that are queued up
|
||||
*
|
||||
*/
|
||||
list_t *dnsqueue;
|
||||
|
||||
|
||||
void dns_check_queue();
|
||||
|
||||
/** @brief starts a DNS lookup
|
||||
|
@ -90,9 +81,7 @@ void dns_check_queue();
|
|||
*
|
||||
* @return returns 1 on success, 0 on failure (to add the lookup, not a successful lookup
|
||||
*/
|
||||
|
||||
int
|
||||
dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_answer * a), char *data)
|
||||
int dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_answer * a), char *data)
|
||||
{
|
||||
lnode_t *dnsnode;
|
||||
DnsLookup *dnsdata;
|
||||
|
@ -109,14 +98,8 @@ dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_answ
|
|||
return 0;
|
||||
}
|
||||
/* set the module name */
|
||||
/* This is a bad bad hack... */
|
||||
if (segv_inmodule[0]) {
|
||||
/* why MAXHOST? because thats the size of mod_name!?!? */
|
||||
strlcpy(dnsdata->mod_name, segv_inmodule, MAX_MOD_NAME);
|
||||
} else {
|
||||
strlcpy(dnsdata->mod_name, "NeoStats", MAX_MOD_NAME);
|
||||
}
|
||||
strlcpy (dnsdata->data, data, 254);
|
||||
dnsdata->modptr = GET_CUR_MODULE();
|
||||
strlcpy (dnsdata->data, data, DNS_DATA_SIZE);
|
||||
dnsdata->callback = callback;
|
||||
dnsdata->type = type;
|
||||
|
||||
|
@ -155,23 +138,22 @@ dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_answ
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/** @brief sets up DNS subsystem
|
||||
*
|
||||
* configures ADNS for use with NeoStats.
|
||||
*
|
||||
* @return returns 1 on success, 0 on failure
|
||||
*/
|
||||
|
||||
int
|
||||
InitDns ()
|
||||
int InitDns (void)
|
||||
{
|
||||
int adnsstart;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
dnslist = list_create (DNS_QUEUE_SIZE);
|
||||
if (!dnslist)
|
||||
if (!dnslist) {
|
||||
nlog (LOG_CRITICAL, "Unable to create DNS list");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
/* dnsqueue is unlimited. */
|
||||
dnsqueue = list_create(-1);
|
||||
if (!dnsqueue)
|
||||
|
@ -182,7 +164,6 @@ InitDns ()
|
|||
adnsstart = adns_init (&ads, adns_if_debug | adns_if_noautosys, 0);
|
||||
#endif
|
||||
if (adnsstart) {
|
||||
printf ("ADNS init failed: %s\n", strerror (adnsstart));
|
||||
nlog (LOG_CRITICAL, "ADNS init failed: %s", strerror (adnsstart));
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
@ -193,14 +174,12 @@ InitDns ()
|
|||
/* @brief Clean up ADNS data when we shutdown
|
||||
*
|
||||
*/
|
||||
void
|
||||
FiniDns (void)
|
||||
void FiniDns (void)
|
||||
{
|
||||
lnode_t *dnsnode;
|
||||
DnsLookup *dnsdata;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
dnsnode = list_first (dnslist);
|
||||
while (dnsnode) {
|
||||
dnsdata = lnode_get(dnsnode);
|
||||
|
@ -222,17 +201,16 @@ FiniDns (void)
|
|||
* @param module name
|
||||
* @return Nothing
|
||||
*/
|
||||
void
|
||||
canx_dns(const char *modname) {
|
||||
void canx_dns(Module* modptr)
|
||||
{
|
||||
lnode_t *dnsnode, *lnode2;
|
||||
DnsLookup *dnsdata;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
dnsnode = list_first (dnslist);
|
||||
while (dnsnode) {
|
||||
dnsdata = lnode_get(dnsnode);
|
||||
if (!ircstrcasecmp(dnsdata->mod_name, modname)) {
|
||||
if (dnsdata->modptr == modptr) {
|
||||
adns_cancel(dnsdata->q);
|
||||
free (dnsdata->a);
|
||||
free (dnsdata);
|
||||
|
@ -245,7 +223,7 @@ canx_dns(const char *modname) {
|
|||
dnsnode = list_first(dnsqueue);
|
||||
while (dnsnode) {
|
||||
dnsdata = lnode_get(dnsnode);
|
||||
if (!ircstrcasecmp(dnsdata->mod_name, modname)) {
|
||||
if (dnsdata->modptr == modptr) {
|
||||
free(dnsdata);
|
||||
lnode2 = list_next(dnsqueue, dnsnode);
|
||||
list_delete(dnsqueue, dnsnode);
|
||||
|
@ -257,8 +235,6 @@ canx_dns(const char *modname) {
|
|||
dns_check_queue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @brief Checks for Completed DNS queries
|
||||
*
|
||||
* Goes through the dnslist of pending queries and calls the callback function for each lookup
|
||||
|
@ -267,9 +243,7 @@ canx_dns(const char *modname) {
|
|||
*
|
||||
* @return Nothing
|
||||
*/
|
||||
|
||||
void
|
||||
do_dns ()
|
||||
void do_dns (void)
|
||||
{
|
||||
lnode_t *dnsnode, *dnsnode1;
|
||||
int status;
|
||||
|
@ -297,12 +271,11 @@ do_dns ()
|
|||
if (status) {
|
||||
nlog (LOG_CRITICAL, "DNS: Baaaad error on adns_check: %s. Please report to NeoStats Group", strerror (status));
|
||||
chanalert (ns_botptr->nick, "Bad Error on DNS lookup. Please check logfile");
|
||||
SET_RUN_LEVEL(dnsdata->modptr);
|
||||
DNSStats.failure++;
|
||||
/* set this so nlog works good */
|
||||
SET_SEGV_INMODULE(dnsdata->mod_name);
|
||||
/* call the callback function with answer set to NULL */
|
||||
dnsdata->callback (dnsdata->data, NULL);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
/* delete from list */
|
||||
dnsnode1 = list_delete (dnslist, dnsnode);
|
||||
dnsnode = list_next (dnslist, dnsnode1);
|
||||
|
@ -311,12 +284,12 @@ do_dns ()
|
|||
lnode_destroy (dnsnode1);
|
||||
break;
|
||||
}
|
||||
nlog (LOG_DEBUG1, "DNS: Calling callback function with data %s for module %s", dnsdata->data, dnsdata->mod_name);
|
||||
nlog (LOG_DEBUG1, "DNS: Calling callback function with data %s for module %s", dnsdata->data, dnsdata->modptr->info->name);
|
||||
DNSStats.success++;
|
||||
SET_SEGV_INMODULE(dnsdata->mod_name);
|
||||
SET_RUN_LEVEL(dnsdata->modptr);
|
||||
/* call the callback function */
|
||||
dnsdata->callback (dnsdata->data, dnsdata->a);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
/* delete from list */
|
||||
dnsnode1 = list_delete (dnslist, dnsnode);
|
||||
dnsnode = list_next (dnslist, dnsnode1);
|
||||
|
@ -375,7 +348,6 @@ void dns_check_queue() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void do_dns_stats_Z(User *u) {
|
||||
numeric (RPL_MEMSTATS, u->nick, "Active DNS queries: %d", (int) list_count(dnslist));
|
||||
numeric (RPL_MEMSTATS, u->nick, "Queued DNS Queries: %d", (int) list_count(dnsqueue));
|
||||
|
|
|
@ -27,6 +27,6 @@
|
|||
int InitDns (void);
|
||||
void do_dns (void);
|
||||
void FiniDns ();
|
||||
void canx_dns(const char *modname);
|
||||
void canx_dns(Module* modptr);
|
||||
void do_dns_stats_Z(User *);
|
||||
#endif /* _DNS_H_ */
|
||||
|
|
|
@ -58,8 +58,10 @@ typedef struct _cfgoption {
|
|||
|
||||
/* general configuration items */
|
||||
struct config {
|
||||
/* log level */
|
||||
unsigned int loglevel;
|
||||
/* debug level */
|
||||
unsigned int debug;
|
||||
unsigned int debuglevel;
|
||||
/* enable recv.log */
|
||||
unsigned int recvlog:1;
|
||||
/* dont load modules on startup */
|
||||
|
|
|
@ -60,8 +60,7 @@ int InitExcludes(void)
|
|||
exclude_list = list_create(-1);
|
||||
if (GetTableData("Exclusions", &row) > 0) {
|
||||
for (i = 0; row[i] != NULL; i++) {
|
||||
e = malloc(sizeof(excludes));
|
||||
bzero(e, sizeof(excludes));
|
||||
e = scalloc(sizeof(excludes));
|
||||
if (GetData((void *)&tmp, CFGSTR, "Exclusions", row[i], "Pattern") > 0) {
|
||||
strlcpy(e->pattern, tmp, MAXHOST);
|
||||
} else {
|
||||
|
|
16
src/ircd.c
16
src/ircd.c
|
@ -207,9 +207,6 @@ SmodeStringToMask(const char* SmodeString, long Smode)
|
|||
int
|
||||
join_bot_to_chan (const char *who, const char *chan, unsigned long chflag)
|
||||
{
|
||||
char savemod[SEGV_INMODULE_BUFSIZE];
|
||||
|
||||
strlcpy(savemod, segv_inmodule, SEGV_INMODULE_BUFSIZE);
|
||||
#ifdef GOTSJOIN
|
||||
ssjoin_cmd(who, chan, chflag);
|
||||
#else
|
||||
|
@ -222,7 +219,6 @@ join_bot_to_chan (const char *who, const char *chan, unsigned long chflag)
|
|||
#endif
|
||||
|
||||
#endif
|
||||
SET_SEGV_INMODULE(savemod);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -627,7 +623,7 @@ void
|
|||
do_version (const char* nick, const char *remoteserver)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
numeric (RPL_VERSION, nick, "%s :%s -> %s %s", me.versionfull, me.name, ns_module_info.build_date, ns_module_info.build_time);
|
||||
numeric (RPL_VERSION, nick, "%s :%s -> %s %s", me.version, me.name, ns_module_info.build_date, ns_module_info.build_time);
|
||||
ModulesVersion (nick, remoteserver);
|
||||
}
|
||||
|
||||
|
@ -649,7 +645,7 @@ do_motd (const char* nick, const char *remoteserver)
|
|||
numeric (ERR_NOMOTD, nick, ":- MOTD file Missing");
|
||||
} else {
|
||||
numeric (RPL_MOTDSTART, nick, ":- %s Message of the Day -", me.name);
|
||||
numeric (RPL_MOTD, nick, ":- %s. Copyright (c) 1999 - 2004 The NeoStats Group", me.versionfull);
|
||||
numeric (RPL_MOTD, nick, ":- %s. Copyright (c) 1999 - 2004 The NeoStats Group", me.version);
|
||||
numeric (RPL_MOTD, nick, ":-");
|
||||
|
||||
while (fgets (buf, sizeof (buf), fp)) {
|
||||
|
@ -679,7 +675,7 @@ do_admin (const char* nick, const char *remoteserver)
|
|||
numeric (ERR_NOADMININFO, nick, "%s :No administrative info available", me.name);
|
||||
} else {
|
||||
numeric (RPL_ADMINME, nick, ":%s :Administrative info", me.name);
|
||||
numeric (RPL_ADMINME, nick, ":%s. Copyright (c) 1999 - 2004 The NeoStats Group", me.versionfull);
|
||||
numeric (RPL_ADMINME, nick, ":%s. Copyright (c) 1999 - 2004 The NeoStats Group", me.version);
|
||||
while (fgets (buf, sizeof (buf), fp)) {
|
||||
buf[strnlen (buf, BUFSIZE) - 1] = 0;
|
||||
numeric (RPL_ADMINLOC1, nick, ":- %s", buf);
|
||||
|
@ -699,7 +695,7 @@ void
|
|||
do_credits (const char* nick, const char *remoteserver)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
numeric (RPL_VERSION, nick, ":- NeoStats %s Credits ", me.versionfull);
|
||||
numeric (RPL_VERSION, nick, ":- NeoStats %s Credits ", me.version);
|
||||
numeric (RPL_VERSION, nick, ":- Now Maintained by Shmad (shmad@neostats.net) and ^Enigma^ (enigma@neostats.net)");
|
||||
numeric (RPL_VERSION, nick, ":- For Support, you can find ^Enigma^ or Shmad at");
|
||||
numeric (RPL_VERSION, nick, ":- irc.irc-chat.net #NeoStats");
|
||||
|
@ -920,8 +916,8 @@ numeric (const int numeric, const char *target, const char *data, ...)
|
|||
void
|
||||
unsupported_cmd(const char* cmd)
|
||||
{
|
||||
chanalert (ns_botptr->nick, "Warning, %s tried to %s which is not supported", ((segv_inmodule[0] != 0)? segv_inmodule : ""), cmd);
|
||||
nlog (LOG_NOTICE, "Warning, %s tried to %s, which is not supported", ((segv_inmodule[0] != 0)? segv_inmodule : ""), cmd);
|
||||
chanalert (ns_botptr->nick, "Warning, %s tried to %s which is not supported", GET_CUR_MODNAME(), cmd);
|
||||
nlog (LOG_NOTICE, "Warning, %s tried to %s, which is not supported", GET_CUR_MODNAME(), cmd);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -66,7 +66,6 @@ extern UserModes user_umodes[];
|
|||
extern UserModes user_smodes[];
|
||||
#endif
|
||||
|
||||
extern const char ircd_version[];
|
||||
extern ircd_server ircd_srv;
|
||||
extern ircd_cmd cmd_list[];
|
||||
extern ChanModes chan_modes[];
|
||||
|
|
58
src/keeper.c
58
src/keeper.c
|
@ -35,12 +35,7 @@ GetConf (void **data, int type, const char *item)
|
|||
char keypath[255];
|
||||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", segv_inmodule, item);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "g/core:/%s", item);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", GET_CUR_MODNAME(), item);
|
||||
|
||||
switch (type) {
|
||||
case CFGSTR:
|
||||
|
@ -76,12 +71,7 @@ GetDir (char *item, char ***data)
|
|||
char keypath[255];
|
||||
char **data1;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", segv_inmodule, item);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "g/core:/%s", item);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", GET_CUR_MODNAME(), item);
|
||||
i = kp_get_dir (keypath, &data1, NULL);
|
||||
if (i == 0) {
|
||||
*data = data1;
|
||||
|
@ -103,12 +93,7 @@ SetConf (void *data, int type, char *item)
|
|||
char keypath[255];
|
||||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", segv_inmodule, item);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "g/core:/%s", item);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", GET_CUR_MODNAME(), item);
|
||||
|
||||
switch (type) {
|
||||
case CFGSTR:
|
||||
|
@ -148,11 +133,7 @@ DelConf (char *item)
|
|||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", segv_inmodule, item);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "g/core:/%s", item);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "g/%s:/%s", GET_CUR_MODNAME(), item);
|
||||
i = kp_recursive_do(keypath, (kp_func) kp_remove, 0, NULL);
|
||||
/* check for errors */
|
||||
if (i != 0) {
|
||||
|
@ -172,11 +153,7 @@ GetData (void **data, int type, const char *table, const char *row, const char *
|
|||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s/%s/%s", segv_inmodule, table, row, field);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "l/core:/%s/%s/%s", table, row, field);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s/%s/%s", GET_CUR_MODNAME(), table, row, field);
|
||||
switch (type) {
|
||||
case CFGSTR:
|
||||
i = kp_get_string (keypath, (char **) *&data);
|
||||
|
@ -212,11 +189,7 @@ GetTableData (char *table, char ***data)
|
|||
char **data1;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s", segv_inmodule, table);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "l/core:/%s", table);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s", GET_CUR_MODNAME(), table);
|
||||
i = kp_get_dir (keypath, &data1, NULL);
|
||||
if (i == 0) {
|
||||
*data = data1;
|
||||
|
@ -238,12 +211,7 @@ SetData (void *data, int type, char *table, char *row, char *field)
|
|||
char keypath[255];
|
||||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s/%s/%s", segv_inmodule, table, row, field);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "l/core:/%s/%s/%s", table, row, field);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s/%s/%s", GET_CUR_MODNAME(), table, row, field);
|
||||
switch (type) {
|
||||
case CFGSTR:
|
||||
i = kp_set_string (keypath, (char *) data);
|
||||
|
@ -282,11 +250,7 @@ DelRow (char *table, char *row)
|
|||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s/%s", segv_inmodule, table, row);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "l/core:/%s/%s", table, row);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s/%s", GET_CUR_MODNAME(), table, row);
|
||||
i = kp_recursive_do(keypath, (kp_func) kp_remove, 0, NULL);
|
||||
/* check for errors */
|
||||
if (i != 0) {
|
||||
|
@ -305,11 +269,7 @@ DelTable (char *table)
|
|||
int i = 0;
|
||||
|
||||
/* determine if its a module setting */
|
||||
if (segv_inmodule[0] != 0) {
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s", segv_inmodule, table);
|
||||
} else {
|
||||
ircsnprintf (keypath, 255, "l/core:/%s", table);
|
||||
}
|
||||
ircsnprintf (keypath, 255, "l/%s:/%s", GET_CUR_MODNAME(), table);
|
||||
i = kp_recursive_do(keypath, (kp_func) kp_remove, 0, NULL);
|
||||
/* check for errors */
|
||||
if (i != 0) {
|
||||
|
|
|
@ -70,8 +70,8 @@ static char *kp_tmpname = NULL;
|
|||
/* String array containing the base path of the different sections */
|
||||
static char *kp_basedirs[KPDB_NUMDBS];
|
||||
|
||||
#define GLOBALDIR "kpconf" /* Default global database path */
|
||||
#define LOCALDIR "kpdata" /* Local database path */
|
||||
#define GLOBALDIR "data/kpconf" /* Default global database path */
|
||||
#define LOCALDIR "data/kpdata" /* Local database path */
|
||||
#define USERSUBDIR "kplang" /* Default user database dir */
|
||||
#define LOCKFILE ":lock:" /* Lock file name */
|
||||
|
||||
|
|
73
src/log.c
73
src/log.c
|
@ -48,6 +48,19 @@ const char *loglevels[10] = {
|
|||
"INSANE"
|
||||
};
|
||||
|
||||
const char *dloglevels[10] = {
|
||||
"DEBUG1",
|
||||
"DEBUG2",
|
||||
"DEBUG3",
|
||||
"DEBUG4",
|
||||
"DEBUG5",
|
||||
"DEBUG6",
|
||||
"DEBUG7",
|
||||
"DEBUG8",
|
||||
"DEBUG9",
|
||||
"DEBUG10",
|
||||
};
|
||||
|
||||
static char log_buf[BUFSIZE];
|
||||
static char log_fmttime[TIMEBUFSIZE];
|
||||
|
||||
|
@ -140,6 +153,42 @@ void make_log_filename(char* modname, char *logname)
|
|||
ircsnprintf (logname, MAXPATH, "logs/%s%s.log", modname, log_fmttime);
|
||||
}
|
||||
|
||||
static void
|
||||
debuglog (const char* time, const char* level, const char *line)
|
||||
{
|
||||
FILE *logfile;
|
||||
|
||||
if ((logfile = fopen ("logs/debug.log", "a")) == NULL)
|
||||
return;
|
||||
if (logfile) {
|
||||
fprintf (logfile, "%s %s %s\n", time, level, line);
|
||||
fclose (logfile);
|
||||
}
|
||||
}
|
||||
|
||||
/** @Configurable logging function
|
||||
*/
|
||||
void
|
||||
dlog (DEBUG_LEVEL level, char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (level <= config.debuglevel) {
|
||||
/* we update me.now here, because some functions might be busy and not call the loop a lot */
|
||||
me.now = time(NULL);
|
||||
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%ld", me.now);
|
||||
strftime (log_fmttime, TIMEBUFSIZE, "%d/%m/%Y[%H:%M:%S]", localtime (&me.now));
|
||||
va_start (ap, fmt);
|
||||
ircvsnprintf (log_buf, BUFSIZE, fmt, ap);
|
||||
va_end (ap);
|
||||
#ifndef DEBUG
|
||||
if (config.foreground)
|
||||
#endif
|
||||
printf ("%s %s - %s\n", dloglevels[level - 1], GET_CUR_MODNAME(), log_buf);
|
||||
debuglog (log_fmttime, dloglevels[level - 1], log_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/** @Configurable logging function
|
||||
*/
|
||||
void
|
||||
|
@ -149,12 +198,8 @@ nlog (LOG_LEVEL level, char *fmt, ...)
|
|||
hnode_t *hn;
|
||||
struct logs_ *logentry;
|
||||
|
||||
if (level <= config.debug) {
|
||||
if (segv_inmodule[0]!= 0) {
|
||||
hn = hash_lookup (logs, segv_inmodule);
|
||||
} else {
|
||||
hn = hash_lookup (logs, CoreLogFileName);
|
||||
}
|
||||
if (level <= config.loglevel) {
|
||||
hn = hash_lookup (logs, GET_CUR_MODNAME());
|
||||
if (hn) {
|
||||
/* we found our log entry */
|
||||
logentry = hnode_get (hn);
|
||||
|
@ -162,7 +207,7 @@ nlog (LOG_LEVEL level, char *fmt, ...)
|
|||
logentry->logfile = fopen (logentry->logname, "a");
|
||||
} else {
|
||||
logentry = malloc (sizeof (struct logs_));
|
||||
strlcpy (logentry->name, segv_inmodule[0] == 0 ? CoreLogFileName : segv_inmodule , MAX_MOD_NAME);
|
||||
strlcpy (logentry->name, GET_CUR_MODNAME() , MAX_MOD_NAME);
|
||||
make_log_filename(logentry->name, logentry->logname);
|
||||
logentry->logfile = fopen (logentry->logname, "a");
|
||||
logentry->flush = 0;
|
||||
|
@ -176,20 +221,24 @@ nlog (LOG_LEVEL level, char *fmt, ...)
|
|||
do_exit (NS_EXIT_NORMAL, NULL);
|
||||
}
|
||||
#endif
|
||||
/* we update me.now here, becase some functions might be busy and not call the loop a lot */
|
||||
/* we update me.now here, because some functions might be busy and not call the loop a lot */
|
||||
me.now = time(NULL);
|
||||
ircsnprintf (me.strnow, STR_TIME_T_SIZE, "%ld", me.now);
|
||||
strftime (log_fmttime, TIMEBUFSIZE, "%d/%m/%Y[%H:%M:%S]", localtime (&me.now));
|
||||
va_start (ap, fmt);
|
||||
ircvsnprintf (log_buf, BUFSIZE, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
fprintf (logentry->logfile, "(%s) %s %s - %s\n", log_fmttime, loglevels[level - 1], segv_inmodule[0] == 0 ? "CORE" : segv_inmodule, log_buf);
|
||||
logentry->flush = 1;
|
||||
if(level <= LOG_INFO) {
|
||||
fprintf (logentry->logfile, "(%s) %s %s - %s\n", log_fmttime, loglevels[level - 1], GET_CUR_MODNAME(), log_buf);
|
||||
logentry->flush = 1;
|
||||
}
|
||||
#ifndef DEBUG
|
||||
if (config.foreground)
|
||||
#endif
|
||||
printf ("%s %s - %s\n", loglevels[level - 1], segv_inmodule[0] == 0 ? "CORE" : segv_inmodule, log_buf);
|
||||
printf ("%s %s - %s\n", loglevels[level - 1], GET_CUR_MODNAME(), log_buf);
|
||||
}
|
||||
if (config.debuglevel) {
|
||||
debuglog (log_fmttime, loglevels[level - 1], log_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
50
src/main.c
50
src/main.c
|
@ -46,7 +46,6 @@
|
|||
#endif
|
||||
|
||||
char segv_location[SEGV_LOCATION_BUFSIZE];
|
||||
char segv_inmodule[SEGV_INMODULE_BUFSIZE];
|
||||
|
||||
/*! Date when we were compiled */
|
||||
const char version_date[] = __DATE__;
|
||||
|
@ -126,6 +125,7 @@ static int InitCore(void)
|
|||
if (InitCurl () != NS_SUCCESS)
|
||||
return NS_FAILURE;
|
||||
InitIrcd ();
|
||||
nlog (LOG_DEBUG1, "Core init successful");
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -145,8 +145,6 @@ main (int argc, char *argv[])
|
|||
|
||||
/* initialise version */
|
||||
strlcpy(me.version, NEOSTATS_VERSION, VERSIONSIZE);
|
||||
strlcpy(me.versionfull, NEOSTATS_VERSION, VERSIONSIZE);
|
||||
strlcat(me.versionfull, ircd_version, VERSIONSIZE);
|
||||
/* get our commandline options */
|
||||
if(get_options (argc, argv)!=NS_SUCCESS)
|
||||
return EXIT_FAILURE;
|
||||
|
@ -159,15 +157,16 @@ main (int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
/* Init run level to NeoStats core */
|
||||
RunModule[0]=&ns_module;
|
||||
/* before we do anything, make sure logging is setup */
|
||||
if(InitLogs () != NS_SUCCESS)
|
||||
return EXIT_FAILURE;
|
||||
/* our crash trace variables */
|
||||
SET_SEGV_LOCATION();
|
||||
CLEAR_SEGV_INMODULE();
|
||||
/* keep quiet if we are told to :) */
|
||||
if (!config.quiet) {
|
||||
printf ("NeoStats %s Loading...\n", me.versionfull);
|
||||
printf ("NeoStats %s Loading...\n", me.version);
|
||||
printf ("-----------------------------------------------\n");
|
||||
printf ("Copyright: NeoStats Group. 2000-2004\n");
|
||||
printf ("Justin Hammond (fish@neostats.net)\n");
|
||||
|
@ -199,7 +198,7 @@ main (int argc, char *argv[])
|
|||
fclose (fp);
|
||||
if (!config.quiet) {
|
||||
printf ("\n");
|
||||
printf ("NeoStats %s Successfully Launched into Background\n", me.versionfull);
|
||||
printf ("NeoStats %s Successfully Launched into Background\n", me.version);
|
||||
printf ("PID: %i - Wrote to %s\n", forked, PID_FILENAME);
|
||||
}
|
||||
return EXIT_SUCCESS; /* parent exits */
|
||||
|
@ -215,7 +214,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
#endif
|
||||
nlog (LOG_NOTICE, "NeoStats started (Version %s).", me.versionfull);
|
||||
nlog (LOG_NOTICE, "NeoStats \"%s\" started.", NEOSTATS_VERSION);
|
||||
|
||||
/* Load modules after we fork. This fixes the load->fork-exit->call
|
||||
_fini problems when we fork */
|
||||
|
@ -238,31 +237,34 @@ static int
|
|||
get_options (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int dbg;
|
||||
int level;
|
||||
|
||||
/* set some defaults first */
|
||||
#ifdef DEBUG
|
||||
config.debug = 10;
|
||||
config.loglevel = LOG_INFO;
|
||||
config.debuglevel = DEBUG10;
|
||||
config.foreground = 1;
|
||||
#else
|
||||
config.debug = 5;
|
||||
config.loglevel = LOG_NORMAL;
|
||||
config.debuglevel = 0;
|
||||
config.foreground = 0;
|
||||
#endif
|
||||
|
||||
while ((c = getopt (argc, argv, "hvrd:nqf")) != -1) {
|
||||
while ((c = getopt (argc, argv, "hvrd:l:nqf")) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
printf ("NeoStats: Usage: \"neostats [options]\"\n");
|
||||
printf (" -h (Show this screen)\n");
|
||||
printf (" -v (Show version number)\n");
|
||||
printf (" -r (Enable recv.log)\n");
|
||||
printf (" -d 1-10 (Enable debugging output 1= lowest, 10 = highest)\n");
|
||||
printf (" -d 1-10 (Debug log output level 1= lowest, 10 = highest)\n");
|
||||
printf (" -l 1-10 (Log output level 1= lowest, 6 = highest)\n");
|
||||
printf (" -n (Do not load any modules on startup)\n");
|
||||
printf (" -q (Quiet start - for cron scripts)\n");
|
||||
printf (" -f (Do not fork into background\n");
|
||||
return NS_FAILURE;
|
||||
case 'v':
|
||||
printf ("NeoStats Version %s\n", me.versionfull);
|
||||
printf ("NeoStats Version %s\n", me.version);
|
||||
printf ("Compiled: %s at %s\n", ns_module_info.build_date, ns_module_info.build_time);
|
||||
printf ("Flag after version number indicates what IRCd NeoStats is compiled for:\n");
|
||||
printf ("(U31)- Unreal 3.1.x IRCd\n");
|
||||
|
@ -279,22 +281,31 @@ get_options (int argc, char **argv)
|
|||
printf ("\nNeoStats: http://www.neostats.net\n");
|
||||
return NS_FAILURE;
|
||||
case 'r':
|
||||
printf ("recv.log enabled. Watch your DiskSpace\n");
|
||||
printf ("recv.log enabled. Watch your disk space\n");
|
||||
config.recvlog = 1;
|
||||
break;
|
||||
case 'd':
|
||||
printf ("debug.log enabled. Watch your disk space\n");
|
||||
level = atoi (optarg);
|
||||
if ((level > DEBUGMAX - 1) || (level < 1)) {
|
||||
printf ("Invalid debug level %d\n", level);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
config.debuglevel = level;
|
||||
break;
|
||||
case 'n':
|
||||
config.modnoload = 1;
|
||||
break;
|
||||
case 'q':
|
||||
config.quiet = 1;
|
||||
break;
|
||||
case 'd':
|
||||
dbg = atoi (optarg);
|
||||
if ((dbg > 10) || (dbg < 1)) {
|
||||
printf ("Invalid Debug Level %d\n", dbg);
|
||||
case 'l':
|
||||
level = atoi (optarg);
|
||||
if ((level > LOG_LEVELMAX - 1) || (level < 1)) {
|
||||
printf ("Invalid level %d\n", level);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
config.debug = dbg;
|
||||
config.loglevel = level;
|
||||
break;
|
||||
case 'f':
|
||||
config.foreground = 1;
|
||||
|
@ -348,6 +359,7 @@ do_exit (NS_EXIT_TYPE exitcode, char* quitmsg)
|
|||
sleep(1);
|
||||
/* now free up the users and servers memory */
|
||||
FiniUsers();
|
||||
FiniChannels();
|
||||
FiniServers();
|
||||
FiniBans();
|
||||
FiniDns();
|
||||
|
|
109
src/modules.c
109
src/modules.c
|
@ -34,6 +34,8 @@
|
|||
*
|
||||
*/
|
||||
static Module *ModList[NUM_MODULES];
|
||||
Module* RunModule[10];
|
||||
int RunLevel = 0;
|
||||
|
||||
int del_all_bot_cmds(Bot* bot_ptr);
|
||||
|
||||
|
@ -78,7 +80,7 @@ void *display_module_builddate (void *tbl, char *col, char *sql, void *row)
|
|||
|
||||
void *display_core_info (void *tbl, char *col, char *sql, void *row)
|
||||
{
|
||||
ircsnprintf(sqlbuf, BUFSIZE, "%s", me.versionfull);
|
||||
ircsnprintf(sqlbuf, BUFSIZE, "%s", me.version);
|
||||
return sqlbuf;
|
||||
}
|
||||
|
||||
|
@ -167,8 +169,10 @@ InitModules ()
|
|||
{
|
||||
SET_SEGV_LOCATION();
|
||||
mh = hash_create (NUM_MODULES, 0, 0);
|
||||
if(!mh)
|
||||
if(!mh) {
|
||||
nlog (LOG_CRITICAL, "Unable to create module hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef SQLSRV
|
||||
/* add the module hash to the sql library */
|
||||
|
@ -211,9 +215,9 @@ SendModuleEvent (Event event, CmdParams* cmdparams, Bot* bot)
|
|||
nlog (LOG_DEBUG1, "Running module %s with event %d", module_ptr->info->name, event);
|
||||
SET_SEGV_LOCATION();
|
||||
if (setjmp (sigvbuf) == 0) {
|
||||
SET_SEGV_INMODULE(module_ptr->info->name);
|
||||
SET_RUN_LEVEL(module_ptr);
|
||||
ev_list->function (cmdparams);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
} else {
|
||||
nlog (LOG_CRITICAL, "setjmp() Failed, Can't call Module %s\n", module_ptr->info->name);
|
||||
}
|
||||
|
@ -254,9 +258,9 @@ SendAllModuleEvent (Event event, CmdParams* cmdparams)
|
|||
nlog (LOG_DEBUG1, "Running module %s with event %d", module_ptr->info->name, event);
|
||||
SET_SEGV_LOCATION();
|
||||
if (setjmp (sigvbuf) == 0) {
|
||||
SET_SEGV_INMODULE(module_ptr->info->name);
|
||||
SET_RUN_LEVEL(module_ptr);
|
||||
ev_list->function (cmdparams);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
} else {
|
||||
nlog (LOG_CRITICAL, "setjmp() Failed, Can't call Module %s\n", module_ptr->info->name);
|
||||
}
|
||||
|
@ -415,14 +419,14 @@ load_module (char *modfilename, User * u)
|
|||
} else {
|
||||
int err;
|
||||
SET_SEGV_LOCATION();
|
||||
SET_SEGV_INMODULE(mod_ptr->info->name);
|
||||
SET_RUN_LEVEL(mod_ptr);
|
||||
err = (*ModInit) (mod_ptr);
|
||||
if (err < 1) {
|
||||
nlog (LOG_NORMAL, "Unable to load module: %s. See %s.log for further information.", mod_ptr->info->name, mod_ptr->info->name);
|
||||
unload_module(mod_ptr->info->name, NULL);
|
||||
return NULL;
|
||||
}
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
SET_SEGV_LOCATION();
|
||||
}
|
||||
|
||||
|
@ -432,9 +436,9 @@ load_module (char *modfilename, User * u)
|
|||
if (event_ptr->event == EVENT_ONLINE) {
|
||||
AddStringToList (&av, me.s->name, &ac);
|
||||
SET_SEGV_LOCATION();
|
||||
SET_SEGV_INMODULE(mod_ptr->info->name);
|
||||
SET_RUN_LEVEL(mod_ptr);
|
||||
event_ptr->function (NULL);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
SET_SEGV_LOCATION();
|
||||
free (av);
|
||||
break;
|
||||
|
@ -449,72 +453,6 @@ load_module (char *modfilename, User * u)
|
|||
return mod_ptr;
|
||||
}
|
||||
|
||||
/** @brief
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int
|
||||
get_dl_handle (const char *mod_name)
|
||||
{
|
||||
Module *mod_ptr;
|
||||
hnode_t *mn;
|
||||
|
||||
mn = hash_lookup (mh, mod_name);
|
||||
if (mn) {
|
||||
mod_ptr = hnode_get (mn);
|
||||
return (int) mod_ptr->dl_handle;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @brief
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int
|
||||
get_mod_num (const char *mod_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_MODULES; i++) {
|
||||
if (ModList[i] != NULL) {
|
||||
if (!ircstrcasecmp (ModList[i]->info->name, mod_name)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if we get here, it wasn't found */
|
||||
nlog (LOG_DEBUG1, "get_mod_num: can't find %s in module number list", mod_name);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
/** @brief
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Module *
|
||||
get_mod_ptr (const char *mod_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_MODULES; i++) {
|
||||
if (ModList[i] != NULL) {
|
||||
if (!ircstrcasecmp (ModList[i]->info->name, mod_name)) {
|
||||
return ModList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if we get here, it wasn't found */
|
||||
nlog (LOG_DEBUG1, "get_mod_ptr: can't find %s in module number list", mod_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** @brief
|
||||
*
|
||||
* @param
|
||||
|
@ -534,7 +472,7 @@ list_modules (CmdParams* cmdparams)
|
|||
mod_ptr = hnode_get (mn);
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Module: %s (%s)", mod_ptr->info->name, mod_ptr->info->version);
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Module Description: %s", mod_ptr->info->description);
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Module Number: %d", get_mod_num (mod_ptr->info->name));
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Module Number: %d", mod_ptr->modnum);
|
||||
}
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "End of Module List");
|
||||
return 0;
|
||||
|
@ -564,11 +502,11 @@ unload_module (const char *modname, User * u)
|
|||
}
|
||||
return NS_FAILURE;
|
||||
}
|
||||
i = get_mod_num (modname);
|
||||
mod_ptr = hnode_get (modnode);
|
||||
i = mod_ptr->modnum;
|
||||
chanalert (ns_botptr->nick, "Unloading module %s", modname);
|
||||
/* canx any DNS queries used by this module */
|
||||
canx_dns (modname);
|
||||
canx_dns (mod_ptr);
|
||||
/* Delete any timers used by this module */
|
||||
del_timers (mod_ptr);
|
||||
/* Delete any sockets used by this module */
|
||||
|
@ -582,9 +520,9 @@ unload_module (const char *modname, User * u)
|
|||
/* call ModFini (replacement for library __fini() call */
|
||||
ModFini = ns_dlsym ((int *) mod_ptr->dl_handle, "ModFini");
|
||||
if (ModFini) {
|
||||
SET_SEGV_INMODULE(modname);
|
||||
SET_RUN_LEVEL(mod_ptr);
|
||||
(*ModFini) ();
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
}
|
||||
/* Delete any bots used by this module. Done after ModFini, so the bot
|
||||
* can still send messages during ModFini
|
||||
|
@ -592,11 +530,11 @@ unload_module (const char *modname, User * u)
|
|||
del_bots (mod_ptr);
|
||||
hnode_destroy (modnode);
|
||||
/* Close module */
|
||||
SET_SEGV_INMODULE(modname);
|
||||
SET_RUN_LEVEL(mod_ptr);
|
||||
#ifndef VALGRIND
|
||||
ns_dlclose (mod_ptr->dl_handle);
|
||||
#endif
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
/* free the module number */
|
||||
if (i >= 0) {
|
||||
nlog (LOG_DEBUG1, "Free %d from Module Numbers", i);
|
||||
|
@ -635,11 +573,11 @@ void unload_modules(void)
|
|||
* @return
|
||||
*/
|
||||
int
|
||||
ModuleConfig(Module* moduleptr, bot_setting* set_ptr)
|
||||
ModuleConfig(bot_setting* set_ptr)
|
||||
{
|
||||
char *temp = NULL;
|
||||
|
||||
SET_SEGV_INMODULE(moduleptr->info->name);
|
||||
SET_SEGV_LOCATION();
|
||||
while(set_ptr->option)
|
||||
{
|
||||
switch(set_ptr->type) {
|
||||
|
@ -681,6 +619,5 @@ ModuleConfig(Module* moduleptr, bot_setting* set_ptr)
|
|||
}
|
||||
set_ptr++;
|
||||
}
|
||||
CLEAR_SEGV_INMODULE();
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -28,16 +28,12 @@ extern jmp_buf sigvbuf;
|
|||
|
||||
int InitModules (void);
|
||||
int FiniModules (void);
|
||||
void SendAllModuleEvent (Event event, CmdParams* cmdparams);
|
||||
void SendModuleEvent (Event event, CmdParams* cmdparams, Bot* bot);
|
||||
Module *load_module (char *path, User * u);
|
||||
int unload_module (const char *module_name, User * u);
|
||||
int list_modules (CmdParams* cmdparams);
|
||||
int get_dl_handle (const char *mod_name);
|
||||
int get_mod_num (const char *mod_name);
|
||||
Module *get_mod_ptr (const char *mod_name);
|
||||
void unload_modules(void);
|
||||
|
||||
int list_modules (CmdParams* cmdparams);
|
||||
void ModulesVersion (const char* nick, const char *remoteserver);
|
||||
void SendAllModuleEvent (Event event, CmdParams* cmdparams);
|
||||
void SendModuleEvent (Event event, CmdParams* cmdparams, Bot* bot);
|
||||
|
||||
#endif /* _MODULES_H_ */
|
||||
|
|
|
@ -110,7 +110,7 @@ static Module* cs_module;
|
|||
|
||||
ModuleInfo module_info = {
|
||||
"ConnectServ",
|
||||
"Connection monitoring service",
|
||||
"Connection monitoring service",
|
||||
ns_copyright,
|
||||
cs_about,
|
||||
NEOSTATS_VERSION,
|
||||
|
@ -132,7 +132,7 @@ static bot_setting cs_settings[]=
|
|||
{"ALTNICK", &cs_botinfo.altnick,SET_TYPE_NICK, 0, MAXNICK, NS_ULEVEL_ADMIN, "AltNick", NULL, ns_help_set_altnick, NULL, (void*)"ConnectServ" },
|
||||
{"USER", &cs_botinfo.user, SET_TYPE_USER, 0, MAXUSER, NS_ULEVEL_ADMIN, "User", NULL, ns_help_set_user, NULL, (void*)"CS" },
|
||||
{"HOST", &cs_botinfo.host, SET_TYPE_HOST, 0, MAXHOST, NS_ULEVEL_ADMIN, "Host", NULL, ns_help_set_host, NULL, (void*)"" },
|
||||
{"REALNAME", &cs_botinfo.realname,SET_TYPE_REALNAME, 0, MAXREALNAME, NS_ULEVEL_ADMIN, "RealName",NULL, ns_help_set_realname, NULL, (void*)"" },
|
||||
{"REALNAME", &cs_botinfo.realname,SET_TYPE_REALNAME, 0, MAXREALNAME, NS_ULEVEL_ADMIN, "RealName",NULL, ns_help_set_realname, NULL, (void*)"Connection monitoring service" },
|
||||
{"SIGNWATCH", &cs_cfg.sign_watch, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, "SignWatch", NULL, cs_help_set_signwatch, NULL, (void*)1 },
|
||||
{"KILLWATCH", &cs_cfg.kill_watch, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, "KillWatch", NULL, cs_help_set_killwatch, NULL, (void*)1 },
|
||||
{"MODEWATCH", &cs_cfg.mode_watch, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, "ModeWatch", NULL, cs_help_set_modewatch, NULL, (void*)1 },
|
||||
|
@ -160,7 +160,7 @@ ModuleEvent module_events[] = {
|
|||
int ModInit(Module* mod_ptr)
|
||||
{
|
||||
cs_module = mod_ptr;
|
||||
ModuleConfig(cs_module, cs_settings);
|
||||
ModuleConfig(cs_settings);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,8 @@ void ModFini()
|
|||
|
||||
static int cs_event_online(CmdParams* cmdparams)
|
||||
{
|
||||
cs_bot = init_bot (cs_module, &cs_botinfo, services_bot_modes, BOT_FLAG_RESTRICT_OPERS|BOT_FLAG_DEAF,
|
||||
cs_commands, cs_settings);
|
||||
cs_bot = init_bot (&cs_botinfo, services_bot_modes,
|
||||
BOT_FLAG_RESTRICT_OPERS|BOT_FLAG_DEAF, cs_commands, cs_settings);
|
||||
cs_online = 1;
|
||||
return 1;
|
||||
};
|
||||
|
|
|
@ -242,9 +242,9 @@ static int hs_event_signon(CmdParams* cmdparams)
|
|||
|
||||
static int hs_event_online(CmdParams* cmdparams)
|
||||
{
|
||||
hs_bot = init_bot(hs_module, &hs_botinfo, services_bot_modes, BOT_FLAG_DEAF,
|
||||
hs_bot = init_bot(&hs_botinfo, services_bot_modes, BOT_FLAG_DEAF,
|
||||
hs_commands, hs_settings);
|
||||
add_timer (hs_module, CleanupHosts, "CleanupHosts", 7200);
|
||||
add_timer (CleanupHosts, "CleanupHosts", 7200);
|
||||
LoadHosts();
|
||||
return 1;
|
||||
};
|
||||
|
@ -268,7 +268,7 @@ int ModInit(Module* mod_ptr)
|
|||
nlog(LOG_CRITICAL, "Error, can't create vhosts hash");
|
||||
return -1;
|
||||
}
|
||||
ModuleConfig(hs_module, hs_settings);
|
||||
ModuleConfig(hs_settings);
|
||||
LoadConfig();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -31,14 +31,13 @@ static int ls_kiss(CmdParams* cmdparams);
|
|||
static int ls_tonsil(CmdParams* cmdparams);
|
||||
static int ls_hug(CmdParams* cmdparams);
|
||||
static int ls_admirer(CmdParams* cmdparams);
|
||||
static int ls_choco(CmdParams* cmdparams);
|
||||
static int ls_chocolate(CmdParams* cmdparams);
|
||||
static int ls_candy(CmdParams* cmdparams);
|
||||
static int ls_lovenote(CmdParams* cmdparams);
|
||||
static int ls_apology(CmdParams* cmdparams);
|
||||
static int ls_thankyou(CmdParams* cmdparams);
|
||||
|
||||
static Bot *ls_bot;
|
||||
static Module* ls_module;
|
||||
|
||||
ModuleInfo module_info = {
|
||||
"LoveServ",
|
||||
|
@ -69,7 +68,7 @@ static bot_cmd ls_commands[]=
|
|||
{"TONSIL", ls_tonsil, 1, 0, ls_help_tonsil, ls_help_tonsil_oneline },
|
||||
{"HUG", ls_hug, 1, 0, ls_help_hug, ls_help_hug_oneline },
|
||||
{"ADMIRER", ls_admirer, 1, 0, ls_help_admirer, ls_help_admirer_oneline },
|
||||
{"CHOCOLATE", ls_choco, 1, 0, ls_help_chocolate, ls_help_chocolate_oneline },
|
||||
{"CHOCOLATE", ls_chocolate, 1, 0, ls_help_chocolate, ls_help_chocolate_oneline },
|
||||
{"CANDY", ls_candy, 1, 0, ls_help_candy, ls_help_candy_oneline },
|
||||
{"LOVENOTE", ls_lovenote, 2, 0, ls_help_lovenote, ls_help_lovenote_oneline },
|
||||
{"APOLOGY", ls_apology, 2, 0, ls_help_apology, ls_help_apology_oneline },
|
||||
|
@ -88,7 +87,8 @@ static bot_setting ls_settings[]=
|
|||
|
||||
static int ls_event_online(CmdParams* cmdparams)
|
||||
{
|
||||
ls_bot = init_bot(ls_module, &ls_botinfo, services_bot_modes, BOT_FLAG_DEAF, ls_commands, ls_settings);
|
||||
ls_bot = init_bot(&ls_botinfo, services_bot_modes,
|
||||
BOT_FLAG_DEAF, ls_commands, ls_settings);
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
@ -99,7 +99,7 @@ ModuleEvent module_events[] = {
|
|||
|
||||
int ModInit(Module* mod_ptr)
|
||||
{
|
||||
ModuleConfig(ls_module, ls_settings);
|
||||
ModuleConfig(ls_settings);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ static int ls_rose(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ls_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick, "Your rose has been sent to %s!",
|
||||
target_nick);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"Rose has been sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s has sent you this beautiful rose! 3--<--<--<{4@",
|
||||
cmdparams->source.user->nick);
|
||||
|
@ -133,7 +133,8 @@ static int ls_kiss(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ls_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick, "You have virtually kissed %s!", target_nick);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"You have virtually kissed %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick, "%s has virtually kissed you!", cmdparams->source.user->nick);
|
||||
return 1;
|
||||
}
|
||||
|
@ -148,7 +149,7 @@ static int ls_tonsil(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"You have virtually tonsilly kissed %s!", target_nick);
|
||||
"You have virtually tonsil kissed %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s would like to send a SLoW..LoNG..DeeP..PeNeTRaTiNG..ToNSiL-TiCKLiNG.. HaiR STRaiGHTeNiNG..Toe-CuRLiNG..NeRVe-JaNGLiNG..LiFe-aLTeRiNG.. FaNTaSY-CauSiNG..i JuST SaW GoD!..GoSH, DiD MY CLoTHeS FaLL oFF?.. YeS, i'M GLaD i CaMe oN iRC..KiSS oN Da LiPS!!!",
|
||||
cmdparams->source.user->nick);
|
||||
|
@ -164,7 +165,8 @@ static int ls_hug(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ls_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick, "%s has received your hug! :)", target_nick);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"You have hugged %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick, "%s has sent you a *BIG WARM HUG*!", cmdparams->source.user->nick);
|
||||
return 1;
|
||||
}
|
||||
|
@ -178,12 +180,13 @@ static int ls_admirer(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ls_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick, "Secret admirer sent to %s :)", target_nick);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"Secret admirer sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick, "You have a secret admirer! ;)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ls_choco(CmdParams* cmdparams)
|
||||
static int ls_chocolate(CmdParams* cmdparams)
|
||||
{
|
||||
char *target_nick;
|
||||
|
||||
|
@ -193,7 +196,7 @@ static int ls_choco(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"A box of cholocates has been sent to %s :)", target_nick);
|
||||
"Cholocates sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s would like you to have this YUMMY box of chocolates!",
|
||||
cmdparams->source.user->nick);
|
||||
|
@ -210,7 +213,7 @@ static int ls_candy(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"A bag of yummy heart shaped candies has been sent to %s :)", target_nick);
|
||||
"Candy sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s would like you to have this big YUMMY bag of heart shaped candies!",
|
||||
cmdparams->source.user->nick);
|
||||
|
@ -229,9 +232,10 @@ static int ls_lovenote(CmdParams* cmdparams)
|
|||
}
|
||||
message = joinbuf(cmdparams->av, cmdparams->ac, 1);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"Your lovenote to %s has been sent! :)", target_nick);
|
||||
"Love note sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s has sent you a LoveNote which reads: \2%s\2", cmdparams->source.user->nick, message);
|
||||
"%s has sent you a love note which reads: \2%s\2",
|
||||
cmdparams->source.user->nick, message);
|
||||
free(message);
|
||||
return 1;
|
||||
}
|
||||
|
@ -247,8 +251,8 @@ static int ls_apology(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
message = joinbuf(cmdparams->av, cmdparams->ac, 1);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick, "Your apology has been sent to %s",
|
||||
target_nick);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"Apology sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s is sorry, and would like to apologise for \2%s\2",
|
||||
cmdparams->source.user->nick, message);
|
||||
|
@ -267,8 +271,8 @@ static int ls_thankyou(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
message = joinbuf(cmdparams->av, cmdparams->ac, 1);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick, "Your Thank You has been sent to %s",
|
||||
target_nick);
|
||||
prefmsg(cmdparams->source.user->nick, ls_bot->nick,
|
||||
"Thank you sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick, "%s wishes to thank you for \2%s\2",
|
||||
cmdparams->source.user->nick, message);
|
||||
free(message);
|
||||
|
|
|
@ -35,7 +35,6 @@ static BotInfo ms_botinfo =
|
|||
"",
|
||||
"Network morale service",
|
||||
};
|
||||
static Module* ms_module;
|
||||
|
||||
static int ms_hail(CmdParams* cmdparams);
|
||||
static int ms_ode(CmdParams* cmdparams);
|
||||
|
@ -61,14 +60,14 @@ ModuleInfo module_info = {
|
|||
|
||||
static bot_cmd ms_commands[]=
|
||||
{
|
||||
{"HAIL", ms_hail, 2, 0, ms_help_hail, ms_help_hail_oneline },
|
||||
{"ODE", ms_ode, 2, 0, ms_help_ode, ms_help_ode_oneline },
|
||||
{"LAPDANCE", ms_lapdance, 1, 0, ms_help_lapdance, ms_help_lapdance_oneline },
|
||||
{"POEM", ms_poem, 2, 0, ms_help_poem, ms_help_poem_oneline },
|
||||
{"REDNECK", ms_redneck, 1, 0, ms_help_redneck, ms_help_redneck_oneline },
|
||||
{"CHEERUP", ms_cheerup, 1, 0, ms_help_cheerup, ms_help_cheerup_oneline },
|
||||
{"BEHAPPY", ms_behappy, 1, 0, ms_help_behappy, ms_help_behappy_oneline },
|
||||
{"WONDERFUL", ms_wonderful, 1, 0, ms_help_wonderful, ms_help_wonderful_oneline },
|
||||
{"HAIL", ms_hail, 2, 0, ms_help_hail, ms_help_hail_oneline },
|
||||
{"ODE", ms_ode, 2, 0, ms_help_ode, ms_help_ode_oneline },
|
||||
{"POEM", ms_poem, 2, 0, ms_help_poem, ms_help_poem_oneline },
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -83,7 +82,8 @@ static bot_setting ms_settings[]=
|
|||
|
||||
static int ms_event_online(CmdParams* cmdparams)
|
||||
{
|
||||
ms_bot = init_bot (ms_module, &ms_botinfo, services_bot_modes, BOT_FLAG_DEAF, ms_commands, ms_settings);
|
||||
ms_bot = init_bot (&ms_botinfo, services_bot_modes,
|
||||
BOT_FLAG_DEAF, ms_commands, ms_settings);
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ ModuleEvent module_events[] = {
|
|||
|
||||
int ModInit(Module* mod_ptr)
|
||||
{
|
||||
ModuleConfig(ms_module, ms_settings);
|
||||
ModuleConfig(ms_settings);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -133,6 +133,8 @@ static int ms_lapdance(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ms_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ms_bot->nick,
|
||||
"Lap dance sent to %s!", target_nick);
|
||||
prefmsg(target_nick, ms_bot->nick,
|
||||
"*%s Seductively walks up to %s and gives %s a sly look*",
|
||||
ms_bot->nick, target_nick, target_nick);
|
||||
|
@ -157,7 +159,7 @@ static int ms_ode(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ms_bot->nick,
|
||||
"Your ODE to %s has been sent to %s!", about_nick, target_nick);
|
||||
"Ode to %s sent to %s!", about_nick, target_nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "Courtesy of your friend %s:", cmdparams->source.user->nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "*recites*");
|
||||
prefmsg(target_nick, ms_bot->nick, "How I wish to be a %s,", about_nick);
|
||||
|
@ -181,7 +183,7 @@ static int ms_poem(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ms_bot->nick,
|
||||
"Your POEM about %s has been sent to %s!", about_nick, target_nick);
|
||||
"Poem about %s sent to %s!", about_nick, target_nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "Courtesy of your friend %s:", cmdparams->source.user->nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "*recites*");
|
||||
prefmsg(target_nick, ms_bot->nick, "I wish I was a %s,", about_nick);
|
||||
|
@ -203,7 +205,7 @@ static int ms_redneck(CmdParams* cmdparams)
|
|||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ms_bot->nick,
|
||||
"Your redneck message has been sent to %s!", target_nick);
|
||||
"Redneck message sent to %s!", target_nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "Courtesy of your friend %s:", cmdparams->source.user->nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "*recites*");
|
||||
prefmsg(target_nick, ms_bot->nick,
|
||||
|
@ -237,6 +239,8 @@ static int ms_behappy(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ms_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ms_bot->nick,
|
||||
"Behappy sent to %s!", target_nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "%s thinks that you're a little sad.....",
|
||||
cmdparams->source.user->nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "*starts singing*");
|
||||
|
@ -291,7 +295,10 @@ static int ms_wonderful(CmdParams* cmdparams)
|
|||
if(!is_target_valid(ms_bot->nick, cmdparams->source.user, target_nick)) {
|
||||
return 0;
|
||||
}
|
||||
prefmsg(target_nick, ms_bot->nick, "Courtesy of your friend %s:", cmdparams->source.user->nick);
|
||||
prefmsg(cmdparams->source.user->nick, ms_bot->nick,
|
||||
"wonderful sent to %s!", target_nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "Courtesy of your friend %s:",
|
||||
cmdparams->source.user->nick);
|
||||
prefmsg(target_nick, ms_bot->nick, "*starts singing*");
|
||||
prefmsg(target_nick, ms_bot->nick,
|
||||
"So excuse me forgetting but these things I do");
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** Portions Copyright (c) 1999 Johnathan George net@lite.net
|
||||
**
|
||||
** 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 2 of the License, or
|
||||
|
@ -27,39 +25,19 @@
|
|||
|
||||
#include "statserv.h"
|
||||
|
||||
/* define this if you want the old database format.... but beware, its slow */
|
||||
#undef OLDDATABASE
|
||||
|
||||
|
||||
int SaveStats()
|
||||
void SaveServerStats(void)
|
||||
{
|
||||
SStats *s;
|
||||
CStats *c;
|
||||
hnode_t *sn;
|
||||
lnode_t *cn;
|
||||
hscan_t ss;
|
||||
int count, limit;
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (StatServ.newdb == 1) {
|
||||
chanalert(ss_bot->nick, "Enabling Record yelling!");
|
||||
StatServ.newdb = 0;
|
||||
}
|
||||
|
||||
if (StatServ.shutdown == 1) {
|
||||
chanalert(ss_bot->nick, "Saving StatServ Database. this *could* take a while");
|
||||
}
|
||||
/* first thing we do is clear the old database */
|
||||
/* clear the old database */
|
||||
DelTable("ServerStats");
|
||||
//DelTable("ChanStats");
|
||||
DelTable("NetStats");
|
||||
|
||||
/* ok, run through the server stats, and save them */
|
||||
/* run through stats and save them */
|
||||
hash_scan_begin(&ss, Shead);
|
||||
while ((sn = hash_scan_next(&ss))) {
|
||||
s = hnode_get(sn);
|
||||
nlog(LOG_DEBUG1,
|
||||
"Writing statistics to database for %s", s->name);
|
||||
nlog(LOG_DEBUG1, "Writing statistics to database for %s", s->name);
|
||||
SetData((void *)s->numsplits, CFGINT, "ServerStats", s->name, "Splits");
|
||||
SetData((void *)s->maxusers, CFGINT, "ServerStats", s->name, "MaxUsers");
|
||||
SetData((void *)s->t_maxusers, CFGINT, "ServerStats", s->name, "MaxUsersTime");
|
||||
|
@ -70,19 +48,32 @@ int SaveStats()
|
|||
SetData((void *)s->totusers, CFGINT, "ServerStats", s->name, "TotalUsers");
|
||||
SetData((void *)s->maxopers, CFGINT, "ServerStats", s->name, "MaxOpers");
|
||||
SetData((void *)s->t_maxopers, CFGINT, "ServerStats", s->name, "MaxOpersTime");
|
||||
if (StatServ.shutdown == 1) {
|
||||
free(s);
|
||||
hash_scan_delete(Shead, sn);
|
||||
hnode_destroy(sn);
|
||||
}
|
||||
|
||||
}
|
||||
if (StatServ.shutdown == 1) {
|
||||
hash_destroy(Shead);
|
||||
}
|
||||
}
|
||||
|
||||
void SaveNetworkStats(void)
|
||||
{
|
||||
/* clear the old database */
|
||||
DelTable("NetStats");
|
||||
/* run through stats and save them */
|
||||
SetData((void *)stats_network.maxopers, CFGINT, "NetStats", "Global", "MaxOpers");
|
||||
SetData((void *)stats_network.maxusers, CFGINT, "NetStats", "Global", "MaxUsers");
|
||||
SetData((void *)stats_network.maxservers, CFGINT, "NetStats", "Global", "MaxServers");
|
||||
SetData((void *)stats_network.t_maxopers, CFGINT, "NetStats", "Global", "MaxOpersTime");
|
||||
SetData((void *)stats_network.t_maxusers, CFGINT, "NetStats", "Global", "MaxUsersTime");
|
||||
SetData((void *)stats_network.t_maxservers, CFGINT, "NetStats", "Global", "MaxServersTime");
|
||||
SetData((void *)stats_network.totusers, CFGINT, "NetStats", "Global", "TotalUsers");
|
||||
SetData((void *)stats_network.maxchans, CFGINT, "NetStats", "Global", "MaxChans");
|
||||
SetData((void *)stats_network.t_chans, CFGINT, "NetStats", "Global", "MaxChansTime");
|
||||
}
|
||||
|
||||
void SaveChanStats(void)
|
||||
{
|
||||
CStats *c;
|
||||
lnode_t *cn;
|
||||
int limit;
|
||||
int count = 0;
|
||||
|
||||
/* ok, Now Channel Stats */
|
||||
count = 0;
|
||||
/* we want to only do 25% each progressive save */
|
||||
limit = (list_count(Chead)/4);
|
||||
cn = list_first(Chead);
|
||||
|
@ -100,54 +91,25 @@ int SaveStats()
|
|||
}
|
||||
count++;
|
||||
}
|
||||
/* we need to squeze as much performance out of this as we can */
|
||||
#if 0
|
||||
nlog(LOG_DEBUG1,
|
||||
"Writting Statistics to database for %s (%d)", c->name, count);
|
||||
#endif
|
||||
save_chan(c);
|
||||
/* if we are shuting down, clean up */
|
||||
if (StatServ.shutdown == 1) {
|
||||
free(c);
|
||||
}
|
||||
cn = list_next(Chead, cn);
|
||||
}
|
||||
if (StatServ.shutdown == 1) {
|
||||
list_destroy_nodes(Chead);
|
||||
}
|
||||
}
|
||||
|
||||
/* and finally, the network data */
|
||||
|
||||
SetData((void *)stats_network.maxopers, CFGINT, "NetStats", "Global", "MaxOpers");
|
||||
SetData((void *)stats_network.maxusers, CFGINT, "NetStats", "Global", "MaxUsers");
|
||||
SetData((void *)stats_network.maxservers, CFGINT, "NetStats", "Global", "MaxServers");
|
||||
SetData((void *)stats_network.t_maxopers, CFGINT, "NetStats", "Global", "MaxOpersTime");
|
||||
SetData((void *)stats_network.t_maxusers, CFGINT, "NetStats", "Global", "MaxUsersTime");
|
||||
SetData((void *)stats_network.t_maxservers, CFGINT, "NetStats", "Global", "MaxServersTime");
|
||||
SetData((void *)stats_network.totusers, CFGINT, "NetStats", "Global", "TotalUsers");
|
||||
SetData((void *)stats_network.maxchans, CFGINT, "NetStats", "Global", "MaxChans");
|
||||
SetData((void *)stats_network.t_chans, CFGINT, "NetStats", "Global", "MaxChansTime");
|
||||
if (StatServ.shutdown == 1) {
|
||||
chanalert(ss_bot->nick, "Done");
|
||||
}
|
||||
int SaveStats(void)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
SaveServerStats();
|
||||
SaveChanStats();
|
||||
SaveNetworkStats();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void LoadStats() {
|
||||
SStats *s;
|
||||
char **row;
|
||||
|
||||
hnode_t *sn;
|
||||
int count;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
Chead = list_create(SS_CHAN_SIZE);
|
||||
Shead = hash_create(S_TABLE_SIZE, 0, 0);
|
||||
|
||||
int LoadNetworkStats(void)
|
||||
{
|
||||
if (GetData ((void *) &stats_network.maxopers, CFGINT, "NetStats", "Global", "MaxOpers") <= 0) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
/* the rest don't need such valid checking */
|
||||
GetData((void *)&stats_network.maxusers, CFGINT, "NetStats", "Global", "MaxUsers");
|
||||
GetData((void *)&stats_network.maxservers, CFGINT, "NetStats", "Global", "MaxServers");
|
||||
GetData((void *)&stats_network.t_maxopers, CFGINT, "NetStats", "Global", "MaxOpersTime");
|
||||
|
@ -156,13 +118,18 @@ void LoadStats() {
|
|||
GetData((void *)&stats_network.totusers, CFGINT, "NetStats", "Global", "TotalUsers");
|
||||
GetData((void *)&stats_network.maxchans, CFGINT, "NetStats", "Global", "MaxChans");
|
||||
GetData((void *)&stats_network.t_chans, CFGINT, "NetStats", "Global", "MaxChansTime");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* ok, now load the server stats */
|
||||
void LoadServerStats(void)
|
||||
{
|
||||
SStats *s;
|
||||
char **row;
|
||||
hnode_t *sn;
|
||||
int count;
|
||||
if (GetTableData("ServerStats", &row) > 0) {
|
||||
for (count = 0; row[count] != NULL; count++) {
|
||||
s = malloc(sizeof(SStats));
|
||||
bzero(s, sizeof(SStats));
|
||||
s = scalloc(sizeof(SStats));
|
||||
strlcpy(s->name, row[count], MAXHOST);
|
||||
GetData((void *)&s->numsplits, CFGINT, "ServerStats", s->name, "Splits");
|
||||
GetData((void *)&s->maxusers, CFGINT, "ServerStats", s->name, "MaxUsers");
|
||||
|
@ -178,63 +145,24 @@ void LoadStats() {
|
|||
s->opers = 0;
|
||||
s->daily_totusers = 0;
|
||||
s->lowest_ping = s->highest_ping = s->daily_totusers = 0;
|
||||
|
||||
nlog(LOG_DEBUG1,
|
||||
"LoadStats(): Loaded statistics for %s", s->name);
|
||||
nlog(LOG_DEBUG1, "Loaded statistics for %s", s->name);
|
||||
sn = hnode_create(s);
|
||||
if (hash_isfull(Shead)) {
|
||||
nlog(LOG_CRITICAL,
|
||||
"Eeek, StatServ Server Hash is Full!");
|
||||
nlog(LOG_CRITICAL, "StatServ server hash full");
|
||||
} else {
|
||||
hash_insert(Shead, sn, s->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(row);
|
||||
/* we now load channel data dynamically. */
|
||||
/* ok, and now the channel stats. */
|
||||
#if 0
|
||||
if (GetTableData("ChanStats", &row) > 0) {
|
||||
for (count = 0; row[count] != NULL; count++) {
|
||||
load_chan(row[count]);
|
||||
}
|
||||
}
|
||||
c = malloc(sizeof(CStats));
|
||||
strlcpy(c->name, row[count], CHANLEN);
|
||||
GetData((void *)&c->topics, CFGINT, "ChanStats", c->name, "Topics");
|
||||
GetData((void *)&c->totmem, CFGINT, "ChanStats", c->name, "TotalMems");
|
||||
GetData((void *)&c->kicks, CFGINT, "ChanStats", c->name, "Kicks");
|
||||
GetData((void *)&c->lastseen, CFGINT, "ChanStats", c->name, "LastSeen");
|
||||
GetData((void *)&c->maxmems, CFGINT, "ChanStats", c->name, "MaxMems");
|
||||
GetData((void *)&c->t_maxmems, CFGINT, "ChanStats", c->name, "MaxMemsTime");
|
||||
GetData((void *)&c->maxkicks, CFGINT, "ChanStats", c->name, "MaxKicks");
|
||||
GetData((void *)&c->t_maxkicks, CFGINT, "ChanStats", c->name, "MaxKicksTime");
|
||||
GetData((void *)&c->maxjoins, CFGINT, "ChanStats", c->name, "MaxJoins");
|
||||
GetData((void *)&c->t_maxjoins, CFGINT, "ChanStats", c->name, "MaxJoinsTime");
|
||||
c->topicstoday = 0;
|
||||
c->joinstoday = 0;
|
||||
c->members = 0;
|
||||
cn = lnode_create(c);
|
||||
if (list_isfull(Chead)) {
|
||||
nlog(LOG_CRITICAL,
|
||||
"Eeek, StatServ Channel Hash is Full!");
|
||||
} else {
|
||||
nlog(LOG_DEBUG2,
|
||||
"Loading %s Channel Data", c->name);
|
||||
if ((me.now - c->lastseen) < 604800) {
|
||||
list_append(Chead, cn);
|
||||
} else {
|
||||
nlog(LOG_DEBUG1,
|
||||
"Deleting Old Channel %s", c->name);
|
||||
lnode_destroy(cn);
|
||||
free(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(row);
|
||||
#endif
|
||||
StatServ.newdb = 0;
|
||||
}
|
||||
|
||||
void LoadStats(void)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
if(LoadNetworkStats() == 0)
|
||||
return;
|
||||
LoadServerStats();
|
||||
}
|
||||
|
||||
/* @brief load the info for a specific channel from the database
|
||||
|
@ -245,13 +173,12 @@ void LoadStats() {
|
|||
* @returns a CStats struct that contains info for the channel. If its a new Channel, contains the name and thats it.
|
||||
*/
|
||||
|
||||
CStats *load_chan(char *name) {
|
||||
CStats *load_chan(char *name)
|
||||
{
|
||||
lnode_t *cn;
|
||||
char *data;
|
||||
|
||||
CStats *c;
|
||||
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
c = malloc(sizeof(CStats));
|
||||
#ifdef USE_BERKELEY
|
||||
|
@ -260,22 +187,9 @@ CStats *load_chan(char *name) {
|
|||
#else
|
||||
strlcpy(c->name, name, CHANLEN);
|
||||
if (GetData((void *)&data, CFGSTR, "ChanStats", c->name, "ChanData") > 0) {
|
||||
/* its the new database format... Good */
|
||||
sscanf(data, "%ld %ld %ld %ld %ld %ld %ld %ld %ld", &c->topics, &c->totmem, &c->kicks, &c->maxmems, &c->t_maxmems, &c->maxkicks, &c->t_maxkicks, &c->maxjoins, &c->t_maxjoins);
|
||||
GetData((void *)&c->lastseen, CFGINT, "ChanStats", c->name, "LastSeen");
|
||||
free(data);
|
||||
} else if (GetData((void *)&c->topics, CFGINT, "ChanStats", c->name, "Topics") > 0) {
|
||||
GetData((void *)&c->totmem, CFGINT, "ChanStats", c->name, "TotalMems");
|
||||
GetData((void *)&c->kicks, CFGINT, "ChanStats", c->name, "Kicks");
|
||||
GetData((void *)&c->lastseen, CFGINT, "ChanStats", c->name, "LastSeen");
|
||||
GetData((void *)&c->maxmems, CFGINT, "ChanStats", c->name, "MaxMems");
|
||||
GetData((void *)&c->t_maxmems, CFGINT, "ChanStats", c->name, "MaxMemsTime");
|
||||
GetData((void *)&c->maxkicks, CFGINT, "ChanStats", c->name, "MaxKicks");
|
||||
GetData((void *)&c->t_maxkicks, CFGINT, "ChanStats", c->name, "MaxKicksTime");
|
||||
GetData((void *)&c->maxjoins, CFGINT, "ChanStats", c->name, "MaxJoins");
|
||||
GetData((void *)&c->t_maxjoins, CFGINT, "ChanStats", c->name, "MaxJoinsTime");
|
||||
/* delete so when we save, we only save relevent information */
|
||||
DelRow("ChanStats", c->name);
|
||||
#endif
|
||||
} else {
|
||||
strlcpy(c->name, name, CHANLEN);
|
||||
|
@ -298,12 +212,11 @@ CStats *load_chan(char *name) {
|
|||
c->lastsave = me.now;
|
||||
cn = lnode_create(c);
|
||||
if (list_isfull(Chead)) {
|
||||
nlog(LOG_CRITICAL, "Eeek, StatServ Channel Hash is Full!");
|
||||
nlog(LOG_CRITICAL, "StatServ channel hash full");
|
||||
} else {
|
||||
nlog(LOG_DEBUG2, "Loading %s Channel Data", c->name);
|
||||
nlog(LOG_DEBUG2, "Loading channel %s", c->name);
|
||||
if ((me.now - c->lastseen) > 604800) {
|
||||
nlog(LOG_DEBUG1,
|
||||
"Resetting Old Channel %s", c->name);
|
||||
nlog(LOG_DEBUG1, "Reset old channel %s", c->name);
|
||||
c->totmem = 0;
|
||||
c->topics = 0;
|
||||
c->kicks = 0;
|
||||
|
@ -334,8 +247,8 @@ CStats *load_chan(char *name) {
|
|||
* @returns nothing
|
||||
*/
|
||||
|
||||
void save_chan(CStats *c) {
|
||||
#ifndef OLDDATABASE
|
||||
void save_chan(CStats *c)
|
||||
{
|
||||
char data[BUFSIZE];
|
||||
|
||||
#ifdef USE_BERKELEY
|
||||
|
@ -352,20 +265,6 @@ void save_chan(CStats *c) {
|
|||
/* we keep this seperate so we can easily delete old channels */
|
||||
SetData((void *)c->lastseen, CFGINT, "ChanStats", c->name, "LastSeen");
|
||||
#endif
|
||||
|
||||
#else
|
||||
SET_SEGV_LOCATION();
|
||||
SetData((void *)c->topics, CFGINT, "ChanStats", c->name, "Topics");
|
||||
SetData((void *)c->totmem, CFGINT, "ChanStats", c->name, "TotalMems");
|
||||
SetData((void *)c->kicks, CFGINT, "ChanStats", c->name, "Kicks");
|
||||
SetData((void *)c->lastseen, CFGINT, "ChanStats", c->name, "LastSeen");
|
||||
SetData((void *)c->maxmems, CFGINT, "ChanStats", c->name, "MaxMems");
|
||||
SetData((void *)c->t_maxmems, CFGINT, "ChanStats", c->name, "MaxMemsTime");
|
||||
SetData((void *)c->maxkicks, CFGINT, "ChanStats", c->name, "MaxKicks");
|
||||
SetData((void *)c->t_maxkicks, CFGINT, "ChanStats", c->name, "MaxKicksTime");
|
||||
SetData((void *)c->maxjoins, CFGINT, "ChanStats", c->name, "MaxJoins");
|
||||
SetData((void *)c->t_maxjoins, CFGINT, "ChanStats", c->name, "MaxJoinsTime");
|
||||
#endif
|
||||
c->lastsave = me.now;
|
||||
}
|
||||
|
||||
|
@ -377,7 +276,7 @@ void save_chan(CStats *c) {
|
|||
* @returns nothing
|
||||
*/
|
||||
|
||||
int DelOldChan()
|
||||
int DelOldChan(void)
|
||||
{
|
||||
char **row;
|
||||
int count = 0;
|
||||
|
@ -385,7 +284,7 @@ int DelOldChan()
|
|||
time_t start;
|
||||
|
||||
start = time(NULL);
|
||||
nlog(LOG_DEBUG1, "Starting To Clean Channel Database");
|
||||
nlog(LOG_DEBUG1, "Deleting old channels");
|
||||
if (GetTableData("ChanStats", &row) > 0) {
|
||||
for (count = 0; row[count] != NULL; count++) {
|
||||
if (GetData((void *)&lastseen, CFGINT, "ChanStats", row[count], "LastSeen") > 0) {
|
||||
|
@ -398,14 +297,12 @@ int DelOldChan()
|
|||
}
|
||||
} else {
|
||||
/* database corruption? */
|
||||
nlog(LOG_WARNING, "Hrm, Database Corruption for Channel %s?. Deleting Record", row[count]);
|
||||
nlog(LOG_WARNING, "Channel %s corrpted: deleting record", row[count]);
|
||||
DelRow("ChanStats", row[count]);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(row);
|
||||
nlog(LOG_INFO, "Took %d seconds to clean %d channel stats", (int)(time(NULL) - start), count);
|
||||
nlog(LOG_INFO, "DelOldChan: %d seconds %d channels", (int)(time(NULL) - start), count);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ int ss_html()
|
|||
if (StatServ.html) {
|
||||
if (StatServ.htmlpath[0] == 0) {
|
||||
nlog(LOG_WARNING,
|
||||
"Can't do HTML Writout as html path is not defined");
|
||||
"Unable to write HTML: html path is not defined");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
|
@ -172,7 +172,7 @@ int ss_html()
|
|||
if (buf1) {
|
||||
startstr = strlen(buf) - strlen(buf1);
|
||||
fwrite(buf, startstr, 1, opf);
|
||||
fputs(me.versionfull, opf);
|
||||
fputs(me.version, opf);
|
||||
buf = buf1 + strlen("!VERSION!");
|
||||
}
|
||||
buf1 = strstr(buf, "!TITLE!");
|
||||
|
@ -575,6 +575,7 @@ void get_chantops()
|
|||
|
||||
void get_map(char *uplink, int level)
|
||||
{
|
||||
#if 0
|
||||
hscan_t hs;
|
||||
hnode_t *sn;
|
||||
Server *s;
|
||||
|
@ -584,7 +585,7 @@ void get_map(char *uplink, int level)
|
|||
hash_scan_begin(&hs, sh);
|
||||
while ((sn = hash_scan_next(&hs))) {
|
||||
s = hnode_get(sn);
|
||||
ss = findstats(s->name);
|
||||
ss = findserverstats(s->name);
|
||||
|
||||
if ((level == 0) && (strlen(s->uplink) <= 0)) {
|
||||
/* its the root server */
|
||||
|
@ -612,4 +613,5 @@ void get_map(char *uplink, int level)
|
|||
get_map(s->name, level + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/* NeoStats - IRC Statistical Services
|
||||
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond
|
||||
** http://www.neostats.net/
|
||||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** NeoStats CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#ifndef M_STATS_H
|
||||
#define M_STATS_H
|
||||
|
||||
#define DecreaseOpers(x) x->opers--; stats_network.opers--;
|
||||
#define DecreaseUsers(x) x->users--; stats_network.users--;
|
||||
#define DecreaseServers() stats_network.servers--;
|
||||
|
||||
#define IncreaseOpers(x) x->opers++; stats_network.opers++;
|
||||
#define IncreaseUsers(x) x->users++; stats_network.users++; x->totusers++; stats_network.totusers++; daily.tot_users++;
|
||||
#define IncreaseServers() stats_network.servers++;
|
||||
|
||||
#define IncreaseKicks(x) x->kicks++; x->maxkickstoday++; x->members--;
|
||||
#define IncreaseTops(x) x->topics++; x->topicstoday++;
|
||||
#define Increasemems(x) x->members++; x->totmem++; x->lastseen = time(NULL); x->joinstoday++;
|
||||
#define Decreasemems(x) x->members--; x->lastseen = time(NULL);
|
||||
#define IncreaseChans() stats_network.chans++;
|
||||
#define DecreaseChans() stats_network.chans--;
|
||||
#endif
|
|
@ -445,7 +445,7 @@ COLDEF statserv_versionscols[] = {
|
|||
"statserv_versions",
|
||||
"name",
|
||||
RTA_STR,
|
||||
MAX_CLIENT_VERSION_NAME,
|
||||
BUFSIZE,
|
||||
offsetof(struct irc_client_version, name),
|
||||
RTA_READONLY,
|
||||
NULL,
|
||||
|
|
|
@ -25,53 +25,27 @@
|
|||
|
||||
#include "statserv.h"
|
||||
|
||||
#define IncreaseOpers(x) x->opers++; stats_network.opers++;
|
||||
#define DecreaseOpers(x) x->opers--; stats_network.opers--;
|
||||
|
||||
#define IncreaseUsers(x) x->users++; stats_network.users++; x->totusers++; stats_network.totusers++; daily.tot_users++;
|
||||
#define DecreaseUsers(x) x->users--; stats_network.users--;
|
||||
|
||||
#define Increasemems(x) x->members++; x->totmem++; x->lastseen = time(NULL); x->joinstoday++;
|
||||
#define Decreasemems(x) x->members--; x->lastseen = time(NULL);
|
||||
|
||||
static char announce_buf[BUFSIZE];
|
||||
|
||||
static int ss_event_ctcpversion(CmdParams* cmdparams);
|
||||
int ss_event_online(CmdParams* cmdparams);
|
||||
static int ss_event_pong(CmdParams* cmdparams);
|
||||
static int ss_event_away(CmdParams* cmdparams);
|
||||
static int ss_event_server(CmdParams* cmdparams);
|
||||
static int ss_event_squit(CmdParams* cmdparams);
|
||||
static int ss_event_nickip(CmdParams* cmdparams);
|
||||
static int ss_event_signon(CmdParams* cmdparams);
|
||||
static int ss_event_quit(CmdParams* cmdparams);
|
||||
static int ss_event_mode(CmdParams* cmdparams);
|
||||
static int ss_event_kill(CmdParams* cmdparams);
|
||||
static int ss_event_newchan(CmdParams* cmdparams);
|
||||
static int ss_event_delchan(CmdParams* cmdparams);
|
||||
static int ss_event_join(CmdParams* cmdparams);
|
||||
static int ss_event_part(CmdParams* cmdparams);
|
||||
static int ss_event_topic(CmdParams* cmdparams);
|
||||
static int ss_event_kick(CmdParams* cmdparams);
|
||||
|
||||
ModuleEvent module_events[] = {
|
||||
{EVENT_ONLINE, ss_event_online},
|
||||
{EVENT_PONG, ss_event_pong},
|
||||
{EVENT_SERVER, ss_event_server},
|
||||
{EVENT_SQUIT, ss_event_squit},
|
||||
{EVENT_SIGNON, ss_event_signon},
|
||||
{EVENT_GOTNICKIP, ss_event_nickip},
|
||||
{EVENT_UMODE, ss_event_mode},
|
||||
{EVENT_QUIT, ss_event_quit},
|
||||
{EVENT_AWAY, ss_event_away},
|
||||
{EVENT_KILL, ss_event_kill},
|
||||
{EVENT_NEWCHAN, ss_event_newchan},
|
||||
{EVENT_DELCHAN, ss_event_delchan},
|
||||
{EVENT_JOIN, ss_event_join},
|
||||
{EVENT_PART, ss_event_part},
|
||||
{EVENT_KICK, ss_event_kick},
|
||||
{EVENT_TOPIC, ss_event_topic},
|
||||
{EVENT_CTCPVERSION, ss_event_ctcpversion},
|
||||
{EVENT_NULL, NULL}
|
||||
};
|
||||
hash_t *Shead;
|
||||
list_t *Chead;
|
||||
list_t *Vhead;
|
||||
|
||||
static int check_interval()
|
||||
{
|
||||
static int lasttime;
|
||||
static int count;
|
||||
|
||||
if (StatServ.newdb || !StatServ.onchan || !me.synced) {
|
||||
if (!StatServ.onchan || !me.synced) {
|
||||
return -1;
|
||||
}
|
||||
if ((me.now - lasttime) < StatServ.msginterval ) {
|
||||
|
@ -129,7 +103,7 @@ announce_lag(const char *msg, ...)
|
|||
announce(StatServ.lagalert, announce_buf);
|
||||
}
|
||||
|
||||
static CVersions *findversions(char *name)
|
||||
static CVersions *findctcpversion(char *name)
|
||||
{
|
||||
CVersions *cv;
|
||||
lnode_t *cn;
|
||||
|
@ -137,7 +111,7 @@ static CVersions *findversions(char *name)
|
|||
if (cn) {
|
||||
cv = lnode_get(cn);
|
||||
} else {
|
||||
nlog(LOG_DEBUG2, "findversions(%s) -> NOT FOUND", name);
|
||||
nlog(LOG_DEBUG2, "findctcpversion(%s) -> NOT FOUND", name);
|
||||
return NULL;
|
||||
}
|
||||
return cv;
|
||||
|
@ -183,85 +157,94 @@ int load_client_versions(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_ctcpversion(CmdParams* cmdparams)
|
||||
void list_client_versions(User* u, int num)
|
||||
{
|
||||
CVersions *cv;
|
||||
lnode_t *cn;
|
||||
int i;
|
||||
|
||||
if (list_count(Vhead) == 0) {
|
||||
prefmsg(u->nick, ss_bot->nick, "No Stats Available.");
|
||||
return;
|
||||
}
|
||||
if (!list_is_sorted(Vhead, topversions)) {
|
||||
list_sort(Vhead, topversions);
|
||||
}
|
||||
cn = list_first(Vhead);
|
||||
cv = lnode_get(cn);
|
||||
prefmsg(u->nick, ss_bot->nick, "Top%d Client Versions:", num);
|
||||
prefmsg(u->nick, ss_bot->nick, "======================");
|
||||
for (i = 0; i <= num; i++) {
|
||||
prefmsg(u->nick, ss_bot->nick, "%d) %d -> %s", i, cv->count, cv->name);
|
||||
cn = list_next(Vhead, cn);
|
||||
if (cn) {
|
||||
cv = lnode_get(cn);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
prefmsg(u->nick, ss_bot->nick, "End of List.");
|
||||
}
|
||||
|
||||
void StatsAddChan(Channel* c)
|
||||
{
|
||||
stats_network.chans++;
|
||||
if (stats_network.chans > stats_network.maxchans) {
|
||||
stats_network.maxchans = stats_network.chans;
|
||||
stats_network.t_chans = me.now;
|
||||
announce_record("\2NEW CHANNEL RECORD\2 %ld channels on the network",
|
||||
stats_network.maxchans);
|
||||
}
|
||||
if (stats_network.chans > daily.chans) {
|
||||
daily.chans = stats_network.chans;
|
||||
daily.t_chans = me.now;
|
||||
}
|
||||
}
|
||||
|
||||
void StatsAddCTCPVersion(char* version)
|
||||
{
|
||||
static char nocols[BUFSIZE];
|
||||
lnode_t *node;
|
||||
CVersions *clientv;
|
||||
char *nocols = cmdparams->av[1];
|
||||
|
||||
strlcpy(nocols, version, BUFSIZE);
|
||||
strip_mirc_codes(nocols);
|
||||
|
||||
clientv = findversions(nocols);
|
||||
clientv = findctcpversion(nocols);
|
||||
if (clientv) {
|
||||
nlog(LOG_DEBUG2, "Found version: %s", nocols);
|
||||
clientv->count++;
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
clientv = malloc(sizeof(CVersions));
|
||||
strlcpy(clientv->name, nocols, MAX_CLIENT_VERSION_NAME);
|
||||
strlcpy(clientv->name, nocols, BUFSIZE);
|
||||
clientv->count = 1;
|
||||
node = lnode_create(clientv);
|
||||
list_append(Vhead, node);
|
||||
nlog(LOG_DEBUG2, "Added version: %s", clientv->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_newchan(CmdParams* cmdparams)
|
||||
{
|
||||
long count;
|
||||
|
||||
IncreaseChans();
|
||||
/* only check exclusions after increasing channel count */
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->channel)) {
|
||||
return 1;
|
||||
}
|
||||
count = hash_count(ch);
|
||||
if (count > stats_network.maxchans) {
|
||||
stats_network.maxchans = count;
|
||||
stats_network.t_chans = me.now;
|
||||
announce_record("\2NEW CHANNEL RECORD\2 Wow, there is now %ld Channels on the Network",
|
||||
stats_network.maxchans);
|
||||
}
|
||||
if (count > daily.chans) {
|
||||
daily.chans = count;
|
||||
daily.t_chans = me.now;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_delchan(CmdParams* cmdparams)
|
||||
void StatsDelChan(Channel* c)
|
||||
{
|
||||
CStats *cs;
|
||||
lnode_t *ln;
|
||||
|
||||
DecreaseChans();
|
||||
/* only check exclusions after increasing channel count */
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->channel)) {
|
||||
return 1;
|
||||
}
|
||||
ln = list_find(Chead, cmdparams->channel->name, comparef);
|
||||
if (ln) {
|
||||
cs = lnode_get(ln);
|
||||
stats_network.chans --;
|
||||
cs = findchanstats(c->name);
|
||||
if (cs) {
|
||||
save_chan(cs);
|
||||
list_delete(Chead, ln);
|
||||
lnode_destroy(ln);
|
||||
free(cs);
|
||||
} else {
|
||||
nlog(LOG_WARNING, "Couldn't find channel %s when deleting from stats", cmdparams->av[0]);
|
||||
nlog(LOG_WARNING, "Couldn't find channel %s when deleting from stats", c->name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_join(CmdParams* cmdparams)
|
||||
void StatsJoinChan(User* u, Channel* c)
|
||||
{
|
||||
CStats *cs;
|
||||
|
||||
/* only check exclusions after increasing channel count */
|
||||
if (StatServ.exclusions && (IsExcluded(cmdparams->channel)|| IsExcluded(cmdparams->source.user))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
cs = findchanstats(cmdparams->channel->name);
|
||||
cs = findchanstats(c->name);
|
||||
if (cs) {
|
||||
Increasemems(cs);
|
||||
if (cs->maxmemtoday < cs->members) {
|
||||
|
@ -277,62 +260,50 @@ int ss_event_join(CmdParams* cmdparams)
|
|||
cs->t_maxjoins = me.now;
|
||||
}
|
||||
} else {
|
||||
cs = load_chan(cmdparams->channel->name);
|
||||
cs = load_chan(c->name);
|
||||
Increasemems(cs);
|
||||
cs->maxmemtoday++;
|
||||
cs->t_maxmemtoday = me.now;
|
||||
cs->maxmems++;
|
||||
cs->t_maxmems = me.now;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_part(CmdParams* cmdparams)
|
||||
void StatsPartChan(User* u, Channel* c)
|
||||
{
|
||||
CStats *cs;
|
||||
/* only check exclusions after increasing channel count */
|
||||
if (StatServ.exclusions && (IsExcluded(cmdparams->channel) || IsExcluded(cmdparams->source.user))) {
|
||||
return 1;
|
||||
}
|
||||
cs = findchanstats(cmdparams->channel->name);
|
||||
|
||||
cs = findchanstats(c->name);
|
||||
if (cs) {
|
||||
Decreasemems(cs);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_topic(CmdParams* cmdparams)
|
||||
void StatsChanTopic(Channel* c)
|
||||
{
|
||||
CStats *cs;
|
||||
|
||||
/* only check exclusions after increasing channel count */
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->channel)) {
|
||||
return 1;
|
||||
}
|
||||
cs = findchanstats(cmdparams->channel->name);
|
||||
cs = findchanstats(c->name);
|
||||
if (cs) {
|
||||
IncreaseTops(cs);
|
||||
cs->topics++;
|
||||
cs->topicstoday++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_kick(CmdParams* cmdparams)
|
||||
void StatsChanKick(Channel* c)
|
||||
{
|
||||
CStats *cs;
|
||||
|
||||
/* only check exclusions after increasing channel count */
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->channel)) {
|
||||
return 1;
|
||||
}
|
||||
cs = findchanstats(cmdparams->channel->name);
|
||||
cs = findchanstats(c->name);
|
||||
if (cs) {
|
||||
IncreaseKicks(cs);
|
||||
cs->kicks++;
|
||||
cs->maxkickstoday++;
|
||||
cs->members--;
|
||||
if (cs->maxkicks < cs->maxkickstoday) {
|
||||
cs->maxkicks = cs->maxkickstoday;
|
||||
cs->t_maxkicks = me.now;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
CStats *findchanstats(char *name)
|
||||
|
@ -343,264 +314,19 @@ CStats *findchanstats(char *name)
|
|||
cn = list_find(Chead, name, comparef);
|
||||
if (cn) {
|
||||
cs = lnode_get(cn);
|
||||
} else {
|
||||
nlog(LOG_DEBUG2, "findchanstats(%s) -> NOT FOUND",
|
||||
name);
|
||||
return NULL;
|
||||
return cs;
|
||||
}
|
||||
return cs;
|
||||
nlog(LOG_DEBUG2, "findchanstats: %s not found", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ss_event_server(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
AddStats(cmdparams->source.server);
|
||||
IncreaseServers();
|
||||
if (stats_network.maxservers < stats_network.servers) {
|
||||
stats_network.maxservers = stats_network.servers;
|
||||
stats_network.t_maxservers = me.now;
|
||||
if (!(StatServ.exclusions && IsExcluded(cmdparams->source.server))) {
|
||||
announce_record("\2NEW SERVER RECORD\2 Wow, there are now %ld Servers on the Network",
|
||||
stats_network.servers);
|
||||
}
|
||||
}
|
||||
if (stats_network.servers > daily.servers) {
|
||||
daily.servers = stats_network.servers;
|
||||
daily.t_servers = me.now;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_squit(CmdParams* cmdparams)
|
||||
{
|
||||
SStats *ss;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
DecreaseServers();
|
||||
ss = findstats(cmdparams->source.server->name);
|
||||
if (cmdparams->source.server->name != me.uplink)
|
||||
ss->numsplits = ss->numsplits + 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_kill(CmdParams* cmdparams)
|
||||
{
|
||||
SStats *s;
|
||||
SStats *ss;
|
||||
char *rbuf, *cmd, *who;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
s = findstats(cmdparams->source.user->server->name);
|
||||
if (is_oper(cmdparams->source.user)) {
|
||||
nlog(LOG_DEBUG2, "Decreasing OperCount on %s due to kill", cmdparams->source.user->server->name);
|
||||
DecreaseOpers(s);
|
||||
}
|
||||
if (cmdparams->source.user->is_away == 1) {
|
||||
stats_network.away = stats_network.away - 1;
|
||||
}
|
||||
DecreaseUsers(s);
|
||||
DelTLD(cmdparams->source.user);
|
||||
rbuf = sstrdup(recbuf);
|
||||
cmd = rbuf;
|
||||
who = strtok(cmd, " ");
|
||||
cmd = strtok(NULL, " ");
|
||||
cmd = strtok(NULL, " ");
|
||||
cmd = strtok(NULL, "");
|
||||
cmd++;
|
||||
who++;
|
||||
if (finduser(who)) {
|
||||
/* it was a User that killed the target */
|
||||
ss = findstats(cmdparams->source.user->server->name);
|
||||
ss->operkills = ss->operkills + 1;
|
||||
} else if (findserver(who)) {
|
||||
ss = findstats(who);
|
||||
ss->serverkills = ss->serverkills + 1;
|
||||
}
|
||||
free(rbuf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_mode(CmdParams* cmdparams)
|
||||
{
|
||||
int add = 1;
|
||||
char *modes;
|
||||
SStats *s;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return -1;
|
||||
}
|
||||
s = findstats(cmdparams->source.user->server->name);
|
||||
if (!s) {
|
||||
nlog(LOG_WARNING,
|
||||
"Unable to find stats for %s", cmdparams->source.user->server->name);
|
||||
return -1;
|
||||
}
|
||||
modes = cmdparams->av[1];
|
||||
while (*modes) {
|
||||
switch (*modes) {
|
||||
case '+':
|
||||
add = 1;
|
||||
break;
|
||||
case '-':
|
||||
add = 0;
|
||||
break;
|
||||
case 'O':
|
||||
case 'o':
|
||||
if (add) {
|
||||
nlog(LOG_DEBUG1, "Increasing OperCount for %s (%d)", cmdparams->source.user->server->name, s->opers);
|
||||
IncreaseOpers(s);
|
||||
if (stats_network.maxopers <
|
||||
stats_network.opers) {
|
||||
stats_network.maxopers = stats_network.opers;
|
||||
stats_network.t_maxopers = me.now;
|
||||
announce_record("\2Oper Record\2 The Network has reached a New Record for Opers at %ld",
|
||||
stats_network.opers);
|
||||
}
|
||||
if (s->maxopers < s->opers) {
|
||||
s->maxopers = s->opers;
|
||||
s->t_maxopers = me.now;
|
||||
announce_record("\2Server Oper Record\2 Wow, the Server %s now has a New record with %d Opers",
|
||||
s->name,s->opers);
|
||||
}
|
||||
if (s->opers > daily.opers) {
|
||||
daily.opers = s->opers;
|
||||
daily.t_opers = me.now;
|
||||
}
|
||||
} else {
|
||||
if (is_oper(cmdparams->source.user)) {
|
||||
nlog(LOG_DEBUG1, "Decreasing OperCount for %s", cmdparams->source.user->server->name);
|
||||
DecreaseOpers(s);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
modes++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_quit(CmdParams* cmdparams)
|
||||
{
|
||||
SStats *s;
|
||||
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
s = findstats(cmdparams->source.user->server->name);
|
||||
|
||||
if (!cmdparams->source.user->modes)
|
||||
return -1;
|
||||
if (is_oper(cmdparams->source.user)) {
|
||||
nlog(LOG_DEBUG2, "Decreasing OperCount on %s due to signoff", cmdparams->source.user->server->name);
|
||||
DecreaseOpers(s);
|
||||
}
|
||||
if (cmdparams->source.user->is_away == 1) {
|
||||
stats_network.away = stats_network.away - 1;
|
||||
}
|
||||
DecreaseUsers(s);
|
||||
DelTLD(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_away(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
if (cmdparams->source.user->is_away == 1) {
|
||||
stats_network.away = stats_network.away + 1;
|
||||
} else {
|
||||
stats_network.away = stats_network.away - 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_nickip(CmdParams* cmdparams)
|
||||
{
|
||||
AddTLD(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_signon(CmdParams* cmdparams)
|
||||
{
|
||||
SStats *s;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
/* ignore them if they are excluded */
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
s = findstats(cmdparams->source.user->server->name);
|
||||
IncreaseUsers(s);
|
||||
nlog(LOG_DEBUG2, "added %s to stats, now at %d", cmdparams->source.user->nick, s->users);
|
||||
if (s->maxusers < s->users) {
|
||||
/* New User Record */
|
||||
s->maxusers = s->users;
|
||||
s->t_maxusers = me.now;
|
||||
announce_record("\2NEW USER RECORD!\2 Wow, %s is cranking at the moment with %d users!",
|
||||
s->name, s->users);
|
||||
}
|
||||
if (stats_network.maxusers < stats_network.users) {
|
||||
stats_network.maxusers = stats_network.users;
|
||||
stats_network.t_maxusers = me.now;
|
||||
announce_record("\2NEW NETWORK RECORD!\2 Wow, a New Global User record has been reached with %ld users!",
|
||||
stats_network.users);
|
||||
}
|
||||
if (stats_network.users > daily.users) {
|
||||
daily.users = stats_network.users;
|
||||
daily.t_users = me.now;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_pong(CmdParams* cmdparams)
|
||||
{
|
||||
SStats *ss;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
/* we don't want negative pings! */
|
||||
if (cmdparams->source.server->ping < 0)
|
||||
return -1;
|
||||
ss = findstats(cmdparams->source.server->name);
|
||||
if (!ss)
|
||||
return -1;
|
||||
/* this is a tidy up from old versions of StatServ that used to have negative pings! */
|
||||
if (ss->lowest_ping < 0) {
|
||||
ss->lowest_ping = 0;
|
||||
}
|
||||
if (ss->highest_ping < 0) {
|
||||
ss->highest_ping = 0;
|
||||
}
|
||||
if (cmdparams->source.server->ping > ss->highest_ping) {
|
||||
ss->highest_ping = cmdparams->source.server->ping;
|
||||
ss->t_highest_ping = me.now;
|
||||
}
|
||||
if (cmdparams->source.server->ping < ss->lowest_ping) {
|
||||
ss->lowest_ping = cmdparams->source.server->ping;
|
||||
ss->t_lowest_ping = me.now;
|
||||
}
|
||||
/* ok, updated the statistics, now lets see if this server is "lagged out" */
|
||||
if (cmdparams->source.server->ping > StatServ.lagtime) {
|
||||
announce_lag("\2%s\2 is lagged out with a ping of %d",
|
||||
cmdparams->source.server->name, cmdparams->source.server->ping);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
SStats *new_stats(const char *name)
|
||||
SStats *newserverstats(const char *name)
|
||||
{
|
||||
hnode_t *sn;
|
||||
SStats *s;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
nlog(LOG_DEBUG2, "new_stats(%s)", name);
|
||||
nlog(LOG_DEBUG2, "newserverstats(%s)", name);
|
||||
s = scalloc(sizeof(SStats));
|
||||
if (!s) {
|
||||
FATAL_ERROR("Out of memory.")
|
||||
|
@ -622,34 +348,235 @@ SStats *new_stats(const char *name)
|
|||
return s;
|
||||
}
|
||||
|
||||
void AddStats(Server * s)
|
||||
{
|
||||
SStats *st;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
nlog(LOG_DEBUG2, "AddStats(%s)", s->name);
|
||||
st = findstats(s->name);
|
||||
if (!st) {
|
||||
st = new_stats(s->name);
|
||||
} else {
|
||||
st->lastseen = me.now;
|
||||
}
|
||||
}
|
||||
|
||||
SStats *findstats(char *name)
|
||||
SStats *findserverstats(char *name)
|
||||
{
|
||||
hnode_t *sn;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
sn = hash_lookup(Shead, name);
|
||||
if (sn) {
|
||||
nlog(LOG_DEBUG2, "findstats(%s) - found", name);
|
||||
nlog(LOG_DEBUG2, "findserverstats(%s) - found", name);
|
||||
return hnode_get(sn);
|
||||
}
|
||||
nlog(LOG_DEBUG2, "findstats(%s) - not found", name);
|
||||
nlog(LOG_DEBUG2, "findserverstats(%s) - not found", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void StatsAddServer(Server* s)
|
||||
{
|
||||
SStats *st;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
nlog(LOG_DEBUG2, "StatsAddServer(%s)", s->name);
|
||||
st = findserverstats(s->name);
|
||||
if (!st) {
|
||||
st = newserverstats(s->name);
|
||||
} else {
|
||||
st->lastseen = me.now;
|
||||
}
|
||||
stats_network.servers ++;
|
||||
if (stats_network.maxservers < stats_network.servers) {
|
||||
stats_network.maxservers = stats_network.servers;
|
||||
stats_network.t_maxservers = me.now;
|
||||
if (!(StatServ.exclusions && IsExcluded(s))) {
|
||||
announce_record("\2NEW SERVER RECORD\2 Wow, there are now %ld Servers on the Network",
|
||||
stats_network.servers);
|
||||
}
|
||||
}
|
||||
if (stats_network.servers > daily.servers) {
|
||||
daily.servers = stats_network.servers;
|
||||
daily.t_servers = me.now;
|
||||
}
|
||||
}
|
||||
|
||||
void StatsDelServer(Server* s)
|
||||
{
|
||||
SStats *ss;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
stats_network.servers--;
|
||||
ss = findserverstats(s->name);
|
||||
if (s->name != me.uplink)
|
||||
ss->numsplits ++;
|
||||
}
|
||||
|
||||
void StatsServerPong(Server* s)
|
||||
{
|
||||
SStats *ss;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
/* we don't want negative pings! */
|
||||
if (s->ping < 0)
|
||||
return;
|
||||
ss = findserverstats(s->name);
|
||||
if (!ss)
|
||||
return;
|
||||
/* this is a tidy up from old versions of StatServ that used to have negative pings! */
|
||||
if (ss->lowest_ping < 0) {
|
||||
ss->lowest_ping = 0;
|
||||
}
|
||||
if (ss->highest_ping < 0) {
|
||||
ss->highest_ping = 0;
|
||||
}
|
||||
if (s->ping > ss->highest_ping) {
|
||||
ss->highest_ping = s->ping;
|
||||
ss->t_highest_ping = me.now;
|
||||
}
|
||||
if (s->ping < ss->lowest_ping) {
|
||||
ss->lowest_ping = s->ping;
|
||||
ss->t_lowest_ping = me.now;
|
||||
}
|
||||
/* ok, updated the statistics, now lets see if this server is "lagged out" */
|
||||
if (s->ping > StatServ.lagtime) {
|
||||
announce_lag("\2%s\2 is lagged out with a ping of %d",
|
||||
s->name, s->ping);
|
||||
}
|
||||
}
|
||||
|
||||
void StatsKillUser(User* u)
|
||||
{
|
||||
SStats *s;
|
||||
SStats *ss;
|
||||
char *rbuf, *cmd, *who;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
s = findserverstats(u->server->name);
|
||||
if (is_oper(u)) {
|
||||
nlog(LOG_DEBUG2, "Decreasing OperCount on %s due to kill", u->server->name);
|
||||
DecreaseOpers(s);
|
||||
}
|
||||
if (u->is_away == 1) {
|
||||
stats_network.away --;
|
||||
}
|
||||
DecreaseUsers(s);
|
||||
DelTLD(u);
|
||||
rbuf = sstrdup(recbuf);
|
||||
cmd = rbuf;
|
||||
who = strtok(cmd, " ");
|
||||
cmd = strtok(NULL, " ");
|
||||
cmd = strtok(NULL, " ");
|
||||
cmd = strtok(NULL, "");
|
||||
cmd++;
|
||||
who++;
|
||||
if (finduser(who)) {
|
||||
/* it was a User that killed the target */
|
||||
ss = findserverstats(u->server->name);
|
||||
ss->operkills ++;
|
||||
} else if (findserver(who)) {
|
||||
ss = findserverstats(who);
|
||||
ss->serverkills ++;
|
||||
}
|
||||
free(rbuf);
|
||||
}
|
||||
|
||||
void StatsUserMode(User* u, char *modes)
|
||||
{
|
||||
int add = 1;
|
||||
SStats *s;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
s = findserverstats(u->server->name);
|
||||
if (!s) {
|
||||
nlog(LOG_WARNING, "Unable to find stats for %s", u->server->name);
|
||||
return;
|
||||
}
|
||||
while (*modes) {
|
||||
switch (*modes) {
|
||||
case '+':
|
||||
add = 1;
|
||||
break;
|
||||
case '-':
|
||||
add = 0;
|
||||
break;
|
||||
case 'O':
|
||||
case 'o':
|
||||
if (add) {
|
||||
nlog(LOG_DEBUG1, "Increasing OperCount for %s (%d)", u->server->name, s->opers);
|
||||
IncreaseOpers(s);
|
||||
if (stats_network.maxopers <
|
||||
stats_network.opers) {
|
||||
stats_network.maxopers = stats_network.opers;
|
||||
stats_network.t_maxopers = me.now;
|
||||
announce_record("\2Oper Record\2 The Network has reached a New Record for Opers at %ld",
|
||||
stats_network.opers);
|
||||
}
|
||||
if (s->maxopers < s->opers) {
|
||||
s->maxopers = s->opers;
|
||||
s->t_maxopers = me.now;
|
||||
announce_record("\2Server Oper Record\2 Wow, the Server %s now has a New record with %d Opers",
|
||||
s->name,s->opers);
|
||||
}
|
||||
if (s->opers > daily.opers) {
|
||||
daily.opers = s->opers;
|
||||
daily.t_opers = me.now;
|
||||
}
|
||||
} else {
|
||||
if (is_oper(u)) {
|
||||
nlog(LOG_DEBUG1, "Decreasing OperCount for %s", u->server->name);
|
||||
DecreaseOpers(s);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
modes++;
|
||||
}
|
||||
}
|
||||
|
||||
void StatsUserAway(User* u)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
if (u->is_away == 1) {
|
||||
stats_network.away ++;
|
||||
} else {
|
||||
stats_network.away --;
|
||||
}
|
||||
}
|
||||
|
||||
void StatsAddUser(User* u)
|
||||
{
|
||||
SStats *s;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
s = findserverstats(u->server->name);
|
||||
IncreaseUsers(s);
|
||||
nlog(LOG_DEBUG2, "added %s to stats, now at %d", u->nick, s->users);
|
||||
if (s->maxusers < s->users) {
|
||||
/* New User Record */
|
||||
s->maxusers = s->users;
|
||||
s->t_maxusers = me.now;
|
||||
announce_record("\2NEW USER RECORD!\2 Wow, %s is cranking at the moment with %d users!",
|
||||
s->name, s->users);
|
||||
}
|
||||
if (stats_network.maxusers < stats_network.users) {
|
||||
stats_network.maxusers = stats_network.users;
|
||||
stats_network.t_maxusers = me.now;
|
||||
announce_record("\2NEW NETWORK RECORD!\2 Wow, a New Global User record has been reached with %ld users!",
|
||||
stats_network.users);
|
||||
}
|
||||
if (stats_network.users > daily.users) {
|
||||
daily.users = stats_network.users;
|
||||
daily.t_users = me.now;
|
||||
}
|
||||
}
|
||||
|
||||
void StatsDelUser(User* u)
|
||||
{
|
||||
SStats *s;
|
||||
|
||||
s = findserverstats(u->server->name);
|
||||
if (is_oper(u)) {
|
||||
nlog(LOG_DEBUG2, "Decreasing OperCount on %s due to signoff", u->server->name);
|
||||
DecreaseOpers(s);
|
||||
}
|
||||
if (u->is_away == 1) {
|
||||
stats_network.away = stats_network.away - 1;
|
||||
}
|
||||
DecreaseUsers(s);
|
||||
DelTLD(u);
|
||||
}
|
||||
|
||||
int StatsMidnight(void)
|
||||
{
|
||||
struct tm *ltm = localtime(&me.now);
|
||||
|
@ -683,3 +610,40 @@ int StatsMidnight(void)
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void InitStats(void)
|
||||
{
|
||||
Chead = list_create(-1);
|
||||
Shead = hash_create(-1, 0, 0);
|
||||
Vhead = list_create(-1);
|
||||
GetServerList(StatsAddServer);
|
||||
GetUserList(StatsAddUser);
|
||||
/* TODO get user modes */
|
||||
GetChannelList(StatsAddChan);
|
||||
/* TODO get member counts */
|
||||
}
|
||||
|
||||
void FiniStats(void)
|
||||
{
|
||||
CStats *c;
|
||||
lnode_t *cn;
|
||||
SStats *s;
|
||||
hnode_t *sn;
|
||||
hscan_t ss;
|
||||
|
||||
hash_destroy(Shead);
|
||||
hash_scan_begin(&ss, Shead);
|
||||
while ((sn = hash_scan_next(&ss))) {
|
||||
s = hnode_get(sn);
|
||||
free(s);
|
||||
hash_scan_delete(Shead, sn);
|
||||
hnode_destroy(sn);
|
||||
}
|
||||
cn = list_first(Chead);
|
||||
while (cn) {
|
||||
c = lnode_get(cn);
|
||||
free(c);
|
||||
cn = list_next(Chead, cn);
|
||||
}
|
||||
list_destroy_nodes(Chead);
|
||||
}
|
||||
|
|
|
@ -44,11 +44,52 @@ static int ss_netstats(CmdParams* cmdparams);
|
|||
static int ss_clientversions(CmdParams* cmdparams);
|
||||
static int ss_forcehtml(CmdParams* cmdparams);
|
||||
|
||||
static int ss_event_ctcpversion(CmdParams* cmdparams);
|
||||
static int ss_event_online(CmdParams* cmdparams);
|
||||
static int ss_event_pong(CmdParams* cmdparams);
|
||||
static int ss_event_away(CmdParams* cmdparams);
|
||||
static int ss_event_server(CmdParams* cmdparams);
|
||||
static int ss_event_squit(CmdParams* cmdparams);
|
||||
static int ss_event_nickip(CmdParams* cmdparams);
|
||||
static int ss_event_signon(CmdParams* cmdparams);
|
||||
static int ss_event_quit(CmdParams* cmdparams);
|
||||
static int ss_event_mode(CmdParams* cmdparams);
|
||||
static int ss_event_kill(CmdParams* cmdparams);
|
||||
static int ss_event_newchan(CmdParams* cmdparams);
|
||||
static int ss_event_delchan(CmdParams* cmdparams);
|
||||
static int ss_event_join(CmdParams* cmdparams);
|
||||
static int ss_event_part(CmdParams* cmdparams);
|
||||
static int ss_event_topic(CmdParams* cmdparams);
|
||||
static int ss_event_kick(CmdParams* cmdparams);
|
||||
|
||||
static User* listu;
|
||||
static int listindex = 0;
|
||||
Bot *ss_bot;
|
||||
static Module* ss_module;
|
||||
|
||||
ModuleEvent module_events[] = {
|
||||
{EVENT_ONLINE, ss_event_online},
|
||||
{EVENT_PONG, ss_event_pong},
|
||||
{EVENT_SERVER, ss_event_server},
|
||||
{EVENT_SQUIT, ss_event_squit},
|
||||
{EVENT_SIGNON, ss_event_signon},
|
||||
{EVENT_GOTNICKIP, ss_event_nickip},
|
||||
{EVENT_UMODE, ss_event_mode},
|
||||
{EVENT_QUIT, ss_event_quit},
|
||||
{EVENT_AWAY, ss_event_away},
|
||||
{EVENT_KILL, ss_event_kill},
|
||||
{EVENT_NEWCHAN, ss_event_newchan},
|
||||
{EVENT_DELCHAN, ss_event_delchan},
|
||||
{EVENT_JOIN, ss_event_join},
|
||||
{EVENT_PART, ss_event_part},
|
||||
{EVENT_KICK, ss_event_kick},
|
||||
{EVENT_TOPIC, ss_event_topic},
|
||||
{EVENT_CTCPVERSION, ss_event_ctcpversion},
|
||||
{EVENT_NULL, NULL}
|
||||
};
|
||||
|
||||
ModuleInfo module_info = {
|
||||
"statserv",
|
||||
"StatServ",
|
||||
"Network statistical service",
|
||||
ns_copyright,
|
||||
ss_about,
|
||||
|
@ -105,104 +146,44 @@ static bot_setting ss_settings[]=
|
|||
{NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
int ss_event_online(CmdParams* cmdparams)
|
||||
static int ss_event_online(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
ss_bot = init_bot (ss_module, &ss_botinfo, services_bot_modes, BOT_FLAG_RESTRICT_OPERS|BOT_FLAG_DEAF, ss_commands, ss_settings);
|
||||
ss_bot = init_bot (&ss_botinfo, services_bot_modes,
|
||||
BOT_FLAG_RESTRICT_OPERS|BOT_FLAG_DEAF, ss_commands, ss_settings);
|
||||
StatServ.onchan = 1;
|
||||
/* now that we are online, setup the timer to save the Stats database every so often */
|
||||
add_timer (ss_module, SaveStats, "SaveStats", DBSAVETIME);
|
||||
add_timer (ss_module, ss_html, "ss_html", 3600);
|
||||
add_timer (SaveStats, "SaveStats", DBSAVETIME);
|
||||
add_timer (ss_html, "ss_html", 3600);
|
||||
/* also add a timer to check if its midnight (to reset the daily stats */
|
||||
add_timer (ss_module, StatsMidnight, "StatsMidnight", 60);
|
||||
add_timer (ss_module, DelOldChan, "DelOldChan", 3600);
|
||||
add_timer (StatsMidnight, "StatsMidnight", 60);
|
||||
add_timer (DelOldChan, "DelOldChan", 3600);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ModInit(Module* mod_ptr)
|
||||
{
|
||||
Server *ss;
|
||||
User *u;
|
||||
hnode_t *node;
|
||||
hscan_t scan;
|
||||
#ifdef SQLSRV
|
||||
lnode_t *lnode;
|
||||
#endif
|
||||
int count, i;
|
||||
Channel *c;
|
||||
char **av;
|
||||
int ac = 0;
|
||||
char *chan;
|
||||
lnode_t *chanmem;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
ss_module = mod_ptr;
|
||||
StatServ.onchan = 0;
|
||||
StatServ.shutdown = 0;
|
||||
/* we want nickip messages */
|
||||
me.want_nickip = 1;
|
||||
|
||||
ModuleConfig(ss_module, ss_settings);
|
||||
me.want_nickip = 1;
|
||||
ModuleConfig(ss_settings);
|
||||
if (StatServ.html && StatServ.htmlpath[0] == 0) {
|
||||
nlog(LOG_NOTICE,
|
||||
"StatServ HTML stats disabled as HTML_PATH is not set");
|
||||
nlog(LOG_NOTICE, "HTML stats disabled as HTML_PATH is not set");
|
||||
StatServ.html = 0;
|
||||
}
|
||||
init_tld();
|
||||
InitTLD();
|
||||
LoadStats();
|
||||
Vhead = list_create(-1);
|
||||
hash_scan_begin(&scan, sh);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
ss = hnode_get(node);
|
||||
ac = 0;
|
||||
AddStringToList(&av, ss->name, &ac);
|
||||
ss_event_server(av, ac);
|
||||
free(av);
|
||||
ac = 0;
|
||||
nlog(LOG_DEBUG2, "Added Server %s to StatServ List", ss->name);
|
||||
}
|
||||
hash_scan_begin(&scan, uh);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
u = hnode_get(node);
|
||||
ac = 0;
|
||||
AddStringToList(&av, u->nick, &ac);
|
||||
ss_event_signon(av, ac);
|
||||
AddStringToList(&av, u->modes, &ac);
|
||||
ss_event_mode(av, ac);
|
||||
free(av);
|
||||
ac = 0;
|
||||
nlog(LOG_DEBUG2, "Add user %s to StatServ List", u->nick);
|
||||
}
|
||||
hash_scan_begin(&scan, ch);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
c = hnode_get(node);
|
||||
count = list_count(c->chanmembers);
|
||||
chanmem = list_first(c->chanmembers);
|
||||
chan = lnode_get(chanmem);
|
||||
ac = 0;
|
||||
AddStringToList(&av, c->name, &ac);
|
||||
ss_event_newchan(av, ac);
|
||||
free(av);
|
||||
ac = 0;
|
||||
for (i = 1; i <= count; i++) {
|
||||
nlog(LOG_DEBUG2, "Chanjoin %s", c->name);
|
||||
ac = 0;
|
||||
AddStringToList(&av, c->name, &ac);
|
||||
AddStringToList(&av, chan, &ac);
|
||||
ss_event_join(av, ac);
|
||||
free(av);
|
||||
ac = 0;
|
||||
if (i < count) {
|
||||
chanmem = list_next(c->chanmembers, chanmem);
|
||||
chan = lnode_get(chanmem);
|
||||
}
|
||||
}
|
||||
}
|
||||
InitStats();
|
||||
|
||||
#ifdef SQLSRV
|
||||
/* ok, now export the server and chan data into the sql emulation layers */
|
||||
|
||||
/* for the network and daily stats, we use a fake list, so we can easily import into rta */
|
||||
|
||||
fakedaily = list_create(-1);
|
||||
|
@ -238,8 +219,11 @@ int ModInit(Module* mod_ptr)
|
|||
void ModFini()
|
||||
{
|
||||
StatServ.shutdown = 1;
|
||||
chanalert(ss_bot->nick, "Saving StatServ Database. this *could* take a while");
|
||||
SaveStats();
|
||||
fini_tld();
|
||||
chanalert(ss_bot->nick, "Done");
|
||||
FiniStats();
|
||||
FiniTLD();
|
||||
save_client_versions();
|
||||
#if SQLSRV
|
||||
list_destroy_nodes(fakedaily);
|
||||
|
@ -250,6 +234,130 @@ void ModFini()
|
|||
#endif
|
||||
}
|
||||
|
||||
static int ss_event_server(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
StatsAddServer(cmdparams->source.server);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_squit(CmdParams* cmdparams)
|
||||
{
|
||||
StatsDelServer(cmdparams->source.server);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_newchan(CmdParams* cmdparams)
|
||||
{
|
||||
StatsAddChan(cmdparams->channel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_delchan(CmdParams* cmdparams)
|
||||
{
|
||||
StatsDelChan(cmdparams->channel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_join(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && (IsExcluded(cmdparams->channel) || IsExcluded(cmdparams->source.user))) {
|
||||
return 0;
|
||||
}
|
||||
StatsJoinChan(cmdparams->source.user, cmdparams->channel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_part(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && (IsExcluded(cmdparams->channel) || IsExcluded(cmdparams->source.user))) {
|
||||
return 0;
|
||||
}
|
||||
StatsPartChan(cmdparams->source.user, cmdparams->channel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_topic(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->channel)) {
|
||||
return 1;
|
||||
}
|
||||
StatsChanTopic(cmdparams->channel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_kick(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->channel)) {
|
||||
return 1;
|
||||
}
|
||||
StatsChanKick(cmdparams->channel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ss_event_ctcpversion(CmdParams* cmdparams)
|
||||
{
|
||||
StatsAddCTCPVersion(cmdparams->av[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_kill(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
StatsKillUser(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_mode(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
StatsUserMode(cmdparams->source.user, cmdparams->av[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_quit(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
StatsDelUser(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_away(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
StatsUserAway(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_nickip(CmdParams* cmdparams)
|
||||
{
|
||||
AddTLD(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_signon(CmdParams* cmdparams)
|
||||
{
|
||||
if (StatServ.exclusions && IsExcluded(cmdparams->source.user)) {
|
||||
return 0;
|
||||
}
|
||||
StatsAddUser(cmdparams->source.user);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_event_pong(CmdParams* cmdparams)
|
||||
{
|
||||
StatsServerPong(cmdparams->source.server);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int topchan(const void *key1, const void *key2)
|
||||
{
|
||||
const CStats *chan1 = key1;
|
||||
|
@ -287,37 +395,13 @@ int topversions(const void *key1, const void *key2)
|
|||
|
||||
static int ss_clientversions(CmdParams* cmdparams)
|
||||
{
|
||||
CVersions *cv;
|
||||
lnode_t *cn;
|
||||
int i;
|
||||
int num;
|
||||
|
||||
chanalert(ss_bot->nick, "%s Wanted to see the Client Version List", cmdparams->source.user->nick);
|
||||
num = cmdparams->ac > 2 ? atoi(cmdparams->av[2]) : 10;
|
||||
if (num < 10) {
|
||||
num = 10;
|
||||
}
|
||||
if (list_count(Vhead) == 0) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "No Stats Available.");
|
||||
return 0;
|
||||
}
|
||||
if (!list_is_sorted(Vhead, topversions)) {
|
||||
list_sort(Vhead, topversions);
|
||||
}
|
||||
cn = list_first(Vhead);
|
||||
cv = lnode_get(cn);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Top%d Client Versions:", num);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "======================");
|
||||
for (i = 0; i <= num; i++) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "%d) %d -> %s", i, cv->count, cv->name);
|
||||
cn = list_next(Vhead, cn);
|
||||
if (cn) {
|
||||
cv = lnode_get(cn);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "End of List.");
|
||||
list_client_versions(cmdparams->source.user, num);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -327,7 +411,6 @@ static int ss_chans(CmdParams* cmdparams)
|
|||
lnode_t *cn;
|
||||
int i;
|
||||
|
||||
chanalert(ss_bot->nick, "%s Wanted to see Channel Statistics", cmdparams->source.user->nick);
|
||||
if (!cmdparams->av[2]) {
|
||||
/* they want the top10 Channels online atm */
|
||||
if (!list_is_sorted(Chead, topchan)) {
|
||||
|
@ -493,17 +576,13 @@ static int ss_chans(CmdParams* cmdparams)
|
|||
static int ss_tld_map(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
chanalert(ss_bot->nick, "%s Wanted to see a Country Breakdown", cmdparams->source.user->nick);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Top Level Domain Statistics:");
|
||||
DisplayTLDmap(cmdparams->source.user);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "End of List");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ss_netstats(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
chanalert(ss_bot->nick, "%s Wanted to see the NetStats ", cmdparams->source.user->nick);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Network Statistics:-----");
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Current Users: %ld", stats_network.users);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Maximum Users: %ld [%s]",
|
||||
|
@ -527,7 +606,6 @@ static int ss_netstats(CmdParams* cmdparams)
|
|||
static int ss_daily(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
chanalert(ss_bot->nick, "%s Wanted to see the Daily NetStats ", cmdparams->source.user->nick);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Daily Network Statistics:");
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Maximum Servers: %-2d %s",
|
||||
daily.servers, sftime(daily.t_servers));
|
||||
|
@ -546,6 +624,7 @@ static int ss_daily(CmdParams* cmdparams)
|
|||
|
||||
static void makemap(char *uplink, User * u, int level)
|
||||
{
|
||||
#if 0
|
||||
hscan_t hs;
|
||||
hnode_t *sn;
|
||||
Server *s;
|
||||
|
@ -556,7 +635,7 @@ static void makemap(char *uplink, User * u, int level)
|
|||
hash_scan_begin(&hs, sh);
|
||||
while ((sn = hash_scan_next(&hs))) {
|
||||
s = hnode_get(sn);
|
||||
ss = findstats(s->name);
|
||||
ss = findserverstats(s->name);
|
||||
if ((level == 0) && (s->uplink[0] == 0)) {
|
||||
/* its the root server */
|
||||
if (StatServ.exclusions && IsExcluded(s)) {
|
||||
|
@ -583,12 +662,12 @@ static void makemap(char *uplink, User * u, int level)
|
|||
makemap(s->name, u, level + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ss_map(CmdParams* cmdparams)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
chanalert(ss_bot->nick, "%s Wanted to see the Current Network MAP", cmdparams->source.user->nick);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "%-40s %-10s %-10s %-10s",
|
||||
"\2[NAME]\2", "\2[USERS/MAX]\2", "\2[OPERS/MAX]\2", "\2[LAG/MAX]\2");
|
||||
makemap("", cmdparams->source.user, 0);
|
||||
|
@ -605,9 +684,7 @@ static int ss_server(CmdParams* cmdparams)
|
|||
char *server;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
server = cmdparams->av[2];
|
||||
chanalert(ss_bot->nick, "%s requested server information on %s",
|
||||
cmdparams->source.user->nick, cmdparams->av[2]);
|
||||
server = cmdparams->av[2];
|
||||
if (!server) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Server listing:");
|
||||
hash_scan_begin(&hs, Shead);
|
||||
|
@ -625,7 +702,7 @@ static int ss_server(CmdParams* cmdparams)
|
|||
}
|
||||
|
||||
/* ok, found the Server, lets do some Statistics work now ! */
|
||||
ss = findstats(server);
|
||||
ss = findserverstats(server);
|
||||
s = findserver(server);
|
||||
if (!ss) {
|
||||
nlog(LOG_CRITICAL, "Unable to find server statistics for %s", server);
|
||||
|
@ -662,7 +739,7 @@ static int ss_server(CmdParams* cmdparams)
|
|||
}
|
||||
if (ss->numsplits >= 1) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick,
|
||||
"%s has split from the network %d time%s",
|
||||
"%s has split from the network %d time %s",
|
||||
ss->name, ss->numsplits, (ss->numsplits == 1) ? "" : "s");
|
||||
} else {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick,"%s has never split from the network.",
|
||||
|
@ -672,90 +749,74 @@ static int ss_server(CmdParams* cmdparams)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int operlistaway = 0;
|
||||
static char* operlistserver;
|
||||
|
||||
static void operlist(User* u)
|
||||
{
|
||||
if (!is_oper(u))
|
||||
return;
|
||||
if (operlistaway && u->is_away)
|
||||
return;
|
||||
if (!operlistserver) {
|
||||
listindex++;
|
||||
prefmsg(listu->nick, ss_bot->nick, "[%2d] %-15s %-15s %-10d", listindex,
|
||||
u->nick, u->server->name, UserLevel(u));
|
||||
} else {
|
||||
if (ircstrcasecmp(operlistserver, u->server->name))
|
||||
return;
|
||||
listindex++;
|
||||
prefmsg(listu->nick, ss_bot->nick, "[%2d] %-15s %-15s %-10d", listindex,
|
||||
u->nick, u->server->name, UserLevel(u));
|
||||
}
|
||||
}
|
||||
|
||||
static int ss_operlist(CmdParams* cmdparams)
|
||||
{
|
||||
register int j = 0;
|
||||
int away = 0;
|
||||
register User *testuser;
|
||||
int ulevel = 0;
|
||||
hscan_t scan;
|
||||
hnode_t *node;
|
||||
char *flags;
|
||||
char *server;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
operlistaway = 0;
|
||||
listindex = 0;
|
||||
if (cmdparams->ac == 2) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Online IRCops:");
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "ID %-15s %-15s %-10s",
|
||||
"Nick", "Server", "Level");
|
||||
chanalert(ss_bot->nick, "%s requested operlist", cmdparams->source.user->nick);
|
||||
}
|
||||
|
||||
flags = cmdparams->av[2];
|
||||
server = cmdparams->av[3];
|
||||
operlistserver = cmdparams->av[3];
|
||||
if (flags && !ircstrcasecmp(flags, "NOAWAY")) {
|
||||
away = 1;
|
||||
operlistaway = 1;
|
||||
flags = NULL;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Online IRCops (not away):");
|
||||
chanalert(ss_bot->nick, "%s requested operlist (not away)", cmdparams->source.user->nick);
|
||||
}
|
||||
if (!away && flags && strchr(flags, '.')) {
|
||||
server = flags;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Online IRCops on server %s", server);
|
||||
chanalert(ss_bot->nick, "%s requested operlist on server %s",
|
||||
cmdparams->source.user->nick, server);
|
||||
}
|
||||
hash_scan_begin(&scan, uh);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
testuser = hnode_get(node);
|
||||
if (!is_oper(testuser))
|
||||
continue;
|
||||
ulevel = UserLevel(testuser);
|
||||
if (ulevel < NS_ULEVEL_OPER)
|
||||
continue;
|
||||
if (away && testuser->is_away)
|
||||
continue;
|
||||
if (!ircstrcasecmp(testuser->server->name, me.services_name))
|
||||
continue;
|
||||
if (!server) {
|
||||
j++;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "[%2d] %-15s %-15s %-10d", j,
|
||||
testuser->nick, testuser->server->name, ulevel);
|
||||
continue;
|
||||
} else {
|
||||
if (ircstrcasecmp(server, testuser->server->name))
|
||||
continue;
|
||||
j++;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "[%2d] %-15s %-15s %-10d", j,
|
||||
testuser->nick, testuser->server->name, ulevel);
|
||||
continue;
|
||||
}
|
||||
if (!operlistaway && flags && strchr(flags, '.')) {
|
||||
operlistserver = flags;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Online IRCops on server %s", operlistserver);
|
||||
}
|
||||
listu = cmdparams->source.user;
|
||||
GetUserList(operlist);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "End of Listing.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GOTBOTMODE
|
||||
static void botlist(User* u)
|
||||
{
|
||||
if is_bot(u) {
|
||||
listindex++;
|
||||
prefmsg(listu->nick, ss_bot->nick,"[%2d] %-15s %s", listindex,
|
||||
u->nick, u->server->name);
|
||||
}
|
||||
}
|
||||
|
||||
static int ss_botlist(CmdParams* cmdparams)
|
||||
{
|
||||
register int j = 0;
|
||||
register User *testuser;
|
||||
hscan_t scan;
|
||||
hnode_t *node;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
chanalert(ss_bot->nick, "%s Wanted to see the Bot List", cmdparams->source.user->nick);
|
||||
listindex = 0;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "On-Line Bots:");
|
||||
hash_scan_begin(&scan, uh);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
testuser = hnode_get(node);
|
||||
if is_bot(testuser) {
|
||||
j++;
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick,"[%2d] %-15s %s", j,
|
||||
testuser->nick, testuser->server->name);
|
||||
}
|
||||
}
|
||||
listu = cmdparams->source.user;
|
||||
GetUserList(botlist);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "End of Listing.");
|
||||
return 1;
|
||||
}
|
||||
|
@ -787,7 +848,7 @@ static int ss_stats(CmdParams* cmdparams)
|
|||
ss_bot->nick);
|
||||
return 0;
|
||||
}
|
||||
st = findstats(cmdparams->av[3]);
|
||||
st = findserverstats(cmdparams->av[3]);
|
||||
if (!st) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "%s is not in the database", cmdparams->av[3]);
|
||||
return 0;
|
||||
|
@ -821,11 +882,11 @@ static int ss_stats(CmdParams* cmdparams)
|
|||
" <newname>", ss_bot->nick);
|
||||
return 0;
|
||||
}
|
||||
st = findstats(cmdparams->av[4]);
|
||||
st = findserverstats(cmdparams->av[4]);
|
||||
if (st)
|
||||
free(st);
|
||||
|
||||
st = findstats(cmdparams->av[3]);
|
||||
st = findserverstats(cmdparams->av[3]);
|
||||
if (!st) {
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "%s is not in the database",
|
||||
cmdparams->av[3]);
|
||||
|
@ -853,8 +914,6 @@ static int ss_forcehtml(CmdParams* cmdparams)
|
|||
{
|
||||
nlog(LOG_NOTICE, "%s!%s@%s forced an update of the HTML file.",
|
||||
cmdparams->source.user->nick, cmdparams->source.user->username, cmdparams->source.user->hostname);
|
||||
chanalert(ss_bot->nick, "%s forced an update of the HTML file.",
|
||||
cmdparams->source.user->nick);
|
||||
ss_html();
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
#define STATSERV_H
|
||||
|
||||
#include "neostats.h"
|
||||
#include "m_stats.h"
|
||||
|
||||
/* this is the max number of statserv channels our database can hold... */
|
||||
#define SS_CHAN_SIZE -1
|
||||
|
||||
/* this is the how often to save a portion of the DB. Don't alter this unless you need to */
|
||||
/* DO NOT set PROGCHANTIME less than ((DBSAVETIME + (DBSAVETIME/2)) * 4) otherwise you will not have the enitre database progressively saved! */
|
||||
|
@ -41,17 +37,11 @@
|
|||
#define PROGCHANTIME 3600
|
||||
|
||||
extern Bot *ss_bot;
|
||||
extern ModuleInfo module_info;
|
||||
|
||||
typedef struct tld_ TLD;
|
||||
typedef struct region_ Region;
|
||||
typedef struct server_stats SStats;
|
||||
typedef struct chan_stats CStats;
|
||||
typedef struct irc_client_version CVersions;
|
||||
hash_t *Shead;
|
||||
list_t *Chead;
|
||||
list_t *Thead;
|
||||
list_t *Vhead;
|
||||
extern hash_t *Shead;
|
||||
extern list_t *Chead;
|
||||
extern list_t *Thead;
|
||||
extern list_t *Vhead;
|
||||
|
||||
struct stats_network_ {
|
||||
long opers;
|
||||
|
@ -78,7 +68,6 @@ struct StatServ {
|
|||
int html;
|
||||
char htmlpath[MAXPATH];
|
||||
int onchan;
|
||||
int newdb;
|
||||
int msginterval;
|
||||
int msglimit;
|
||||
int shutdown;
|
||||
|
@ -87,8 +76,7 @@ struct StatServ {
|
|||
} StatServ;
|
||||
|
||||
|
||||
struct server_stats {
|
||||
SStats *next, *prev;
|
||||
typedef struct SStats {
|
||||
char name[MAXHOST];
|
||||
unsigned int users;
|
||||
int opers;
|
||||
|
@ -107,16 +95,14 @@ struct server_stats {
|
|||
unsigned int serverkills;
|
||||
long totusers;
|
||||
long daily_totusers;
|
||||
};
|
||||
}SStats;
|
||||
|
||||
#define MAX_CLIENT_VERSION_NAME 512
|
||||
|
||||
struct irc_client_version {
|
||||
char name[MAX_CLIENT_VERSION_NAME];
|
||||
typedef struct CVersions {
|
||||
char name[BUFSIZE];
|
||||
int count;
|
||||
};
|
||||
}CVersions;
|
||||
|
||||
struct chan_stats {
|
||||
typedef struct CStats {
|
||||
char name[CHANLEN];
|
||||
long members;
|
||||
long topics;
|
||||
|
@ -135,7 +121,7 @@ struct chan_stats {
|
|||
long maxjoins;
|
||||
time_t t_maxjoins;
|
||||
time_t lastsave;
|
||||
};
|
||||
}CStats;
|
||||
|
||||
struct daily_ {
|
||||
int servers;
|
||||
|
@ -149,41 +135,56 @@ struct daily_ {
|
|||
time_t t_chans;
|
||||
} daily;
|
||||
|
||||
struct tld_ {
|
||||
typedef struct TLD {
|
||||
char tld[5];
|
||||
char country[32];
|
||||
int users;
|
||||
int daily_users;
|
||||
/* for region/isp edition of GeoIP */
|
||||
list_t *rl;
|
||||
};
|
||||
}TLD;
|
||||
|
||||
struct region_ {
|
||||
typedef struct Region {
|
||||
char *region;
|
||||
int users;
|
||||
int daily_users;
|
||||
};
|
||||
}Region;
|
||||
|
||||
int StatsMidnight(void);
|
||||
/* statserv.c */
|
||||
void statserv(char *);
|
||||
int topchan(const void *key1, const void *key2);
|
||||
int topjoin(const void *key1, const void *key2);
|
||||
int topkick(const void *key1, const void *key2);
|
||||
int toptopics(const void *key1, const void *key2);
|
||||
int topversions(const void *key1, const void *key2);
|
||||
/* stats.c */
|
||||
void list_client_versions(User* u, int num);
|
||||
int load_client_versions(void);
|
||||
int save_client_versions(void);
|
||||
void AddStats(Server *);
|
||||
SStats *findstats(char *);
|
||||
int SaveStats();
|
||||
void LoadStats();
|
||||
CStats *findchanstats(char *);
|
||||
#if 0
|
||||
CStats *AddChanStats(char *);
|
||||
#endif
|
||||
int DelOldChan();
|
||||
void StatsAddServer(Server* s);
|
||||
void StatsDelServer(Server* s);
|
||||
void StatsServerPong(Server* s);
|
||||
SStats *findserverstats(char *name);
|
||||
void StatsAddCTCPVersion(char* version);
|
||||
void StatsAddUser(User* u);
|
||||
void StatsDelUser(User* u);
|
||||
void StatsKillUser(User* u);
|
||||
void StatsUserMode(User* u, char *modes);
|
||||
void StatsUserAway(User* u);
|
||||
void InitStats(void);
|
||||
void FiniStats(void);
|
||||
|
||||
int SaveStats(void);
|
||||
void LoadStats(void);
|
||||
|
||||
CStats *findchanstats(char *name);
|
||||
void StatsAddChan(Channel* c);
|
||||
void StatsDelChan(Channel* c);
|
||||
void StatsJoinChan(User* u, Channel* c);
|
||||
void StatsPartChan(User* u, Channel* c);
|
||||
void StatsChanTopic(Channel* c);
|
||||
void StatsChanKick(Channel* c);
|
||||
int DelOldChan(void);
|
||||
|
||||
/* database.c */
|
||||
void save_chan(CStats *c);
|
||||
|
@ -236,8 +237,8 @@ int sortusers(const void *v, const void *v2);
|
|||
void ResetTLD();
|
||||
void DisplayTLDmap(User *u);
|
||||
void AddTLD(User *);
|
||||
void init_tld();
|
||||
void fini_tld();
|
||||
void InitTLD(void);
|
||||
void FiniTLD(void);
|
||||
/* htmlstats.c */
|
||||
int ss_html(void);
|
||||
|
||||
|
|
|
@ -32,11 +32,13 @@
|
|||
#include "GeoIP.h"
|
||||
#include "GeoIPCity.h"
|
||||
|
||||
list_t *Thead;
|
||||
GeoIP *gi;
|
||||
|
||||
void _setup_dbfilename();
|
||||
|
||||
void ResetTLD() {
|
||||
void ResetTLD()
|
||||
{
|
||||
lnode_t *tn, *tn2;
|
||||
TLD *t;
|
||||
|
||||
|
@ -70,10 +72,12 @@ int sortusers(const void *v, const void *v2) {
|
|||
return (t2->users - t->users);
|
||||
}
|
||||
|
||||
void DisplayTLDmap(User *u) {
|
||||
void DisplayTLDmap(User *u)
|
||||
{
|
||||
TLD *t;
|
||||
lnode_t *tn;
|
||||
|
||||
prefmsg(u->nick, ss_bot->nick, "Top Level Domain Statistics:");
|
||||
list_sort(Thead, sortusers);
|
||||
tn = list_first(Thead);
|
||||
while (tn) {
|
||||
|
@ -81,11 +85,11 @@ void DisplayTLDmap(User *u) {
|
|||
prefmsg(u->nick, ss_bot->nick,
|
||||
"%3s \2%3d\2 (%2.0f%%) -> %s ---> Daily Total: %d",
|
||||
t->tld, t->users,
|
||||
(float) t->users /
|
||||
(float) stats_network.users * 100,
|
||||
((float) t->users / (float) stats_network.users) * 100,
|
||||
t->country, t->daily_users);
|
||||
tn = list_next(Thead, tn);
|
||||
}
|
||||
prefmsg(u->nick, ss_bot->nick, "End of List");
|
||||
}
|
||||
|
||||
void DelTLD(User * u)
|
||||
|
@ -94,8 +98,8 @@ void DelTLD(User * u)
|
|||
const char *ipaddr;
|
||||
lnode_t *tn;
|
||||
TLD *t = NULL;
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
if (!gi) {
|
||||
return;
|
||||
}
|
||||
|
@ -124,11 +128,9 @@ void AddTLD(User * u)
|
|||
|
||||
if (!gi) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
ipaddr = inet_ntoa(u->ipaddr);
|
||||
country_code = GeoIP_country_code_by_addr(gi, ipaddr);
|
||||
|
||||
if (country_code) {
|
||||
tn = list_find(Thead, country_code, findcc);
|
||||
} else {
|
||||
|
@ -151,16 +153,16 @@ void AddTLD(User * u)
|
|||
return;
|
||||
}
|
||||
|
||||
void init_tld()
|
||||
void InitTLD(void)
|
||||
{
|
||||
TLD *t;
|
||||
lnode_t *tn;
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
Thead = list_create(-1);
|
||||
gi = NULL;
|
||||
/* setup the GeoIP db filenames */
|
||||
_setup_dbfilename();
|
||||
|
||||
_setup_dbfilename();
|
||||
StatServ.GeoDBtypes = -1;
|
||||
/* now open the various DB's */
|
||||
if (GeoIP_db_avail(GEOIP_COUNTRY_EDITION)) {
|
||||
|
@ -173,17 +175,15 @@ void init_tld()
|
|||
} else {
|
||||
nlog(LOG_WARNING, "GeoIP Database is not available. TLD stats will not be available");
|
||||
}
|
||||
Thead = list_create(-1);
|
||||
t = malloc(sizeof(TLD));
|
||||
bzero(t, sizeof(TLD));
|
||||
t = scalloc(sizeof(TLD));
|
||||
ircsnprintf(t->tld, 5, "???");
|
||||
strlcpy(t->country, "Unknown", 8);
|
||||
tn = lnode_create(t);
|
||||
list_append(Thead, tn);
|
||||
|
||||
}
|
||||
|
||||
void fini_tld() {
|
||||
void FiniTLD(void)
|
||||
{
|
||||
TLD *t;
|
||||
lnode_t *tn;
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond, Mark Hetherington
|
||||
** http://www.neostats.net/
|
||||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** 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 2 of the License, or
|
||||
|
@ -27,36 +25,41 @@
|
|||
* You can copy this file as a template for writing your own modules
|
||||
*/
|
||||
|
||||
#include "neostats.h" /* Neostats API */
|
||||
/* neostats.h is the only required include for your module to access the
|
||||
* NeoStats module API. You should not need to include any other NeoStats
|
||||
* files in order to develop your module.
|
||||
*/
|
||||
#include "neostats.h" /* NeoStats API */
|
||||
|
||||
/** When we create a a bot, we must store the handle returned to us for use
|
||||
* when calling API bot functions
|
||||
*/
|
||||
static Bot *template_bot;
|
||||
|
||||
/** When a module loads, it is passed a handle that must be used when calling
|
||||
* API functions.
|
||||
/** When a module loads, it is passed a handle that includes information
|
||||
* we might need later so you should store this.
|
||||
*/
|
||||
static Module* template_module;
|
||||
|
||||
/** Define information about our bot
|
||||
*/
|
||||
BotInfo template_bot_info = {
|
||||
BotInfo template_bot_info =
|
||||
{
|
||||
/* REQUIRED:
|
||||
* nick */
|
||||
"TemplateBot",
|
||||
"changeme",
|
||||
/* OPTIONAL:
|
||||
* altnick, use "" if not needed */
|
||||
"",
|
||||
"altnick",
|
||||
/* REQUIRED:
|
||||
* user */
|
||||
"user",
|
||||
"changeme",
|
||||
/* REQUIRED:
|
||||
* host */
|
||||
"",
|
||||
/* REQUIRED:
|
||||
* realname */
|
||||
"Real Name",
|
||||
"Example NeoStats module",
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -129,7 +132,7 @@ ModuleInfo module_info = {
|
|||
static int tm_event_online(CmdParams* cmdparams)
|
||||
{
|
||||
/* Introduce a bot onto the network saving the bot handle */
|
||||
template_bot = init_bot ( template_module, &template_bot_info, "-x", 0, NULL, NULL);
|
||||
template_bot = init_bot ( &template_bot_info, "-x", 0, NULL, NULL);
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
@ -149,7 +152,7 @@ ModuleEvent module_events[] = {
|
|||
*/
|
||||
int ModInit(Module* mod_ptr)
|
||||
{
|
||||
/* Save our module handle so we can use API functions */
|
||||
/* Save our module handle */
|
||||
template_module = mod_ptr;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -53,17 +53,10 @@
|
|||
/*#define USE_BERKELEY*/
|
||||
#endif
|
||||
|
||||
/* Temp disable for upcoming release until all external modules
|
||||
* have been released with warnings fixed
|
||||
*/
|
||||
#if 0
|
||||
#define __attribute__(x) /* NOTHING */
|
||||
#else
|
||||
/* If we're not using GNU C, elide __attribute__ */
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x) /* NOTHING */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NeoStats core API version.
|
||||
|
@ -106,9 +99,9 @@
|
|||
#endif
|
||||
|
||||
#ifdef NEOSTATS_REVISION
|
||||
#define NEOSTATS_VERSION NEOSTATS_PACKAGE_VERSION " (" NEOSTATS_REVISION ")"
|
||||
#define NEOSTATS_VERSION NEOSTATS_PACKAGE_VERSION " (" NEOSTATS_REVISION ")" NS_PROTOCOL
|
||||
#else
|
||||
#define NEOSTATS_VERSION NEOSTATS_PACKAGE_VERSION
|
||||
#define NEOSTATS_VERSION NEOSTATS_PACKAGE_VERSION NS_PROTOCOL
|
||||
#endif
|
||||
#define CORE_MODULE_VERSION NEOSTATS_VERSION
|
||||
|
||||
|
@ -296,28 +289,9 @@ typedef enum NS_TRANSFER {
|
|||
#define CLEAR_SEGV_LOCATION() segv_location[0]='\0';
|
||||
#endif
|
||||
|
||||
#define SEGV_INMODULE_BUFSIZE MAX_MOD_NAME
|
||||
#define SET_SEGV_INMODULE(module_name) strlcpy(segv_inmodule,(module_name),SEGV_INMODULE_BUFSIZE);
|
||||
#define CLEAR_SEGV_INMODULE() segv_inmodule[0]='\0';
|
||||
|
||||
/* macros to provide a couple missing string functions for code legibility
|
||||
* and to ensure we perform these operations in a standard and optimal manner
|
||||
*/
|
||||
/* set a string to NULL */
|
||||
#define strsetnull(str) (str)[0] = 0
|
||||
/* test a string for NULL */
|
||||
#define strisnull(str) ((str) && (str)[0] == 0)
|
||||
|
||||
#define ARRAY_COUNT (a) ((sizeof ((a)) / sizeof ((a)[0]))
|
||||
|
||||
extern char recbuf[BUFSIZE];
|
||||
extern const char services_bot_modes[];
|
||||
extern char segv_location[SEGV_LOCATION_BUFSIZE];
|
||||
extern char segv_inmodule[SEGV_INMODULE_BUFSIZE];
|
||||
|
||||
extern hash_t *sh;
|
||||
extern hash_t *uh;
|
||||
extern hash_t *ch;
|
||||
|
||||
/* this is the dns structure */
|
||||
extern adns_state ads;
|
||||
|
@ -388,7 +362,6 @@ struct me {
|
|||
int sqlport;
|
||||
#endif
|
||||
char version[VERSIONSIZE];
|
||||
char versionfull[VERSIONSIZE];
|
||||
} me;
|
||||
|
||||
/** @brief Bans structure
|
||||
|
@ -696,6 +669,21 @@ typedef struct Module {
|
|||
unsigned int modnum;
|
||||
}Module;
|
||||
|
||||
extern Module* RunModule[10];
|
||||
extern int RunLevel;
|
||||
|
||||
/* Simple stack to manage run level replacing original segv_module stuff
|
||||
* which will hopefully make it easier to determine where we are running
|
||||
* and avoid the need for modules to ever manage this and the core to
|
||||
* have to set/reset when a module calls a core function which triggers
|
||||
* other modules to run (e.g. init_bot)
|
||||
*/
|
||||
#define SET_RUN_LEVEL(moduleptr) {if(RunLevel<10 && RunModule[RunLevel] != moduleptr){RunLevel++;RunModule[RunLevel] = moduleptr;}}
|
||||
#define RESET_RUN_LEVEL() {if(RunLevel>0){RunLevel--;}}
|
||||
#define GET_CUR_MODULE() RunModule[RunLevel]
|
||||
#define GET_CUR_MODNUM() RunModule[RunLevel]->modnum
|
||||
#define GET_CUR_MODNAME() RunModule[RunLevel]->info->name
|
||||
|
||||
/** @brief Module socket list structure
|
||||
*
|
||||
*/
|
||||
|
@ -781,25 +769,25 @@ typedef struct _Bot {
|
|||
unsigned int set_ulevel;
|
||||
}_Bot;
|
||||
|
||||
int ModuleConfig(Module* moduleptr, bot_setting* bot_settings);
|
||||
int ModuleConfig(bot_setting* bot_settings);
|
||||
|
||||
int add_timer (Module* moduleptr, timer_function func, char* name, int interval);
|
||||
int add_timer (timer_function func, char* name, int interval);
|
||||
int del_timer (char *timer_name);
|
||||
int set_timer_interval (char *timer_name, int interval);
|
||||
Timer *findtimer(char *timer_name);
|
||||
|
||||
int add_socket (Module* moduleptr, socket_function readfunc, socket_function writefunc, socket_function errfunc, char *sock_name, int socknum);
|
||||
int add_sockpoll (Module* moduleptr, before_poll_function beforepoll, after_poll_function afterpoll, char *sock_name, void *data);
|
||||
int add_socket (socket_function readfunc, socket_function writefunc, socket_function errfunc, char *sock_name, int socknum);
|
||||
int add_sockpoll (before_poll_function beforepoll, after_poll_function afterpoll, char *sock_name, void *data);
|
||||
int del_socket (char *name);
|
||||
Sock *findsock (char *sock_name);
|
||||
|
||||
Bot * init_bot (Module* modptr, BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd *bot_cmd_list, bot_setting *bot_setting_list);
|
||||
Bot * init_bot (BotInfo* botinfo, const char* modes, unsigned int flags, bot_cmd *bot_cmd_list, bot_setting *bot_setting_list);
|
||||
int del_bot (Bot *botptr, char * reason);
|
||||
Bot *findbot (char * bot_name);
|
||||
int bot_nick_change (char * oldnick, char *newnick);
|
||||
|
||||
/* sock.c */
|
||||
int sock_connect (Module* moduleptr, int socktype, unsigned long ipaddr, int port, char *module, socket_function func_read, socket_function func_write, socket_function func_error);
|
||||
int sock_connect (int socktype, unsigned long ipaddr, int port, char *module, socket_function func_read, socket_function func_write, socket_function func_error);
|
||||
int sock_disconnect (char *name);
|
||||
|
||||
/* conf.c */
|
||||
|
@ -958,12 +946,13 @@ typedef enum LOG_LEVEL {
|
|||
LOG_DEBUG2, /* more debug notices that are usefull */
|
||||
LOG_DEBUG3, /* even more stuff, that would be useless to most normal people */
|
||||
LOG_DEBUG4, /* are you insane? */
|
||||
LOG_LEVELMAX, /* are you insane? */
|
||||
} LOG_LEVEL;
|
||||
|
||||
/* define debug levels */
|
||||
|
||||
typedef enum DEBUG_LEVEL {
|
||||
DEBUG1,
|
||||
DEBUG1=1,
|
||||
DEBUG2,
|
||||
DEBUG3,
|
||||
DEBUG4,
|
||||
|
@ -972,6 +961,8 @@ typedef enum DEBUG_LEVEL {
|
|||
DEBUG7,
|
||||
DEBUG8,
|
||||
DEBUG9,
|
||||
DEBUG10,
|
||||
DEBUGMAX,
|
||||
} DEBUG_LEVEL;
|
||||
|
||||
/* this is for the neostats assert replacement. */
|
||||
|
@ -1007,6 +998,13 @@ void nlog (LOG_LEVEL level, char *fmt, ...) __attribute__((format(printf,2,3)));
|
|||
|
||||
int CloakHost (Bot *bot_ptr);
|
||||
|
||||
typedef void (*ChannelListHandler) (Channel * c);
|
||||
void GetChannelList(ChannelListHandler handler);
|
||||
typedef void (*UserListHandler) (User * u);
|
||||
void GetUserList(UserListHandler handler);
|
||||
typedef void (*ServerListHandler) (Server * s);
|
||||
void GetServerList(ServerListHandler handler);
|
||||
|
||||
/*
|
||||
* Module Interface
|
||||
*/
|
||||
|
|
|
@ -52,7 +52,6 @@ static void m_svinfo (char *origin, char **argv, int argc, int srv);
|
|||
static void m_burst (char *origin, char **argv, int argc, int srv);
|
||||
static void m_sjoin (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(B)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
|
||||
ircd_cmd cmd_list[] = {
|
||||
|
|
|
@ -49,7 +49,6 @@ static void m_burst (char *origin, char **argv, int argc, int srv);
|
|||
static void m_sjoin (char *origin, char **argv, int argc, int srv);
|
||||
static void m_protoctl (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(H)";
|
||||
const char services_bot_modes[]= "+o";
|
||||
|
||||
/* this is the command list and associated functions to run */
|
||||
|
|
|
@ -60,7 +60,6 @@ static void m_end_of_burst (char *origin, char **argv, int argc, int srv);
|
|||
void send_end_of_burst_ack(void);
|
||||
void send_end_of_burst(void);
|
||||
|
||||
const char ircd_version[] = "(IRCu)";
|
||||
const char services_bot_modes[]= "+iok";
|
||||
|
||||
/* this is the command list and associated functions to run */
|
||||
|
|
|
@ -53,7 +53,6 @@ static void m_svinfo (char *origin, char **argv, int argc, int srv);
|
|||
static void m_burst (char *origin, char **argv, int argc, int srv);
|
||||
static void m_sjoin (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(L)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
|
||||
ircd_cmd cmd_list[] = {
|
||||
|
|
|
@ -53,7 +53,6 @@ static void m_svsnick (char *origin, char **argv, int argc, int srv);
|
|||
static void m_protoctl (char *origin, char **argv, int argc, int srv);
|
||||
static void m_vctrl (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(M)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
|
||||
ircd_cmd cmd_list[] = {
|
||||
|
|
|
@ -49,7 +49,6 @@ static void m_burst (char *origin, char **argv, int argc, int srv);
|
|||
static void m_sjoin (char *origin, char **argv, int argc, int srv);
|
||||
static void m_tburst (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(N)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
|
||||
/* this is the command list and associated functions to run */
|
||||
|
|
|
@ -57,7 +57,6 @@ static void m_vctrl (char *origin, char **argv, int argc, int srv);
|
|||
static void m_client (char *origin, char **argv, int argc, int srv);
|
||||
static void m_smode (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(Q)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
|
||||
ircd_cmd cmd_list[] = {
|
||||
|
|
|
@ -62,10 +62,8 @@ static void m_snetinfo (char *origin, char **argv, int argc, int srv);
|
|||
static void m_vctrl (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
#ifdef ULTIMATE3
|
||||
const char ircd_version[] = "(UL3)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
#else
|
||||
const char ircd_version[] = "(UL)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
#endif
|
||||
|
||||
|
|
|
@ -63,11 +63,6 @@ static void m_tkl (char *origin, char **argv, int argc, int srv);
|
|||
|
||||
#define NICKV2
|
||||
|
||||
#ifdef UNREAL32
|
||||
const char ircd_version[] = "(U32)";
|
||||
#else
|
||||
const char ircd_version[] = "(U31)";
|
||||
#endif
|
||||
const char services_bot_modes[]= "+oSq";
|
||||
|
||||
ircd_cmd cmd_list[] = {
|
||||
|
|
|
@ -52,7 +52,6 @@ static void m_svinfo (char *origin, char **argv, int argc, int srv);
|
|||
static void m_burst (char *origin, char **argv, int argc, int srv);
|
||||
static void m_sjoin (char *origin, char **argv, int argc, int srv);
|
||||
|
||||
const char ircd_version[] = "(V)";
|
||||
const char services_bot_modes[]= "+oS";
|
||||
|
||||
ircd_cmd cmd_list[] = {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** Portions Copyright (c) 1999 Johnathan George net@lite.net
|
||||
**
|
||||
** 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 2 of the License, or
|
||||
|
@ -34,7 +32,7 @@
|
|||
#include "sqlsrv/rta.h"
|
||||
#endif
|
||||
|
||||
hash_t *sh;
|
||||
static hash_t *sh;
|
||||
|
||||
static Server *
|
||||
new_server (const char *name)
|
||||
|
@ -47,12 +45,12 @@ new_server (const char *name)
|
|||
strlcpy (s->name, name, MAXHOST);
|
||||
sn = hnode_create (s);
|
||||
if (!sn) {
|
||||
nlog (LOG_WARNING, "Server hash broken\n");
|
||||
nlog (LOG_WARNING, "Server hash broken");
|
||||
free (s);
|
||||
return NULL;
|
||||
}
|
||||
if (hash_isfull (sh)) {
|
||||
nlog (LOG_WARNING, "Server hash full\n");
|
||||
nlog (LOG_WARNING, "Server hash full");
|
||||
free (s);
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -295,7 +293,7 @@ InitServers (void)
|
|||
{
|
||||
sh = hash_create (S_TABLE_SIZE, 0, 0);
|
||||
if (!sh) {
|
||||
nlog (LOG_CRITICAL, "Create Server Hash Failed\n");
|
||||
nlog (LOG_CRITICAL, "Unable to create server hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
AddServer (me.name, NULL, 0, NULL, me.infoline);
|
||||
|
@ -346,3 +344,17 @@ FiniServers (void)
|
|||
}
|
||||
hash_destroy(sh);
|
||||
}
|
||||
|
||||
void GetServerList(ServerListHandler handler)
|
||||
{
|
||||
hnode_t *node;
|
||||
hscan_t scan;
|
||||
Server *ss;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
hash_scan_begin(&scan, sh);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
ss = hnode_get(node);
|
||||
handler(ss);
|
||||
}
|
||||
}
|
||||
|
|
107
src/services.c
107
src/services.c
|
@ -4,8 +4,6 @@
|
|||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** Portions Copyright (c) 1999 Johnathan George net@lite.net
|
||||
**
|
||||
** 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 2 of the License, or
|
||||
|
@ -75,7 +73,7 @@ ModuleInfo ns_module_info = {
|
|||
0,
|
||||
};
|
||||
|
||||
static Module ns_module = {
|
||||
Module ns_module = {
|
||||
&ns_module_info
|
||||
};
|
||||
|
||||
|
@ -125,10 +123,17 @@ init_services_bot (void)
|
|||
unsigned int flags;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
/* if all bots should join the chan */
|
||||
if (GetConf ((void *) &me.allbots, CFGINT, "AllBotsJoinChan") <= 0) {
|
||||
me.allbots = 0;
|
||||
}
|
||||
if (GetConf ((void *) &me.pingtime, CFGINT, "PingServerTime") <= 0) {
|
||||
me.pingtime = 120;
|
||||
}
|
||||
ircsnprintf (ns_botinfo.realname, MAXREALNAME, "/msg %s \2HELP\2", ns_botinfo.nick);
|
||||
flags = me.onlyopers ? BOT_FLAG_ONLY_OPERS : 0;
|
||||
flags |= BOT_FLAG_DEAF;
|
||||
ns_botptr = init_bot (&ns_module, &ns_botinfo, services_bot_modes, flags, ns_commands, NULL);
|
||||
ns_botptr = init_bot (&ns_botinfo, services_bot_modes, flags, ns_commands, NULL);
|
||||
me.onchan = 1;
|
||||
SendAllModuleEvent (EVENT_ONLINE, NULL);
|
||||
return NS_SUCCESS;
|
||||
|
@ -138,9 +143,7 @@ init_services_bot (void)
|
|||
*
|
||||
* maintain global exclusion list, which modules can take advantage off
|
||||
*
|
||||
* @param u user
|
||||
* @param av list of arguments
|
||||
* @param ac number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
|
@ -149,20 +152,18 @@ ns_exclude (CmdParams* cmdparams)
|
|||
{
|
||||
if (!ircstrcasecmp(cmdparams->av[0], "ADD")) {
|
||||
if (cmdparams->ac < 3) {
|
||||
prefmsg(cmdparams->source.user->nick, ns_botptr->nick, "Syntax error. /msg %s help exclude", ns_botptr->nick);
|
||||
return NS_FAILURE;
|
||||
return NS_ERR_NEED_MORE_PARAMS;
|
||||
}
|
||||
ns_do_exclude_add(cmdparams->source.user, cmdparams->av[0], cmdparams->av[1]);
|
||||
} else if (!ircstrcasecmp(cmdparams->av[0], "DEL")) {
|
||||
if (cmdparams->ac < 2) {
|
||||
prefmsg(cmdparams->source.user->nick, ns_botptr->nick, "Syntax error. /msg %s help exclude", ns_botptr->nick);
|
||||
return NS_FAILURE;
|
||||
return NS_ERR_NEED_MORE_PARAMS;
|
||||
}
|
||||
ns_do_exclude_del(cmdparams->source.user, cmdparams->av[1]);
|
||||
} else if (!ircstrcasecmp(cmdparams->av[0], "LIST")) {
|
||||
ns_do_exclude_list(cmdparams->source.user, ns_botptr->nick);
|
||||
} else {
|
||||
prefmsg(cmdparams->source.user->nick, ns_botptr->nick, "Syntax error. /msg %s help exclude", ns_botptr->nick);
|
||||
return NS_ERR_SYNTAX_ERROR;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
@ -170,9 +171,7 @@ ns_exclude (CmdParams* cmdparams)
|
|||
*
|
||||
* Shutdown NeoStats
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -192,9 +191,7 @@ ns_shutdown (CmdParams* cmdparams)
|
|||
*
|
||||
* Reload NeoStats
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -214,9 +211,7 @@ ns_reload (CmdParams* cmdparams)
|
|||
*
|
||||
* Jupiter a server
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -237,9 +232,7 @@ ns_jupe (CmdParams* cmdparams)
|
|||
*
|
||||
* Set debug mode on/off
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -255,9 +248,7 @@ ns_set_debug (CmdParams* cmdparams)
|
|||
globops (me.name, "\2DEBUG MODE\2 disabled by %s", cmdparams->source.user->nick);
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "Debug mode disabled");
|
||||
} else {
|
||||
prefmsg(cmdparams->source.user->nick, ns_botptr->nick,
|
||||
"Syntax Error: /msg %s HELP DEBUG for more info", ns_botptr->nick);
|
||||
return NS_FAILURE;
|
||||
return NS_ERR_SYNTAX_ERROR;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
@ -266,9 +257,7 @@ ns_set_debug (CmdParams* cmdparams)
|
|||
*
|
||||
* Dump user list
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -279,13 +268,7 @@ ns_userdump (CmdParams* cmdparams)
|
|||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "\2Error:\2 debug mode disabled");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
if(cmdparams->ac < 1) {
|
||||
chanalert (ns_botptr->nick, "\2DEBUG\2 %s requested a user dump", cmdparams->source.user->nick);
|
||||
UserDump (NULL);
|
||||
} else {
|
||||
chanalert (ns_botptr->nick, "\2DEBUG\2 %s requested a user dump for %s", cmdparams->source.user->nick, cmdparams->av[0]);
|
||||
UserDump (cmdparams->av[0]);
|
||||
}
|
||||
UserDump ((cmdparams->ac < 1)? NULL : cmdparams->av[0]);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -293,9 +276,7 @@ ns_userdump (CmdParams* cmdparams)
|
|||
*
|
||||
* Dump server list
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -306,13 +287,7 @@ ns_serverdump (CmdParams* cmdparams)
|
|||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "\2Error:\2 debug mode disabled");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
if(cmdparams->ac < 1) {
|
||||
chanalert (ns_botptr->nick, "\2DEBUG\2 %s requested a server dump", cmdparams->source.user->nick);
|
||||
ServerDump (NULL);
|
||||
} else {
|
||||
chanalert (ns_botptr->nick, "\2DEBUG\2 %s requested a server dump for %s", cmdparams->source.user->nick, cmdparams->av[0]);
|
||||
ServerDump (cmdparams->av[0]);
|
||||
}
|
||||
ServerDump ((cmdparams->ac < 1)? NULL : cmdparams->av[0]);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -320,9 +295,7 @@ ns_serverdump (CmdParams* cmdparams)
|
|||
*
|
||||
* Dump channel list
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -333,13 +306,7 @@ ns_chandump (CmdParams* cmdparams)
|
|||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "\2Error:\2 debug mode disabled");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
if(cmdparams->ac < 1) {
|
||||
chanalert (ns_botptr->nick, "\2DEBUG\2 %s requested a channel dump", cmdparams->source.user->nick);
|
||||
ChanDump (NULL);
|
||||
} else {
|
||||
chanalert (ns_botptr->nick, "\2DEBUG\2 %s requested a channel dump for %s", cmdparams->source.user->nick, cmdparams->av[0]);
|
||||
ChanDump (cmdparams->av[0]);
|
||||
}
|
||||
ChanDump ((cmdparams->ac < 1)? NULL : cmdparams->av[0]);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -347,9 +314,7 @@ ns_chandump (CmdParams* cmdparams)
|
|||
*
|
||||
* Display NeoStats status
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -384,9 +349,7 @@ ns_status (CmdParams* cmdparams)
|
|||
*
|
||||
* Display user level
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -398,9 +361,11 @@ ns_level (CmdParams* cmdparams)
|
|||
} else {
|
||||
User * otheruser;
|
||||
otheruser = finduser(cmdparams->av[0]);
|
||||
if(otheruser) {
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "User level for %s is %d", otheruser->nick, UserLevel (otheruser));
|
||||
if(!otheruser) {
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "User %s not found", cmdparams->av[0]);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
prefmsg (cmdparams->source.user->nick, ns_botptr->nick, "User level for %s is %d", otheruser->nick, UserLevel (otheruser));
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
@ -409,9 +374,7 @@ ns_level (CmdParams* cmdparams)
|
|||
*
|
||||
* Load module
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -430,9 +393,7 @@ ns_load (CmdParams* cmdparams)
|
|||
*
|
||||
* Unload module
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
static int
|
||||
|
@ -449,9 +410,7 @@ ns_unload (CmdParams* cmdparams)
|
|||
*
|
||||
* issue a RAW command
|
||||
*
|
||||
* @param user
|
||||
* @param list of arguments
|
||||
* @param number of arguments
|
||||
* @param cmdparams structure with command information
|
||||
* @returns none
|
||||
*/
|
||||
#ifdef USE_RAW
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define _SERVICES_H_
|
||||
|
||||
extern ModuleInfo ns_module_info;
|
||||
extern Module ns_module;
|
||||
extern BotInfo ns_botinfo;
|
||||
extern Bot* ns_botptr;
|
||||
|
||||
|
|
|
@ -116,12 +116,12 @@ void do_backtrace(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void report_segfault(char* modulename)
|
||||
void report_segfault(const char* modulename)
|
||||
{
|
||||
segfault = fopen ("segfault.log", "a");
|
||||
if(modulename) {
|
||||
globops (me.name, "Segmentation fault in %s. Refer to segfault.log for details.", segv_inmodule);
|
||||
nlog (LOG_CRITICAL, "Segmentation fault in %s. Refer to segfault.log for details.", segv_inmodule);
|
||||
globops (me.name, "Segmentation fault in %s. Refer to segfault.log for details.", GET_CUR_MODNAME());
|
||||
nlog (LOG_CRITICAL, "Segmentation fault in %s. Refer to segfault.log for details.", GET_CUR_MODNAME());
|
||||
} else {
|
||||
globops (me.name, "Segmentation fault. Server terminating. Refer to segfault.log.");
|
||||
nlog (LOG_CRITICAL, "Segmentation fault. Server terminating. Refer to segfault.log.");
|
||||
|
@ -129,9 +129,9 @@ void report_segfault(char* modulename)
|
|||
fprintf (segfault, "------------------------SEGFAULT REPORT-------------------------\n");
|
||||
fprintf (segfault, "Please view the README for how to submit a bug report\n");
|
||||
fprintf (segfault, "and include this segfault report in your submission.\n");
|
||||
fprintf (segfault, "Version: %s\n", me.versionfull);
|
||||
fprintf (segfault, "Version: %s\n", me.version);
|
||||
if (modulename) {
|
||||
fprintf (segfault, "Module: %s\n", segv_inmodule);
|
||||
fprintf (segfault, "Module: %s\n", GET_CUR_MODNAME());
|
||||
}
|
||||
fprintf (segfault, "Location: %s\n", segv_location);
|
||||
fprintf (segfault, "recbuf: %s\n", recbuf);
|
||||
|
@ -149,10 +149,10 @@ serv_segv ()
|
|||
/** segv happened inside a module, so unload and try to restore the stack
|
||||
* to location before we jumped into the module and continue
|
||||
*/
|
||||
if (strcasecmp (segv_inmodule, "neostats") != 0) {
|
||||
report_segfault (segv_inmodule);
|
||||
strlcpy (name, segv_inmodule, MAX_MOD_NAME);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
if (RunLevel > 0) {
|
||||
report_segfault (GET_CUR_MODNAME());
|
||||
strlcpy (name, GET_CUR_MODNAME(), MAX_MOD_NAME);
|
||||
RunLevel = 0;
|
||||
unload_module (name, NULL);
|
||||
chanalert (ns_botptr->nick, "Restoring Stack to before Crash");
|
||||
/* flush the logs out */
|
||||
|
|
28
src/sock.c
28
src/sock.c
|
@ -212,9 +212,9 @@ read_loop ()
|
|||
++me.cursocks;
|
||||
} else {
|
||||
/* its a poll interface, setup for select instead */
|
||||
SET_SEGV_INMODULE(sock->moduleptr->info->name);
|
||||
SET_RUN_LEVEL(sock->moduleptr);
|
||||
j = sock->beforepoll (sock->data, ufds);
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
/* if we don't have any socks, just continue */
|
||||
if (j == -1)
|
||||
continue;
|
||||
|
@ -329,7 +329,7 @@ restartsql:
|
|||
while ((sn = hash_scan_next (&ss)) != NULL) {
|
||||
pollflag = 0;
|
||||
sock = hnode_get (sn);
|
||||
SET_SEGV_INMODULE(sock->moduleptr->info->name);
|
||||
SET_RUN_LEVEL(sock->moduleptr);
|
||||
if (sock->socktype == SOCK_STANDARD) {
|
||||
if (FD_ISSET (sock->sock_no, &readfds)) {
|
||||
nlog (LOG_DEBUG3, "Running module %s readsock function for %s", sock->moduleptr->info->name, sock->name);
|
||||
|
@ -367,8 +367,8 @@ restartsql:
|
|||
sock->afterpoll(sock->data, ufds, pollsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else if (SelectResult == 0) {
|
||||
|
@ -466,12 +466,14 @@ recvlog (char *line)
|
|||
* NS_FAILURE if unsuccessful
|
||||
*/
|
||||
int
|
||||
sock_connect (Module* moduleptr, int socktype, unsigned long ipaddr, int port, char *name, socket_function func_read, socket_function func_write, socket_function func_error)
|
||||
sock_connect (int socktype, unsigned long ipaddr, int port, char *name, socket_function func_read, socket_function func_write, socket_function func_error)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
int s;
|
||||
int i;
|
||||
Module* moduleptr;
|
||||
|
||||
moduleptr = GET_CUR_MODULE();
|
||||
/* socktype = SOCK_STREAM */
|
||||
if ((s = socket (AF_INET, socktype, 0)) < 0)
|
||||
return NS_FAILURE;
|
||||
|
@ -506,7 +508,7 @@ sock_connect (Module* moduleptr, int socktype, unsigned long ipaddr, int port, c
|
|||
}
|
||||
}
|
||||
|
||||
add_socket (moduleptr, func_read, func_write, func_error, name, s);
|
||||
add_socket (func_read, func_write, func_error, name, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -844,8 +846,10 @@ int InitSocks (void)
|
|||
{
|
||||
me.maxsocks = getmaxsock ();
|
||||
sockh = hash_create (me.maxsocks, 0, 0);
|
||||
if(!sockh)
|
||||
if(!sockh) {
|
||||
nlog (LOG_CRITICAL, "Unable to create socks hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -917,11 +921,13 @@ findsock (char *sock_name)
|
|||
* @return pointer to socket if found, NULL if not found
|
||||
*/
|
||||
int
|
||||
add_socket (Module* moduleptr, socket_function readfunc, socket_function writefunc, socket_function errfunc, char *sock_name, int socknum)
|
||||
add_socket (socket_function readfunc, socket_function writefunc, socket_function errfunc, char *sock_name, int socknum)
|
||||
{
|
||||
Sock *sock;
|
||||
Module* moduleptr;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
moduleptr = GET_CUR_MODULE();
|
||||
if (!readfunc) {
|
||||
nlog (LOG_WARNING, "add_socket: read socket function doesn't exist = %s (%s)", sock_name, moduleptr->info->name);
|
||||
return NS_FAILURE;
|
||||
|
@ -958,11 +964,13 @@ add_socket (Module* moduleptr, socket_function readfunc, socket_function writefu
|
|||
* @return pointer to socket if found, NULL if not found
|
||||
*/
|
||||
int
|
||||
add_sockpoll (Module* moduleptr, before_poll_function beforepoll, after_poll_function afterpoll, char *sock_name, void *data)
|
||||
add_sockpoll (before_poll_function beforepoll, after_poll_function afterpoll, char *sock_name, void *data)
|
||||
{
|
||||
Sock *sock;
|
||||
Module* moduleptr;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
moduleptr = GET_CUR_MODULE();
|
||||
if (!beforepoll) {
|
||||
nlog (LOG_WARNING, "add_sockpoll: read socket function doesn't exist = %s (%s)", sock_name, moduleptr->info->name);
|
||||
return NS_FAILURE;
|
||||
|
|
|
@ -344,8 +344,7 @@ dbcommand(char *buf, int *nin, char *out, int *nout, int connid)
|
|||
}
|
||||
else
|
||||
{
|
||||
conn = malloc(sizeof(EpgConn));
|
||||
bzero(conn, sizeof(EpgConn));
|
||||
conn = scalloc(sizeof(EpgConn));
|
||||
snprintf(conn->cmd, 1000, "Authenticating");
|
||||
snprintf((char *) conn->username, 32, "%s", &buf[72]);
|
||||
conn->id = connid;
|
||||
|
|
12
src/timer.c
12
src/timer.c
|
@ -42,8 +42,10 @@ void run_mod_timers (void);
|
|||
int InitTimers (void)
|
||||
{
|
||||
th = hash_create (T_TABLE_SIZE, 0, 0);
|
||||
if(!th)
|
||||
if(!th) {
|
||||
nlog (LOG_CRITICAL, "Unable to create timer hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -161,11 +163,13 @@ findtimer (char *name)
|
|||
* @return NS_SUCCESS if added, NS_FAILURE if not
|
||||
*/
|
||||
int
|
||||
add_timer (Module* moduleptr, timer_function func_name, char *name, int interval)
|
||||
add_timer (timer_function func_name, char *name, int interval)
|
||||
{
|
||||
Timer *timer;
|
||||
Module* moduleptr;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
moduleptr = GET_CUR_MODULE();
|
||||
if (func_name == NULL) {
|
||||
nlog (LOG_WARNING, "%s: Timer %s Function doesn't exist", moduleptr->info->name, name);
|
||||
return NS_FAILURE;
|
||||
|
@ -311,7 +315,7 @@ run_mod_timers (void)
|
|||
timer = hnode_get (tn);
|
||||
if (me.now - timer->lastrun > timer->interval) {
|
||||
if (setjmp (sigvbuf) == 0) {
|
||||
SET_SEGV_INMODULE(timer->moduleptr->info->name);
|
||||
SET_RUN_LEVEL(timer->moduleptr);
|
||||
nlog(LOG_DEBUG3, "run_mod_timers: Running timer %s for module %s", timer->name, timer->moduleptr->info->name);
|
||||
if (timer->function () < 0) {
|
||||
nlog(LOG_DEBUG2, "run_mod_timers: Deleting Timer %s for Module %s as requested", timer->name, timer->moduleptr->info->name);
|
||||
|
@ -321,7 +325,7 @@ run_mod_timers (void)
|
|||
} else {
|
||||
timer->lastrun = (int) me.now;
|
||||
}
|
||||
CLEAR_SEGV_INMODULE();
|
||||
RESET_RUN_LEVEL();
|
||||
} else {
|
||||
nlog (LOG_CRITICAL, "run_mod_timers: setjmp() failed, can't call module %s\n", timer->moduleptr->info->name);
|
||||
}
|
||||
|
|
|
@ -29,17 +29,6 @@
|
|||
#include "transfer.h"
|
||||
#include "curl.h"
|
||||
|
||||
void testcallback(void *data, int status, char *body, int bodysize) {
|
||||
if (status == NS_FAILURE) {
|
||||
printf("gotcallback for %s\n", (char *)data);
|
||||
printf("Error: %s\n", body);
|
||||
} else {
|
||||
printf("got good callback for %s\n", (char *)data);
|
||||
printf("Body:(%d - %d)\n%s\n", bodysize, strlen(body),body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InitCurl(void)
|
||||
{
|
||||
/* global curl init */
|
||||
|
@ -67,7 +56,8 @@ int InitCurl(void)
|
|||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
static size_t neocurl_callback( void *transferptr, size_t size, size_t nmemb, void *stream) {
|
||||
static size_t neocurl_callback( void *transferptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
size_t writesize;
|
||||
int rembuffer;
|
||||
char *newbuf;
|
||||
|
@ -106,10 +96,10 @@ static size_t neocurl_callback( void *transferptr, size_t size, size_t nmemb, vo
|
|||
}
|
||||
|
||||
|
||||
int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *filename, void *data, transfer_callback *callback) {
|
||||
int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *filename, void *data, transfer_callback *callback)
|
||||
{
|
||||
int ret;
|
||||
neo_transfer *newtrans;
|
||||
|
||||
|
||||
/* sanity check the input first */
|
||||
if (url[0] == 0) {
|
||||
|
@ -121,8 +111,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
newtrans = malloc(sizeof(neo_transfer));
|
||||
bzero(newtrans, sizeof(neo_transfer));
|
||||
newtrans = scalloc(sizeof(neo_transfer));
|
||||
switch (savetofileormemory) {
|
||||
case NS_FILE:
|
||||
/* if we don't have a filename, bail out */
|
||||
|
@ -197,7 +186,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
}
|
||||
|
||||
/* setup the user agent */
|
||||
ircsnprintf(newtrans->useragent, MAXURL, "NeoStats %s (%s)", me.versionfull, segv_inmodule);
|
||||
ircsnprintf(newtrans->useragent, MAXURL, "NeoStats %s (%s)", me.version, GET_CUR_MODNAME());
|
||||
if ((ret = curl_easy_setopt(newtrans->curleasyhandle, CURLOPT_USERAGENT, newtrans->useragent)) != 0) {
|
||||
nlog(LOG_WARNING, "Curl Set useragent failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
|
@ -269,8 +258,8 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void transfer_status() {
|
||||
void transfer_status(void)
|
||||
{
|
||||
CURLMsg *msg;
|
||||
int msg_left;
|
||||
neo_transfer *neotrans;
|
||||
|
@ -294,7 +283,6 @@ void transfer_status() {
|
|||
/* check if it failed etc */
|
||||
if (msg->data.result != 0) {
|
||||
/* it failed for whatever reason */
|
||||
/* XXX TODO... Callback with a failure */
|
||||
nlog(LOG_NOTICE, "Transfer %s Failed. Error was: %s", neotrans->url, neotrans->curlerror);
|
||||
neotrans->callback(neotrans->data, NS_FAILURE, neotrans->curlerror, strlen(neotrans->curlerror));
|
||||
} else {
|
||||
|
@ -302,7 +290,6 @@ void transfer_status() {
|
|||
/* success, so we must callback with success */
|
||||
neotrans->callback(neotrans->data, NS_SUCCESS, neotrans->savefileormem == NS_MEMORY ? neotrans->savemem : NULL, neotrans->savememsize);
|
||||
}
|
||||
CLEAR_SEGV_INMODULE();
|
||||
/* regardless, clean up the transfer */
|
||||
curl_multi_remove_handle(curlmultihandle, neotrans->curleasyhandle);
|
||||
curl_easy_cleanup(neotrans->curleasyhandle);
|
||||
|
|
45
src/users.c
45
src/users.c
|
@ -4,8 +4,6 @@
|
|||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** Portions Copyright (c) 1999 Johnathan George net@lite.net
|
||||
**
|
||||
** 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 2 of the License, or
|
||||
|
@ -41,9 +39,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
hash_t *uh;
|
||||
|
||||
char quitreason[BUFSIZE];
|
||||
static hash_t *uh;
|
||||
|
||||
static User *
|
||||
new_user (const char *nick)
|
||||
|
@ -194,17 +190,12 @@ KillUser (const char *nick, const char *reason)
|
|||
nlog (LOG_WARNING, "KillUser: %s failed!", nick);
|
||||
return;
|
||||
}
|
||||
bzero(quitreason, BUFSIZE);
|
||||
if(reason) {
|
||||
strlcpy(quitreason, reason, BUFSIZE);
|
||||
strip_mirc_codes(quitreason);
|
||||
}
|
||||
PartAllChannels (u);
|
||||
PartAllChannels (u, reason);
|
||||
/* run the event to delete a user */
|
||||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->source.user = u;
|
||||
if(reason) {
|
||||
cmdparams->param = (char*)quitreason;
|
||||
cmdparams->param = (char*)reason;
|
||||
}
|
||||
SendAllModuleEvent (EVENT_KILL, cmdparams);
|
||||
/* if its one of our bots inform the module */
|
||||
|
@ -229,17 +220,12 @@ QuitUser (const char *nick, const char *reason)
|
|||
nlog (LOG_WARNING, "QuitUser: %s failed!", nick);
|
||||
return;
|
||||
}
|
||||
bzero(quitreason, BUFSIZE);
|
||||
if(reason) {
|
||||
strlcpy(quitreason, reason, BUFSIZE);
|
||||
strip_mirc_codes(quitreason);
|
||||
}
|
||||
PartAllChannels (u);
|
||||
PartAllChannels (u, reason);
|
||||
/* run the event to delete a user */
|
||||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->source.user = u;
|
||||
if(reason) {
|
||||
cmdparams->param = (char*)quitreason;
|
||||
cmdparams->param = (char*)reason;
|
||||
}
|
||||
SendAllModuleEvent (EVENT_QUIT, cmdparams);
|
||||
deluser(u);
|
||||
|
@ -578,8 +564,10 @@ int
|
|||
InitUsers ()
|
||||
{
|
||||
uh = hash_create (U_TABLE_SIZE, 0, 0);
|
||||
if(!uh)
|
||||
if(!uh) {
|
||||
nlog (LOG_CRITICAL, "Unable to create user hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef SQLSRV
|
||||
/* add the server hash to the sql library */
|
||||
|
@ -768,7 +756,7 @@ void FiniUsers (void)
|
|||
hash_scan_begin(&hs, uh);
|
||||
while ((un = hash_scan_next(&hs)) != NULL) {
|
||||
u = hnode_get (un);
|
||||
PartAllChannels (u);
|
||||
PartAllChannels (u, NULL);
|
||||
/* something is wrong if its our bots */
|
||||
if ( IsMe(u) ) {
|
||||
nlog (LOG_NOTICE, "FiniUsers called with a neostats bot online: %s", u->nick);
|
||||
|
@ -779,5 +767,18 @@ void FiniUsers (void)
|
|||
free (u);
|
||||
}
|
||||
hash_destroy(uh);
|
||||
hash_destroy(ch);
|
||||
}
|
||||
|
||||
void GetUserList(UserListHandler handler)
|
||||
{
|
||||
User *u;
|
||||
hscan_t scan;
|
||||
hnode_t *node;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
hash_scan_begin(&scan, uh);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
u = hnode_get(node);
|
||||
handler(u);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue