📄 m_stats.c
字号:
} return 0;}int stats_mem(aClient *sptr, char *para){ extern MODVAR int flinks; extern MODVAR Link *freelink; extern MODVAR MemoryInfo StatsZ; aClient *acptr; Ban *ban; Link *link; aChannel *chptr; int lc = 0, /* local clients */ ch = 0, /* channels */ lcc = 0, /* local client conf links */ rc = 0, /* remote clients */ us = 0, /* user structs */ chu = 0, /* channel users */ chi = 0, /* channel invites */ chb = 0, /* channel bans */ wwu = 0, /* whowas users */ fl = 0, /* free links */ cl = 0, /* classes */ co = 0; /* conf lines */ int usi = 0, /* users invited */ usc = 0, /* users in channels */ aw = 0, /* aways set */ wwa = 0, /* whowas aways */ wlh = 0, /* watchlist headers */ wle = 0; /* watchlist entries */ u_long chm = 0, /* memory used by channels */ chbm = 0, /* memory used by channel bans */ lcm = 0, /* memory used by local clients */ rcm = 0, /* memory used by remote clients */ awm = 0, /* memory used by aways */ wwam = 0, /* whowas away memory used */ wwm = 0, /* whowas array memory used */ com = 0, /* memory used by conf lines */ wlhm = 0, /* watchlist memory used */ db = 0, /* memory used by dbufs */ rm = 0, /* res memory used */ totcl = 0, totch = 0, totww = 0, tot = 0; if (!IsAnOper(sptr)) { sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, sptr->name); return 0; } count_whowas_memory(&wwu, &wwam); count_watch_memory(&wlh, &wlhm); wwm = sizeof(aName) * NICKNAMEHISTORYLENGTH; for (acptr = client; acptr; acptr = acptr->next) { if (MyConnect(acptr)) { lc++; /*for (link = acptr->confs; link; link = link->next) lcc++; wle += acptr->notifies;*/ } else rc++; if (acptr->user) { Membership *mb; us++; for (link = acptr->user->invited; link; link = link->next) usi++; for (mb = acptr->user->channel; mb; mb = mb->next) usc++; if (acptr->user->away) { aw++; awm += (strlen(acptr->user->away) + 1); } } } lcm = lc * CLIENT_LOCAL_SIZE; rcm = rc * CLIENT_REMOTE_SIZE; for (chptr = channel; chptr; chptr = chptr->nextch) { Member *member; ch++; chm += (strlen(chptr->chname) + sizeof(aChannel)); for (member = chptr->members; member; member = member->next) chu++; for (link = chptr->invites; link; link = link->next) chi++; for (ban = chptr->banlist; ban; ban = ban->next) { chb++; chbm += (strlen(ban->banstr) + 1 + strlen(ban->who) + 1 + sizeof(Ban)); } for (ban = chptr->exlist; ban; ban = ban->next) { chb++; chbm += (strlen(ban->banstr) + 1 + strlen(ban->who) + 1 + sizeof(Ban)); } for (ban = chptr->invexlist; ban; ban = ban->next) { chb++; chbm += (strlen(ban->banstr) + 1 + strlen(ban->who) + 1 + sizeof(Ban)); } } sendto_one(sptr, ":%s %d %s :Client Local %d(%ld) Remote %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, lc, lcm, rc, rcm); sendto_one(sptr, ":%s %d %s :Users %d(%ld) Invites %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, us, (long)(us * sizeof(anUser)), usi, (long)(usi * sizeof(Link))); sendto_one(sptr, ":%s %d %s :User channels %d(%ld) Aways %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, usc, (long)(usc * sizeof(Link)), aw, awm); sendto_one(sptr, ":%s %d %s :WATCH headers %d(%ld) entries %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, wlh, wlhm, wle, (long)(wle * sizeof(Link))); sendto_one(sptr, ":%s %d %s :Attached confs %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, lcc, (long)(lcc * sizeof(Link))); totcl = lcm + rcm + us * sizeof(anUser) + usc * sizeof(Link) + awm; totcl += lcc * sizeof(Link) + usi * sizeof(Link) + wlhm; totcl += wle * sizeof(Link); sendto_one(sptr, ":%s %d %s :Conflines %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, co, com); sendto_one(sptr, ":%s %d %s :Classes %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, StatsZ.classes, StatsZ.classesmem); sendto_one(sptr, ":%s %d %s :Channels %d(%ld) Bans %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, ch, chm, chb, chbm); sendto_one(sptr, ":%s %d %s :Channel members %d(%ld) invite %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, chu, (long)(chu * sizeof(Link)), chi, (long)(chi * sizeof(Link))); totch = chm + chbm + chu * sizeof(Link) + chi * sizeof(Link); sendto_one(sptr, ":%s %d %s :Whowas users %d(%ld) away %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, wwu, (long)(wwu * sizeof(anUser)), wwa, wwam); sendto_one(sptr, ":%s %d %s :Whowas array %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, NICKNAMEHISTORYLENGTH, wwm); totww = wwu * sizeof(anUser) + wwam + wwm; sendto_one(sptr, ":%s %d %s :Hash: client %d(%ld) chan %d(%ld) watch %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, U_MAX, (long)(sizeof(aHashEntry) * U_MAX), CH_MAX, (long)(sizeof(aHashEntry) * CH_MAX), WATCHHASHSIZE, (long)(sizeof(aWatch *) * WATCHHASHSIZE)); db = dbufblocks * sizeof(dbufbuf); sendto_one(sptr, ":%s %d %s :Dbuf blocks %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, dbufblocks, db); for (link = freelink; link; link = link->next) fl++; sendto_one(sptr, ":%s %d %s :Link blocks free %d(%ld) total %d(%ld)", me.name, RPL_STATSDEBUG, sptr->name, fl, (long)(fl * sizeof(Link)), flinks, (long)(flinks * sizeof(Link)));/* rm = cres_mem(sptr,sptr->name); */ rm = 0; /* syzop: todo ?????????? */ tot = totww + totch + totcl + com + cl * sizeof(aClass) + db + rm; tot += fl * sizeof(Link); tot += sizeof(aHashEntry) * U_MAX; tot += sizeof(aHashEntry) * CH_MAX; tot += sizeof(aWatch *) * WATCHHASHSIZE; sendto_one(sptr, ":%s %d %s :Total: ww %ld ch %ld cl %ld co %ld db %ld", me.name, RPL_STATSDEBUG, sptr->name, totww, totch, totcl, com, db);#if !defined(_WIN32) && !defined(_AMIGA)#ifdef __alpha sendto_one(sptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %u", me.name, RPL_STATSDEBUG, sptr->name, tot, (u_int)sbrk((size_t)0) - (u_int)sbrk0);#else sendto_one(sptr, ":%s %d %s :TOTAL: %ld sbrk(0)-etext: %lu", me.name, RPL_STATSDEBUG, sptr->name, tot, (u_long)sbrk((size_t)0) - (u_long)sbrk0);#endif#else sendto_one(sptr, ":%s %d %s :TOTAL: %lu", me.name, RPL_STATSDEBUG, sptr->name, tot);#endif return 0;}int stats_badwords(aClient *sptr, char *para){#ifdef STRIPBADWORDS ConfigItem_badword *words; for (words = conf_badword_channel; words; words = (ConfigItem_badword *) words->next) { #ifdef FAST_BADWORD_REPLACE sendto_one(sptr, ":%s %i %s :c %c %s%s%s %s", me.name, RPL_TEXT, sptr->name, words->type & BADW_TYPE_REGEX ? 'R' : 'F', (words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word, (words->type & BADW_TYPE_FAST_R) ? "*" : "", words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : ""); #else sendto_one(sptr, ":%s %i %s :c %s %s", me.name, RPL_TEXT, sptr->name, words->word, words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : ""); #endif } for (words = conf_badword_message; words; words = (ConfigItem_badword *) words->next) { #ifdef FAST_BADWORD_REPLACE sendto_one(sptr, ":%s %i %s :m %c %s%s%s %s", me.name, RPL_TEXT, sptr->name, words->type & BADW_TYPE_REGEX ? 'R' : 'F', (words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word, (words->type & BADW_TYPE_FAST_R) ? "*" : "", words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : ""); #else sendto_one(sptr, ":%s %i %s :m %s %s", me.name, RPL_TEXT, sptr->name, words->word, words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : ""); #endif } for (words = conf_badword_quit; words; words = (ConfigItem_badword *) words->next) { #ifdef FAST_BADWORD_REPLACE sendto_one(sptr, ":%s %i %s :q %c %s%s%s %s", me.name, RPL_TEXT, sptr->name, words->type & BADW_TYPE_REGEX ? 'R' : 'F', (words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word, (words->type & BADW_TYPE_FAST_R) ? "*" : "", words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : ""); #else sendto_one(sptr, ":%s %i %s :q %s %s", me.name, RPL_TEXT, sptr->name, words->word, words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : ""); #endif }#endif return 0;}int stats_denylinkauto(aClient *sptr, char *para){ ConfigItem_deny_link *links; for (links = conf_deny_link; links; links = (ConfigItem_deny_link *) links->next) { if (links->flag.type == CRULE_AUTO) sendto_one(sptr, rpl_str(RPL_STATSDLINE), me.name, sptr->name, 'd', links->mask, links->prettyrule); } return 0;}int stats_exceptthrottle(aClient *sptr, char *para){ ConfigItem_except *excepts; for (excepts = conf_except; excepts; excepts = (ConfigItem_except *) excepts->next) if (excepts->flag.type == CONF_EXCEPT_THROTTLE) sendto_one(sptr, rpl_str(RPL_STATSELINE), me.name, sptr->name, excepts->mask); return 0;}int stats_denydcc(aClient *sptr, char *para){ ConfigItem_deny_dcc *denytmp; ConfigItem_allow_dcc *allowtmp; char *filemask, *reason; char a = 0; for (denytmp = conf_deny_dcc; denytmp; denytmp = (ConfigItem_deny_dcc *) denytmp->next) { filemask = BadPtr(denytmp->filename) ? "<NULL>" : denytmp->filename; reason = BadPtr(denytmp->reason) ? "<NULL>" : denytmp->reason; if (denytmp->flag.type2 == CONF_BAN_TYPE_CONF) a = 'c'; if (denytmp->flag.type2 == CONF_BAN_TYPE_AKILL) a = 's'; if (denytmp->flag.type2 == CONF_BAN_TYPE_TEMPORARY) a = 'o'; /* <d> <s|h> <howadded> <filemask> <reason> */ sendto_one(sptr, ":%s %i %s :d %c %c %s %s", me.name, RPL_TEXT, sptr->name, (denytmp->flag.type == DCCDENY_SOFT) ? 's' : 'h', a, filemask, reason); } for (allowtmp = conf_allow_dcc; allowtmp; allowtmp = (ConfigItem_allow_dcc *) allowtmp->next) { filemask = BadPtr(allowtmp->filename) ? "<NULL>" : allowtmp->filename; if (allowtmp->flag.type2 == CONF_BAN_TYPE_CONF) a = 'c'; if (allowtmp->flag.type2 == CONF_BAN_TYPE_AKILL) a = 's'; if (allowtmp->flag.type2 == CONF_BAN_TYPE_TEMPORARY) a = 'o'; /* <a> <s|h> <howadded> <filemask> */ sendto_one(sptr, ":%s %i %s :a %c %c %s", me.name, RPL_TEXT, sptr->name, (allowtmp->flag.type == DCCDENY_SOFT) ? 's' : 'h', a, filemask); } return 0;}int stats_kline(aClient *sptr, char *para){ ConfigItem_ban *bans; ConfigItem_except *excepts; char type[2]; for (bans = conf_ban; bans; bans = (ConfigItem_ban *)bans->next) { if (bans->flag.type == CONF_BAN_USER) { if (bans->flag.type2 == CONF_BAN_TYPE_CONF) type[0] = 'K'; type[1] = '\0'; sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, sptr->name, type, bans->mask, bans->reason ? bans->reason : "<no reason>"); } else if (bans->flag.type == CONF_BAN_IP) { if (bans->flag.type2 == CONF_BAN_TYPE_CONF) type[0] = 'Z'; else if (bans->flag.type2 == CONF_BAN_TYPE_TEMPORARY) type[0] = 'z'; type[1] = '\0'; sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, sptr->name, type, bans->mask, bans->reason ? bans->reason : "<no reason>"); } } tkl_stats(sptr, TKL_KILL, NULL); tkl_stats(sptr, TKL_ZAP, NULL); for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next) { if (excepts->flag.type == CONF_EXCEPT_BAN) sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, sptr->name, "E", excepts->mask, ""); } return 0;}int stats_banrealname(aClient *sptr, char *para){ ConfigItem_ban *bans; for (bans = conf_ban; bans; bans = (ConfigItem_ban *)bans->next) if (bans->flag.type == CONF_BAN_REALNAME) sendto_one(sptr, rpl_str(RPL_STATSNLINE), me.name, sptr->name, bans->mask, bans->reason ? bans->reason : "<no reason>"); return 0;}int stats_sqline(aClient *sptr, char *para){ tkl_stats(sptr, TKL_NICK|TKL_GLOBAL, para); return 0;}int stats_chanrestrict(aClient *sptr, char *para){ ConfigItem_deny_channel *dchans; ConfigItem_allow_channel *achans; for (dchans = conf_deny_channel; dchans; dchans = (ConfigItem_deny_channel *) dchans->next) sendto_one(sptr, ":%s %i %s :deny %s %c %s", me.name, RPL_TEXT, sptr->name, dchans->channel, dchans->warn ? 'w' : '-', dchans->reason); for (achans = conf_allow_channel; achans; achans = (ConfigItem_allow_channel *) achans->next) sendto_one(sptr, ":%s %i %s :allow %s", me.name, RPL_TEXT, sptr->name, achans->channel); return 0;}int stats_shun(aClient *sptr, char *para){ tkl_stats(sptr, TKL_GLOBAL|TKL_SHUN, para); return 0;}/* should this be moved to a seperate stats flag? */int stats_officialchannels(aClient *sptr, char *para){ConfigItem_offchans *x; for (x = conf_offchans; x; x = (ConfigItem_offchans *)x->next) sendto_one(sptr, ":%s %i %s :%s %s", me.name, RPL_TEXT, sptr->name, x->chname, x->topic ? x->topic : ""); return 0;}int stats_set(aClient *sptr, char *para){ char *uhallow; if (!IsAnOper(sptr)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -