⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m_stats.c

📁 Unreal irc 服务器源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
			sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);				return 0;		}			/* Old style, we can use a binary search here */		stat = stats_binary_search(parv[1][0]);	}	else	{		if (!IsAnOper(sptr) && stats_operonly_long(parv[1]))		{			sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);				return 0;		}		/* New style, search the hard way */		stat = stats_search(parv[1]);	}	if (stat)	{		/* It was a short flag, so check oper only on long flags */		if (!parv[1][1])		{			if (!IsAnOper(sptr) && stats_operonly_long(stat->longflag))			{				sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);				return 0;			}		}		/* It was a long flag, so check oper only on short flags */		else		{			if (!IsAnOper(sptr) && stats_operonly_short(stat->flag))			{				sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);					return 0;			}		}		if (stat->options & FLAGS_AS_PARA)		{			if (parc > 2 && (parv[2][0] == '+' || parv[2][0] == '-'))			{				if (parc > 3)					stat->func(sptr, stats_combine_parv(parv[2],parv[3]));				else					stat->func(sptr, parv[2]);			}			else if (parc > 3)				stat->func(sptr, parv[3]);			else				stat->func(sptr, NULL);		}		else if (stat->options & SERVER_AS_PARA)		{			if (parc > 2)				stat->func(sptr, parv[2]);			else				stat->func(sptr, NULL);		}		else			stat->func(sptr, NULL);		sendto_one(sptr, rpl_str(RPL_ENDOFSTATS), me.name, parv[0], stat->flag);		if (!IsULine(sptr))			sendto_snomask(SNO_EYES, "Stats \'%c\' requested by %s (%s@%s)",				stat->flag, sptr->name, sptr->user->username, GetHost(sptr));		else			sendto_snomask(SNO_JUNK, "Stats \'%c\' requested by %s (%s@%s) [ulined]",				stat->flag, sptr->name, sptr->user->username, GetHost(sptr));	}	else	{		stats_help(sptr);		sendto_one(sptr, rpl_str(RPL_ENDOFSTATS), me.name, parv[0], '*');		return 0;	}	return 0;}int stats_banversion(aClient *sptr, char *para){	ConfigItem_ban *bans;	for (bans = conf_ban; bans; bans = (ConfigItem_ban *)bans->next)	{		if (bans->flag.type != CONF_BAN_VERSION)			continue;		sendto_one(sptr, rpl_str(RPL_STATSBANVER), me.name, sptr->name,			bans->mask, bans->reason ? bans->reason : "No Reason");	}	return 0;}int stats_links(aClient *sptr, char *para){	ConfigItem_link *link_p;#ifdef DEBUGMODE	aClient *acptr;#endif	for (link_p = conf_link; link_p; link_p = (ConfigItem_link *) link_p->next)	{		sendto_one(sptr, ":%s 213 %s C %s@%s * %s %i %s %s%s%s%s%s%s",			me.name, sptr->name, IsOper(sptr) ? link_p->username : "*",			IsOper(sptr) ? link_p->hostname : "*", link_p->servername,			link_p->port,			link_p->class->name,			(link_p->options & CONNECT_AUTO) ? "a" : "",			(link_p->options & CONNECT_SSL) ? "S" : "",			(link_p->options & CONNECT_ZIP) ? "z" : "",			(link_p->options & CONNECT_NODNSCACHE) ? "d" : "",			(link_p->options & CONNECT_NOHOSTCHECK) ? "h" : "",			(link_p->flag.temporary == 1) ? "T" : "");#ifdef DEBUGMODE		sendnotice(sptr, "%s (%p) has refcount %d",			link_p->servername, link_p, link_p->refcount);#endif		if (link_p->hubmask)			sendto_one(sptr, ":%s 244 %s H %s * %s",				me.name, sptr->name, link_p->hubmask,				link_p->servername);		else if (link_p->leafmask)			sendto_one(sptr, ":%s 241 %s L %s * %s %d",				me.name, sptr->name,				link_p->leafmask, link_p->servername, link_p->leafdepth);	}#ifdef DEBUGMODE	for (acptr = client; acptr; acptr = acptr->next)		if (MyConnect(acptr) && IsServer(acptr))		{			if (!acptr->serv->conf)				sendnotice(sptr, "client '%s' (%p) has NO CONF attached (? :P)",					acptr->name, acptr);			else				sendnotice(sptr, "client '%s' (%p) has conf %p attached, refcount: %d, temporary: %s",					acptr->name, acptr,					acptr->serv->conf,					acptr->serv->conf->refcount,					acptr->serv->conf->flag.temporary ? "YES" : "NO");		}#endif	return 0;}int stats_denylinkall(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_ALL)			sendto_one(sptr, rpl_str(RPL_STATSDLINE), me.name, sptr->name,			'D', links->mask, links->prettyrule);	}	return 0;}int stats_gline(aClient *sptr, char *para){	tkl_stats(sptr, TKL_GLOBAL|TKL_KILL, para);	tkl_stats(sptr, TKL_GLOBAL|TKL_ZAP, para);	return 0;}int stats_spamfilter(aClient *sptr, char *para){	tkl_stats(sptr, TKL_SPAMF, para);	tkl_stats(sptr, TKL_GLOBAL|TKL_SPAMF, para);	return 0;}int stats_exceptban(aClient *sptr, char *para){	ConfigItem_except *excepts;	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, "");		else if (excepts->flag.type == CONF_EXCEPT_TKL)			sendto_one(sptr, rpl_str(RPL_STATSEXCEPTTKL), me.name,				sptr->name, tkl_typetochar(excepts->type), excepts->mask);	}	return 0;}int stats_allow(aClient *sptr, char *para){	ConfigItem_allow *allows;	for (allows = conf_allow; allows; allows = (ConfigItem_allow *) allows->next) 		sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name,			sptr->name, allows->ip, allows->hostname, allows->maxperip, 			allows->class->name, allows->server ? allows->server 			: defserv, allows->port ? allows->port : 6667);	return 0;}int stats_command(aClient *sptr, char *para){	int i;	aCommand *mptr;	for (i = 0; i < 256; i++)		for (mptr = CommandHash[i]; mptr; mptr = mptr->next)			if (mptr->count)#ifndef DEBUGMODE			sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),				me.name, sptr->name, mptr->cmd,				mptr->count, mptr->bytes);#else			sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),				me.name, sptr->name, mptr->cmd,				mptr->count, mptr->bytes,				mptr->lticks, mptr->lticks / CLOCKS_PER_SEC,				mptr->rticks, mptr->rticks / CLOCKS_PER_SEC);#endif	for (i = 0; i < 256; i++)		for (mptr = TokenHash[i]; mptr; mptr = mptr->next)			if (mptr->count)#ifndef DEBUGMODE			sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),				me.name, sptr->name, mptr->cmd,				mptr->count, mptr->bytes);#else			sendto_one(sptr, rpl_str(RPL_STATSCOMMANDS),				me.name, sptr->name, mptr->cmd,				mptr->count, mptr->bytes,				mptr->lticks, mptr->lticks / CLOCKS_PER_SEC,				mptr->rticks, mptr->rticks / CLOCKS_PER_SEC);#endif	return 0;}	int stats_oper(aClient *sptr, char *para){	ConfigItem_oper *oper_p;	ConfigItem_oper_from *from;	for (oper_p = conf_oper; oper_p; oper_p = (ConfigItem_oper *) oper_p->next)	{		if(!oper_p->from)			sendto_one(sptr, rpl_str(RPL_STATSOLINE),		  		me.name, sptr->name, 		  		'O', "(none)", oper_p->name,		  		oflagstr(oper_p->oflags),		  		oper_p->class->name ? oper_p->class->name : "");		else			for (from = (ConfigItem_oper_from *) oper_p->from; from; from = (ConfigItem_oper_from *) from->next)		  		sendto_one(sptr, rpl_str(RPL_STATSOLINE),		  			me.name, sptr->name, 		  			'O', from->name, oper_p->name,		  			oflagstr(oper_p->oflags),		  			oper_p->class->name? oper_p->class->name : "");	}	return 0;}static char *stats_port_helper(aClient *listener){static char buf[256];	buf[0] = '\0';	if (listener->umodes & LISTENER_CLIENTSONLY)		strcat(buf, "clientsonly ");	if (listener->umodes & LISTENER_SERVERSONLY)		strcat(buf, "serversonly ");	if (listener->umodes & LISTENER_JAVACLIENT)		strcat(buf, "java ");	if (listener->umodes & LISTENER_SSL)		strcat(buf, "SSL ");	return buf;}int stats_port(aClient *sptr, char *para){	int i;	aClient *acptr;	for (i = 0; i <= LastSlot; i++)	{		if (!(acptr = local[i]))			continue;	  	if (!IsListening(acptr))	  		continue;	  	sendto_one(sptr, ":%s %s %s :*** Listener on %s:%i, clients %i. is %s %s",	  		me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name,	  		((ConfigItem_listen *)acptr->class)->ip,			((ConfigItem_listen *)acptr->class)->port,			((ConfigItem_listen *)acptr->class)->clients,			((ConfigItem_listen *)acptr->class)->flag.temporary ? "TEMPORARY" : "PERM",			stats_port_helper(acptr));	}	return 0;}int stats_bannick(aClient *sptr, char *para){	tkl_stats(sptr, TKL_NICK, para);	return 0;}int stats_usage(aClient *sptr, char *para){#ifdef DEBUGMODE	send_usage(sptr, sptr->name);#endif	return 0;}int stats_traffic(aClient *sptr, char *para){	aClient *acptr;	int  i;	struct stats *sp;	struct stats tmp;	time_t now = TStime();	sp = &tmp;	bcopy((char *)ircstp, (char *)sp, sizeof(*sp));	for (i = 0; i <= LastSlot; i++)	{		if (!(acptr = local[i]))			continue;		if (IsServer(acptr))		{			sp->is_sbs += acptr->sendB;			sp->is_sbr += acptr->receiveB;			sp->is_sks += acptr->sendK;			sp->is_skr += acptr->receiveK;			sp->is_sti += now - acptr->firsttime;			sp->is_sv++;			if (sp->is_sbs > 1023)			{				sp->is_sks += (sp->is_sbs >> 10);				sp->is_sbs &= 0x3ff;			}			if (sp->is_sbr > 1023)			{				sp->is_skr += (sp->is_sbr >> 10);				sp->is_sbr &= 0x3ff;			}		}		else if (IsClient(acptr))		{			sp->is_cbs += acptr->sendB;			sp->is_cbr += acptr->receiveB;			sp->is_cks += acptr->sendK;			sp->is_ckr += acptr->receiveK;			sp->is_cti += now - acptr->firsttime;			sp->is_cl++;			if (sp->is_cbs > 1023)			{				sp->is_cks += (sp->is_cbs >> 10);				sp->is_cbs &= 0x3ff;			}			if (sp->is_cbr > 1023)			{				sp->is_ckr += (sp->is_cbr >> 10);				sp->is_cbr &= 0x3ff;			}		}		else if (IsUnknown(acptr))			sp->is_ni++;	}	sendto_one(sptr, ":%s %d %s :accepts %u refused %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_ac, sp->is_ref);	sendto_one(sptr, ":%s %d %s :unknown commands %u prefixes %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_unco, sp->is_unpf);	sendto_one(sptr, ":%s %d %s :nick collisions %u unknown closes %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_kill, sp->is_ni);	sendto_one(sptr, ":%s %d %s :wrong direction %u empty %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_wrdi, sp->is_empt);	sendto_one(sptr, ":%s %d %s :numerics seen %u mode fakes %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_num, sp->is_fake);	sendto_one(sptr, ":%s %d %s :auth successes %u fails %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_asuc, sp->is_abad);	sendto_one(sptr, ":%s %d %s :local connections %u udp packets %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_loc, sp->is_udp);	sendto_one(sptr, ":%s %d %s :Client Server",	    me.name, RPL_STATSDEBUG, sptr->name);	sendto_one(sptr, ":%s %d %s :connected %u %u",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_cl, sp->is_sv);	sendto_one(sptr, ":%s %d %s :bytes sent %ld.%huK %ld.%huK",	    me.name, RPL_STATSDEBUG, sptr->name,	    sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs);	sendto_one(sptr, ":%s %d %s :bytes recv %ld.%huK %ld.%huK",	    me.name, RPL_STATSDEBUG, sptr->name,	    sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr);	sendto_one(sptr, ":%s %d %s :time connected %ld %ld",	    me.name, RPL_STATSDEBUG, sptr->name, sp->is_cti, sp->is_sti);#ifndef NO_FDLIST	sendto_one(sptr,	    ":%s %d %s :incoming rate %0.2f kb/s - outgoing rate %0.2f kb/s",	    me.name, RPL_STATSDEBUG, sptr->name, currentrate, currentrate2);#endif	return 0;}int stats_uline(aClient *sptr, char *para){	ConfigItem_ulines *ulines;	for (ulines = conf_ulines; ulines; ulines = (ConfigItem_ulines *) ulines->next)		sendto_one(sptr, rpl_str(RPL_STATSULINE), me.name,			sptr->name, ulines->servername);	return 0;	}int stats_vhost(aClient *sptr, char *para){	ConfigItem_oper_from *from;	ConfigItem_vhost *vhosts;	for(vhosts = conf_vhost; vhosts; vhosts = (ConfigItem_vhost *) vhosts->next) 	{		for (from = (ConfigItem_oper_from *)vhosts->from; from; from = (ConfigItem_oper_from *)from->next) 			sendto_one(sptr, ":%s %i %s :vhost %s%s%s %s %s", me.name, RPL_TEXT, sptr->name,			     vhosts->virtuser ? vhosts->virtuser : "", vhosts->virtuser ? "@" : "",			     vhosts->virthost, vhosts->login, from->name);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -