Ejemplo n.º 1
0
static void
ss_showstats(struct Luser *lptr, int ac, char **av)

{
	RecordCommand("%s: %s!%s@%s SHOWSTATS",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname);

#ifdef NICKSERVICES

	notice(n_StatServ, lptr->nick,
	       "Registered Nicknames: %d",
	       Network->TotalNicks);

#ifdef CHANNELSERVICES

	notice(n_StatServ, lptr->nick,
	       "Registered Channels:  %d",
	       Network->TotalChans);

#endif /* CHANNELSERVICES */

#ifdef MEMOSERVICES

	notice(n_StatServ, lptr->nick,
	       "Total Memos:          %d",
	       Network->TotalMemos);

#endif /* MEMOSERVICES */

#endif /* NICKSERVICES */
} /* ss_showstats() */
Ejemplo n.º 2
0
void ProcAssign( void )
{
    char        *startpos;

    if( !AdvMachState( ACTION_ASSIGNMENT ) ) {
        FlushEOC();
        return;
    }
    startpos = ScanPos();
    NormalExpr();
    PopEntry();
    ReqEOC();
    RecordCommand( startpos, CMD_ASSIGN );
}
Ejemplo n.º 3
0
/*
 * es_unseen()
 *
 * Removes all wild matches of av[1] from seen list 
 */
static void es_unseen(struct Luser *lptr, int ac, char **av)
{
    aSeen *saved, *seen = seenp;
    char nuhost[NICKLEN + USERLEN + HOSTLEN + 3];

    if (ac < 2)
    {
        notice(n_SeenServ, lptr->nick,
               "Syntax: UNSEEN <mask>");
        notice(n_SeenServ, lptr->nick,
               ERR_MORE_INFO,
               n_SeenServ,
               "UNSEEN");
        return ;
    }

    RecordCommand("%s: %s!%s@%s UNSEEN [%s]",
                  n_SeenServ,
                  lptr->nick,
                  lptr->username,
                  lptr->hostname,
                  av[1]);

    while (seen)
    {
        saved = seen->prev;
        /* Converted to memset() -kre */
        /* bzero(nuhost, sizeof(nuhost)); */
        memset(nuhost, 0, sizeof(nuhost));
        strncpy(nuhost, seen->nick, NICKLEN);
        strcat(nuhost, "!");
        strncat(nuhost, seen->userhost, USERLEN + HOSTLEN + 1);
        if (match(av[1], nuhost))
        {
            if (seen->prev) seen->prev->next = seen->next;
            if (seen->next) seen->next->prev = seen->prev;
            if (seenp == seen) seenp = seen->prev;
            if (seenb == seen) seenb = seen->next;
            MyFree(seen->userhost);
            MyFree(seen->msg);
            MyFree(seen);
        }
        seen = saved;
    }

    notice(n_SeenServ, lptr->nick, "Done.");

} /* es_unseen() */
Ejemplo n.º 4
0
static void
g_motd(struct Luser *lptr, int ac, char **av)

{
  RecordCommand("%s: %s!%s@%s MOTD",
                n_Global,
                lptr->nick,
                lptr->username,
                lptr->hostname);

  if (!Network->LogonNewsFile.Contents)
    {
      notice(n_Global, lptr->nick,
             "No logon news specified");
      return;
    }

  SendMessageFile(lptr, &Network->LogonNewsFile);
} /* g_motd() */
Ejemplo n.º 5
0
/*
 * Show operators. Code from IrcBg, slightly modified. -kre
 */
static void ss_showopers(struct Luser *lptr, int ac, char **av)
{
	int iCnt = 0;
	struct Luser *tempuser;

	RecordCommand("%s: %s!%s@%s SHOWOPERS",
	              n_StatServ, lptr->nick, lptr->username, lptr->hostname);

	notice(n_StatServ, lptr->nick, "Currently online irc operators");
	notice(n_StatServ, lptr->nick, "-------------------------------");

	for (tempuser = ClientList; tempuser; tempuser = tempuser->next)
	{
		if (IsOperator(tempuser))
			notice(n_StatServ, lptr->nick , "[%d] %s", ++iCnt,tempuser->nick );
	}

	notice(n_StatServ, lptr->nick, "-------------------------------");
	notice(n_StatServ, lptr->nick, " %d operators online.", iCnt);
}
Ejemplo n.º 6
0
/*
 * Show services adminstrators. Code from IrcBg, slightly modified. -kre
 */
static void ss_showadmins(struct Luser *lptr, int ac, char **av)
{
	int iCnt = 0;
	struct Luser *tempuser;

	RecordCommand("%s: %s!%s@%s SHOWADMINS",
	              n_StatServ, lptr->nick, lptr->username, lptr->hostname);

	notice(n_StatServ, lptr->nick, "Currently online services admins");
	notice(n_StatServ, lptr->nick, "--------------------------------");

	for (tempuser = ClientList; tempuser; tempuser = tempuser->next)
	{
		if (IsValidAdmin(tempuser))
			notice(n_StatServ, lptr->nick , "[%d] %s", ++iCnt,tempuser->nick );
	}

	notice(n_StatServ, lptr->nick, "--------------------------------");
	notice(n_StatServ, lptr->nick, " %d admins online.", iCnt);
}
Ejemplo n.º 7
0
static void
ss_refresh(struct Luser *lptr, int ac, char **av)

{
	if (!LagDetect)
	{
		notice(n_StatServ, lptr->nick,
		       "Lag Detection is disabled");
		return;
	}

	RecordCommand("%s: %s!%s@%s REFRESH",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname);

	notice(n_StatServ, lptr->nick,
	       "Updating server lag information");

	DoPings();
} /* ss_refresh() */
Ejemplo n.º 8
0
void ProcModify( void )
{
    const char          *startpos;
    mad_type_handle     mth;
    mad_type_kind       tk;

    if( !AdvMachState( ACTION_MODIFY_MEMORY ) ) {
        FlushEOC();
        return;
    }
    startpos = ScanPos();
    if( CurrToken != T_DIV ) {
        MemMod( GetMADTypeHandleDefaultAt( NilAddr, MTK_BASIC ), MAS_MEMORY );
    } else {
        Scan();
        mth = ScanType( MAS_ALL | MTK_ALL, &tk );
        if( mth == MAD_NIL_TYPE_HANDLE ) {
            Error( ERR_LOC, LIT_ENG( ERR_BAD_OPTION ), GetCmdName( CMD_MODIFY ) );
        }
        MemMod( mth, tk );
    }
    RecordCommand( startpos, CMD_MODIFY );
}
Ejemplo n.º 9
0
/*
 * es_seenstat()
 *
 * Give lptr seen statistics
 */
static void es_seenstat(struct Luser *lptr, int ac, char **av)
{
    int total = 0, quits = 0, nicks = 0;
    aSeen *seen;

    RecordCommand("%s: %s!%s@%s SEENSTAT",
                  n_SeenServ,
                  lptr->nick,
                  lptr->username,
                  lptr->hostname);

    for (seen = seenp; seen; seen = seen->prev)
    {
        total++;
        if (seen->type == 1) quits++;
        else if (seen->type == 2) nicks++;
    }

    notice(n_SeenServ, lptr->nick, "Total number of nicks seen: %d", total);
    notice(n_SeenServ, lptr->nick, "...of these, QUIT msgs: %d", quits);
    notice(n_SeenServ, lptr->nick, "...of these, NICK msgs: %d", nicks);

} /* es_seenstat() */
Ejemplo n.º 10
0
static void
ss_greplog(struct Luser *lptr, int ac, char **av )
{
	int             day;
	char            buf[MAXLINE + 1];
	char            date[10];
	FILE *          lf;
	char            grep_log_filename[MAXLINE + 1];
	int             i;
	struct tm *     tm;
	int             iCounter;

	if (ac < 3)
	{
		notice(n_StatServ,lptr->nick,
		       "Syntax: \002GREPLOG <service> <pattern> [days]\002");
		return;
	}

	if (ac > 3 && av[3] != NULL)
		day = atoi(av[3]);
	else
		day = 0;

	if (day < 0)
	{
		notice(n_StatServ, lptr->nick, "Day count should be positive.");
		return;
	}

	if (!GetService(av[1]))
	{
		notice(n_StatServ, lptr->nick, "Invalid service!");
		return;
	}

	iCounter = 0;
	tm = localtime(&current_ts);

	RecordCommand("%s: %s!%s@%s GREPLOG [%s %s] %s", n_StatServ, lptr->nick,
			lptr->username, lptr->hostname,
			av[1], av[2], (ac >= 4) ? av[3] : "");

	ircsprintf(date, "%4.4d%2.2d%2.2d",
	           tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);

	for (i = 0; i <= day; i++)
	{
		if (i == 0)
			ircsprintf(grep_log_filename, "%s/%s", LogPath, LogFile);
		else
			ircsprintf(grep_log_filename, "%s/%s.%8.8ld", LogPath, LogFile,
			           korectdat(atol(date), -i));

		if ((lf = fopen(grep_log_filename, "r")) == NULL)
		{
			notice(n_StatServ, lptr->nick, "No log file: %s",
			       grep_log_filename);
			continue;
		}
		notice(n_StatServ, lptr->nick,
		       "Searching for [%s] with service [%s] for [%d] days in file [%s]",
		       av[2], av[1], day, grep_log_filename);

		while (fgets(buf, sizeof(buf), lf))
		{
			if ((ircncmp(buf + 25, av[1], strlen(av[1])) == 0)
			        && match(av[2], buf + 25 + strlen(av[1]) + 2))
			{
				iCounter ++;
				notice(n_StatServ, lptr->nick,
				       "[%d] ... %s", iCounter, buf);
			}
		}
		fclose(lf);
	}
	notice(n_StatServ, lptr->nick, "End of search." );

	return;
} /* o_greplog */
Ejemplo n.º 11
0
void
UpdateUserModes(struct Luser *user, char *modes)

{
	int PLUS = 1;
	int umode;
	unsigned int ii;

	if (!modes || !user)
		return;

	for (ii = 0; ii < strlen(modes); ii++)
	{
		if (modes[ii] == '+')
		{
			PLUS = 1;
			continue;
		}
		if (modes[ii] == '-')
		{
			PLUS = 0;
			continue;
		}
		umode = 0;
		if (modes[ii] == 'i')
			umode = UMODE_I;
		if (modes[ii] == 's')
			umode = UMODE_S;
		if (modes[ii] == 'w')
			umode = UMODE_W;
		if (modes[ii] == 'o')
			umode = UMODE_O;
#ifdef DANCER

		if (modes[ii] == 'e')
			if (PLUS)
			{
				struct NickInfo* realptr = FindNick(user->nick);
				if (realptr)
				{
					realptr->flags |= NS_IDENTIFIED;
					RecordCommand("User %s has +e umode, marking as identified",user->nick);
					umode = UMODE_E;
				}
				else
				{
					/* Blech, who is screwing with us? */
					toserv(":%s MODE %s -e\r\n", Me.name, user->nick);
					RecordCommand("User %s has +e umode but is not known to me, setting -e",
					              user->nick);
					umode = 0;
				}
			}
#endif /* DANCER */

		if (!umode)
			continue;

		if (PLUS)
		{
			if ((umode == UMODE_O) && (!IsOperator(user)))
			{
#ifdef STATSERVICES
				char *hostname, *domain;
				struct HostHash *hosth, *domainh;
				time_t currtime = current_ts;
#endif

#ifdef NICKSERVICES

				CheckOper(user);
#endif

				Network->TotalOperators++;

				if (SafeConnect)
					SendUmode(OPERUMODE_O,
					          "*** New Operator: %s (%s@%s) [%s]",
					          user->nick,
					          user->username,
					          user->hostname,
					          user->server ? user->server->name : "*unknown*");

#ifdef STATSERVICES

				if (Network->TotalOperators > Network->MaxOperators)
				{
					Network->MaxOperators = Network->TotalOperators;
					Network->MaxOperators_ts = current_ts;

					if ((Network->MaxOperators % 5) == 0)
					{
						/* inform +y people of new max oper count */
						SendUmode(OPERUMODE_Y,
						          "*** New Max Operator Count: %ld",
						          Network->MaxOperators);
						putlog(LOG2, "New Max Operator Count: %ld",
								Network->MaxOperators);
					}
				}
				if (Network->TotalOperators > Network->MaxOperatorsT)
				{
					Network->MaxOperatorsT = Network->TotalOperators;
					Network->MaxOperatorsT_ts = current_ts;
				}
#endif

				if (user->server)
				{
					user->server->numopers++;

#ifdef STATSERVICES

					if (user->server->numopers > user->server->maxopers)
					{
						user->server->maxopers = user->server->numopers;
						user->server->maxopers_ts = current_ts;
					}
#endif

				}

#ifdef STATSERVICES
				hostname = user->hostname;

				if ((hosth = FindHost(hostname)))
				{
					hosth->curropers++;
					if (hosth->curropers > hosth->maxopers)
					{
						hosth->maxopers = hosth->curropers;
						hosth->maxopers_ts = currtime;
					}
				}

				if ((domain = GetDomain(hostname)))
				{
					if ((domainh = FindDomain(domain)))
					{
						domainh->curropers++;
						if (domainh->curropers > domainh->maxopers)
						{
							domainh->maxopers = domainh->curropers;
							domainh->maxopers_ts = currtime;
						}
					}
				}
#endif /* STATSERVICES */

			}
			user->umodes |= umode;
		}
		else
		{
			if ((umode == UMODE_O) && (IsOperator(user)))
			{
#ifdef STATSERVICES
				char *hostname, *domain;
				struct HostHash *hosth, *domainh;
#endif

				Network->TotalOperators--;
				if (user->server)
					user->server->numopers--;

#ifdef STATSERVICES

				hostname = user->hostname;

				if ((hosth = FindHost(hostname)))
					hosth->curropers--;

				if ((domain = GetDomain(hostname)))
					if ((domainh = FindDomain(domain)))
						domainh->curropers--;
#endif

			}
			user->umodes &= ~umode;
		}
	}
} /* UpdateUserModes() */
Ejemplo n.º 12
0
struct Luser *
			AddClient(char **line)

{
	char *ch;
	struct Luser *tempuser,
				*newptr;

#ifdef BLOCK_ALLOCATION

	tempuser = (struct Luser *) BlockSubAllocate(ClientHeap);
	if (!tempuser) /* shouldn't happen - but I'm paranoid :) */
		return (NULL);

	memset(tempuser, 0, sizeof(struct Luser));

	strlcpy(tempuser->nick, line[1], NICKLEN + 1);
	strlcpy(tempuser->username, line[5], USERLEN + 1);
	strlcpy(tempuser->hostname, line[6], HOSTLEN + 1);
	strlcpy(tempuser->realname, line[8] + 1, REALLEN + 1);

#else

	tempuser = (struct Luser *) MyMalloc(sizeof(struct Luser));
	memset(tempuser, 0, sizeof(struct Luser));

	tempuser->nick = MyStrdup(line[1]);
	tempuser->username = MyStrdup(line[5]);
	tempuser->hostname = MyStrdup(line[6]);
	tempuser->realname = MyStrdup(line[8] + 1);

#endif /* BLOCK_ALLOCATION */

	tempuser->since = atol(line[3]);

#ifdef NICKSERVICES

	tempuser->nick_ts = tempuser->since;

#if defined SVSNICK || defined FORCENICK
	tempuser->flags &= ~(UMODE_NOFORCENICK);
#endif

#endif /* NICKSERVICES */

	if ((tempuser->server = FindServer(line[7])))
{
		tempuser->server->numusers++;

#ifdef STATSERVICES

		if (tempuser->server->numusers > tempuser->server->maxusers)
		{
			tempuser->server->maxusers = tempuser->server->numusers;
			tempuser->server->maxusers_ts = current_ts;
		}
#endif

	}

	ch = &line[4][1];
	while (*ch)
	{
		switch (*ch)
		{
		case 'i':
		case 'I':
			{
				tempuser->umodes |= UMODE_I;
				break;
			}
		case 's':
		case 'S':
			{
				tempuser->umodes |= UMODE_S;
				break;
			}
		case 'w':
		case 'W':
			{
				tempuser->umodes |= UMODE_W;
				break;
			}
		case 'o':
		case 'O':
			{
				tempuser->umodes |= UMODE_O;

				Network->TotalOperators++;

#ifdef STATSERVICES

				if (Network->TotalOperators > Network->MaxOperators)
				{
					Network->MaxOperators = Network->TotalOperators;
					Network->MaxOperators_ts = current_ts;

					if ((Network->MaxOperators % 5) == 0)
					{
						/* inform +y people of new max oper count */
						SendUmode(OPERUMODE_Y,
						          "*** New Max Operator Count: %ld",
						          Network->MaxOperators);
						putlog(LOG2, "New Max Operator Count: %ld",
								Network->MaxOperators);
					}
				}
				if (Network->TotalOperators > Network->MaxOperatorsT)
				{
					Network->MaxOperatorsT = Network->TotalOperators;
					Network->MaxOperatorsT_ts = current_ts;
				}
#endif

				if (tempuser->server)
				{
					tempuser->server->numopers++;

#ifdef STATSERVICES

					if (tempuser->server->numopers > tempuser->server->maxopers)
					{
						tempuser->server->maxopers = tempuser->server->numopers;
						tempuser->server->maxopers_ts = current_ts;
					}
#endif

				}
				break;
			} /* case 'O' */
#ifdef DANCER
		case 'e':
		case 'E':
			{
				struct NickInfo *realptr;
				realptr = FindNick(tempuser->nick);
				if (realptr)
				{
					realptr->flags |= NS_IDENTIFIED;
					tempuser->umodes |= UMODE_E;
					RecordCommand("User %s has +e umode, marking as identified",
					              tempuser->nick);
				}
				else
				{
					/* Is it one of mine? */
					int mine = 0;
					struct aService *sptr;
					for (sptr = ServiceBots; sptr->name; ++sptr)
						if (!irccmp(tempuser->nick, *(sptr->name)))
						{
							mine = 1;
							break;
						}
					if (!mine)
					{
						/* Blech, who is screwing with us? */
						toserv(":%s MODE %s -e\r\n", Me.name, tempuser->nick);
						RecordCommand("User %s has +e umode but is not known to me, setting -e",
						              tempuser->nick);
					}
				}
				break;
			}
#endif /* DANCER */
		default:
			break;
		} /* switch (*ch) */
		ch++;
	}

	tempuser->next = ClientList;
	tempuser->prev = NULL;
	if (tempuser->next)
		tempuser->next->prev = tempuser;
	ClientList = tempuser;

	/* add client to the hash table */
	newptr = HashAddClient(ClientList, 0);

	Network->TotalUsers++;
#ifdef STATSERVICES

	if (Network->TotalUsers > Network->MaxUsers)
	{
		Network->MaxUsers = Network->TotalUsers;
		Network->MaxUsers_ts = current_ts;

		if ((Network->MaxUsers % 10) == 0)
		{
			/* notify +y people of new max user count */
			SendUmode(OPERUMODE_Y,
			          "*** New Max Client Count: %ld",
			          Network->MaxUsers);
			putlog(LOG2, "New Max Client Count: %ld",
					Network->MaxUsers);
		}
	}
	if (Network->TotalUsers > Network->MaxUsersT)
	{
		Network->MaxUsersT = Network->TotalUsers;
		Network->MaxUsersT_ts = current_ts;
	}
#endif /* STATSERVICES */

#ifdef ALLOW_GLINES
	/*
	 * It's possible the client won't exist anymore, because if the user
	 * is a clone and AutoKillClones is enabled, HashAddClient() would
	 * have already killed the user, in which case newptr will be
	 * NULL - CheckGlined() checks for null pointers
	 */
	CheckGlined(newptr); /* Check if new user is glined */
#endif

	return (tempuser);
} /* AddClient() */
Ejemplo n.º 13
0
static void
ss_stats(struct Luser *lptr, int ac, char **av)

{
	float avgops, avguc, avgus;
	struct tm *tmp_tm;
	char str[MAXLINE + 1], tmp[MAXLINE + 1];
	char **tav;
	time_t currtime;

	RecordCommand("%s: %s!%s@%s STATS",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname);

	avgops = Network->TotalOperators / Network->TotalServers;
	if (Network->TotalChannels > 0.0)
		avguc = Network->TotalUsers / Network->TotalChannels;
	else
		avguc = 0;
	avgus = Network->TotalUsers / Network->TotalServers;

	notice(n_StatServ, lptr->nick,
	       "Current Users:              %1.0f (avg. %1.2f users per server)",
	       Network->TotalUsers,
	       avgus);
	notice(n_StatServ, lptr->nick,
	       "Current Operators:          %1.0f (avg. %1.2f operators per server)",
	       Network->TotalOperators,
	       avgops);
	notice(n_StatServ, lptr->nick,
	       "Current Channels:           %1.0f (avg. %1.2f users per channel)",
	       Network->TotalChannels,
	       avguc);
	notice(n_StatServ, lptr->nick,
	       "Current Servers:            %1.0f",
	       Network->TotalServers);

	strlcpy(str, ctime(&Network->MaxUsers_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Users:                  %ld on %s",
	       Network->MaxUsers,
	       str);

	if (Network->MaxOperators_ts)
	{
		strlcpy(str, "on ", sizeof(str));
		strlcat(str, ctime(&Network->MaxOperators_ts), sizeof(str));
		str[strlen(str) - 1] = '\0';
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Operators:              %ld %s",
	       Network->MaxOperators,
	       str);

	if (Network->MaxChannels_ts)
	{
		strlcpy(str, "on ", sizeof(str));
		strlcat(str, ctime(&Network->MaxChannels_ts), sizeof(str));
		str[strlen(str) - 1] = '\0';
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Channels:               %ld %s",
	       Network->MaxChannels,
	       str);

	strlcpy(str, ctime(&Network->MaxServers_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Servers:                %ld on %s",
	       Network->MaxServers,
	       str);

	notice(n_StatServ, lptr->nick,
	       "Identd Users:               %ld",
	       Network->Identd);
	notice(n_StatServ, lptr->nick,
	       "Non-Identd Users:           %ld",
	       Network->NonIdentd);
	notice(n_StatServ, lptr->nick,
	       "Resolving Host Users:       %ld",
	       Network->ResHosts);
	notice(n_StatServ, lptr->nick,
	       "Non-Resolving Host Users:   %ld",
	       (long) Network->TotalUsers - Network->ResHosts);

	currtime = current_ts;
	strlcpy(tmp, ctime(&currtime), sizeof(tmp));
	SplitBuf(tmp, &tav);
	ircsprintf(str, "%s %s %s, %s", tav[0], tav[1], tav[2], tav[4]);
	notice(n_StatServ, lptr->nick,
	       "-- \002So far today:\002 (%s) --",
	       str);
	MyFree(tav);

	if (Network->MaxUsersT_ts)
	{
		tmp_tm = localtime(&Network->MaxUsersT_ts);
		ircsprintf(str, "at %d:%02d:%02d", tmp_tm->tm_hour, tmp_tm->tm_min,
		           tmp_tm->tm_sec);
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Users:                  %ld %s",
	       Network->MaxUsersT,
	       str);

	if (Network->MaxOperatorsT_ts)
	{
		tmp_tm = localtime(&Network->MaxOperatorsT_ts);
		ircsprintf(str, "at %d:%02d:%02d", tmp_tm->tm_hour, tmp_tm->tm_min,
		           tmp_tm->tm_sec);
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Operators:              %ld %s",
	       Network->MaxOperatorsT,
	       str);

	if (Network->MaxChannelsT_ts)
	{
		tmp_tm = localtime(&Network->MaxChannelsT_ts);
		ircsprintf(str, "at %d:%02d:%02d", tmp_tm->tm_hour, tmp_tm->tm_min,
		           tmp_tm->tm_sec);
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Channels:               %ld %s",
	       Network->MaxChannelsT,
	       str);

	if (Network->MaxServersT_ts)
	{
		tmp_tm = localtime(&Network->MaxServersT_ts);
		ircsprintf(str, "at %d:%02d:%02d", tmp_tm->tm_hour, tmp_tm->tm_min,
		           tmp_tm->tm_sec);
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Servers:                %ld %s",
	       Network->MaxServersT,
	       str);

	notice(n_StatServ, lptr->nick,
	       "Operator Kills:             %ld",
	       Network->OperKillsT);
	notice(n_StatServ, lptr->nick,
	       "Server Kills:               %ld",
	       Network->ServKillsT);
} /* ss_stats() */
Ejemplo n.º 14
0
static void
ss_server(struct Luser *lptr, int ac, char **av)

{
	struct Server *servptr,
				*hub;
	char argbuf[MAXLINE + 1],
	str[MAXLINE + 1];
	char *target; /* target server */
	int maxusers, /* -maxusers */
	minusers, /* -minusers */
	info;     /* -info */
	int ii,
	alen,
	cnt;

	if (ac < 2)
{
		notice(n_StatServ, lptr->nick,
		       "Syntax: SERVER <server | mask> [options]");
		notice(n_StatServ, lptr->nick,
		       ERR_MORE_INFO,
		       n_StatServ,
		       "SERVER");
		return;
	}

	hub = NULL;
	maxusers = -1;
	minusers = -1;
	target = NULL;
	info = 0;

	/*
	 * Parse their args
	 */
	for (ii = 1; ii < ac; ii++)
	{
		alen = strlen(av[ii]);

		if (!ircncmp(av[ii], "-maxusers", alen))
		{
			if (++ii >= ac)
			{
				notice(n_StatServ, lptr->nick,
				       "No maximum user count given");
				return;
			}

			maxusers = atoi(av[ii]);
		}
		else if (!ircncmp(av[ii], "-minusers", alen))
		{
			if (++ii >= ac)
			{
				notice(n_StatServ, lptr->nick,
				       "No minimum user count given");
				return;
			}

			minusers = atoi(av[ii]);
		}
		else if (!ircncmp(av[ii], "-info", alen))
			info = 1;
		else if (!ircncmp(av[ii], "-hub", alen))
		{
			if (++ii >= ac)
			{
				notice(n_StatServ, lptr->nick,
				       "No hub server given");
				return;
			}

			if (!(hub = FindServer(av[ii])))
			{
				notice(n_StatServ, lptr->nick,
				       "No such server: %s",
				       av[ii]);
				return;
			}
		}
		else
		{
			if (!target)
				target = av[ii];
		}
	}

	if (!target)
	{
		notice(n_StatServ, lptr->nick,
		       "No target server specified");
		return;
	}

	argbuf[0] = '\0';

	if (maxusers >= 0)
	{
		ircsprintf(str, "-maxusers %d ", maxusers);
		strlcat(argbuf, str, sizeof(argbuf));
	}

	if (minusers >= 0)
	{
		ircsprintf(str, "-minusers %d ", minusers);
		strlcat(argbuf, str, sizeof(argbuf));
	}

	if (info)
		strlcat(argbuf, "-info ", sizeof(argbuf));

	if (hub)
	{
		ircsprintf(str, "-hub %s ", hub->name);
		strlcat(argbuf, str, sizeof(argbuf));
	}

	RecordCommand("%s: %s!%s@%s SERVER [%s] %s",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname,
	              target,
	              argbuf);

	if ((servptr = FindServer(target)))
	{
		ShowServerInfo(servptr, lptr, 1);
		return;
	}

	cnt = 0;
	for (servptr = ServerList; servptr; servptr = servptr->next)
	{
		if (!match(target, servptr->name))
			continue;

		if (((maxusers >= 0) && (servptr->numusers > maxusers)) ||
		        ((minusers >= 0) && (servptr->numusers < minusers)))
			continue;
		else if (hub && (servptr->uplink != hub))
			continue;

		/*
		 * servptr passes all the tests
		 */

		++cnt;

		notice(n_StatServ, lptr->nick,
		       "-----");

		ShowServerInfo(servptr, lptr, info);
	}

	notice(n_StatServ, lptr->nick,
	       "%d match%s found",
	       cnt,
	       (cnt == 1) ? "" : "es");
} /* ss_server() */
Ejemplo n.º 15
0
static void
ss_domain(struct Luser *lptr, int ac, char **av)

{
	struct HostHash *hosth;
	char *domain;
	char str[MAXLINE + 1];

	if (ac < 2)
	{
		notice(n_StatServ, lptr->nick,
		       "Syntax: DOMAIN <domain>");
		notice(n_StatServ, lptr->nick,
		       ERR_MORE_INFO,
		       n_StatServ,
		       "DOMAIN");
		return;
	}

	domain = GetDomain(av[1]);

	RecordCommand("%s: %s!%s@%s DOMAIN [%s]",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname,
	              domain ? domain : av[1]);

	if (!(hosth = FindDomain(domain)))
	{
		notice(n_StatServ, lptr->nick,
		       "No domains matching [\002%s\002] found",
		       domain ? domain : av[1]);
		return;
	}

	notice(n_StatServ, lptr->nick,
	       "Statistics for domain: \002%s\002",
	       domain);
	notice(n_StatServ, lptr->nick,
	       "Current Clients:  %ld (%ld unique)",
	       hosth->currclients,
	       hosth->currunique);
	notice(n_StatServ, lptr->nick,
	       "Current Opers:    %ld",
	       hosth->curropers);

	strlcpy(str, ctime(&hosth->maxclients_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Clients:      %ld on %s",
	       hosth->maxclients,
	       str);

	strlcpy(str, ctime(&hosth->maxunique_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Unique:       %ld on %s",
	       hosth->maxunique,
	       str);

	if (hosth->maxopers_ts)
	{
		strlcpy(str, "on ", sizeof(str));
		strlcat(str, ctime(&hosth->maxopers_ts), sizeof(str));
		str[strlen(str) - 1] = '\0';
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Operators:    %ld %s",
	       hosth->maxopers,
	       str);

	notice(n_StatServ, lptr->nick,
	       "Identd Users:     %ld",
	       hosth->curridentd);
	notice(n_StatServ, lptr->nick,
	       "Non-Identd Users: %ld",
	       hosth->currclients - hosth->curridentd);
} /* ss_domain() */
Ejemplo n.º 16
0
static void
g_gnote(struct Luser *lptr, int ac, char **av)

{
  int cnt,
  alen,
  bad,
  ii;
  int all,
  ops,
  opers,
  admins;
  char *message;
  char argbuf[MAXLINE + 1];
  char temp[MAXLINE * 2];
  struct Luser *tempuser;
  struct Userlist *userptr;

  if (!GlobalNotices)
    {
      notice(n_Global, lptr->nick,
             "Global notices are disabled");
      return;
    }

  if (ac < 2)
    {
      notice(n_Global, lptr->nick,
             "Syntax: \002GNOTE [options] <message>\002");
      return;
    }

  all = 0;
  ops = 0;
  opers = 0;
  admins = 0;
  message = NULL;

  for (cnt = 1; cnt < ac; ++cnt)
    {
      alen = strlen(av[cnt]);

      if (!ircncmp(av[cnt], "-all", alen))
        all = 1;
      else if (!ircncmp(av[cnt], "-ops", alen))
        ops = 1;
      else if (!ircncmp(av[cnt], "-opers", alen))
        opers = 1;
      else if (!ircncmp(av[cnt], "-admins", alen))
        admins = 1;
      else
        {
          message = GetString(ac - cnt, av + cnt);
          break;
        }
    }

  if (!message)
    {
      notice(n_Global, lptr->nick,
             "No message specified");
      return;
    }

  if (!all && !ops && !opers && !admins)
    all = 1; /* -all is the default */

  *argbuf = '\0';

  if (all)
    strcat(argbuf, "-all ");

  if (ops)
    strcat(argbuf, "-ops ");

  if (opers)
    strcat(argbuf, "-opers ");

  if (admins)
    strcat(argbuf, "-admins ");

  ircsprintf(temp, "%s%s", argbuf, message);
  strncpy(argbuf, temp, MAXLINE);
  argbuf[MAXLINE] = '\0';

  RecordCommand("%s: %s!%s@%s GNOTE %s",
                n_Global,
                lptr->nick,
                lptr->username,
                lptr->hostname,
                argbuf);

  cnt = 0;

  for (tempuser = ClientList; tempuser; tempuser = tempuser->next)
    {
      if (FindService(tempuser))
        continue;

      if (!ircncmp(Me.name, tempuser->server->name,
                   strlen(tempuser->server->name)))
        continue;

      bad = 0;

      if (!all)
        {
          if (opers && !IsOperator(tempuser))
            bad = 1;
          else
            {
              if (tempuser->flags & L_OSREGISTERED)
                ii = 1;
              else
                ii = 0;

              userptr = GetUser(ii,
                                tempuser->nick,
                                tempuser->username,
                                tempuser->hostname);

              if (ops && !IsOper(userptr))
                bad = 1;
              else if (admins && !IsAdmin(userptr))
                bad = 1;
            }
        }

      if (bad)
        continue;

      notice(n_Global, tempuser->nick, message);

      ++cnt;
    }

  notice(n_Global, lptr->nick,
         "Message sent (%d match%s)",
         cnt,
         (cnt == 1) ? "" : "es");

  MyFree(message);
} /* g_gnote() */
Ejemplo n.º 17
0
static void
g_gchannote(struct Luser *lptr, int ac, char **av)

{
  int cnt,
  alen;
  char *mask;
  char *message;
  char argbuf[MAXLINE + 1],
  temp[MAXLINE + 1];
  struct Channel *cptr;

  if (!GlobalNotices)
    {
      notice(n_Global, lptr->nick,
             "Global notices are disabled");
      return;
    }

  if (ac < 2)
    {
      notice(n_Global, lptr->nick,
             "Syntax: \002GCHANNOTE [options] <message>\002");
      return;
    }

  mask = NULL;
  message = NULL;

  for (cnt = 1; cnt < ac; ++cnt)
    {
      alen = strlen(av[cnt]);

      if (!ircncmp(av[cnt], "-mask", alen))
        {
          if (++cnt >= ac)
            {
              notice(n_Global, lptr->nick,
                     "No mask specified");
              return;
            }

          mask = av[cnt];
        }
      else
        {
          message = GetString(ac - cnt, av + cnt);
          break;
        }
    }

  if (!message)
    {
      notice(n_Global, lptr->nick,
             "No message specified");
      return;
    }

  *argbuf = '\0';

  if (mask)
    ircsprintf(argbuf, "-mask %s ", mask);

  ircsprintf(temp, "%s%s", argbuf, message);

  strncpy(argbuf, temp, sizeof(argbuf) - 1);
  argbuf[sizeof(argbuf) - 1] = '\0';

  RecordCommand("%s: %s!%s@%s GCHANNOTE %s",
                n_Global,
                lptr->nick,
                lptr->username,
                lptr->hostname,
                argbuf);

  cnt = 0;
  for (cptr = ChannelList; cptr; cptr = cptr->next)
    {
      if (mask && !match(mask, cptr->name))
        continue;

      *temp = '-';
      *(temp + 1) = '\0';
      if (cptr->modes & MODE_N)
        strcat(temp, "n");
      if (cptr->modes & MODE_M)
        strcat(temp, "m");

      if (*(temp + 1))
        DoMode(cptr, temp, 0);

      notice(n_Global, cptr->name, message);
      ++cnt;

      if (*(temp + 1))
        {
          *temp = '+';
          DoMode(cptr, temp, 0);
        }
    }

  notice(n_Global, lptr->nick,
         "Channel message sent (%d match%s)",
         cnt,
         (cnt == 1) ? "" : "es");

  MyFree(message);
} /* g_gchannote() */
Ejemplo n.º 18
0
static void
ss_clearstats(struct Luser *lptr, int ac, char **av)

{
	int ii, bad;
	struct HostHash *hosth, *hnext;
	char buf[MAXLINE + 1],
	buf2[MAXLINE + 1];
	int domain,
	host;

	domain = 0;
	host = 0;

	if (ac >= 2)
	{
		for (ii = 1; ii < ac; ii++)
		{
			if (!ircncmp(av[ii], "-domain", strlen(av[ii])))
				domain = 1;
			else if (!ircncmp(av[ii], "-host", strlen(av[ii])))
				host = 1;
			else if (!ircncmp(av[ii], "-all", strlen(av[ii])))
				host = domain = 1;
		}
	}
	else
	{
		/*
		 * They didn't give an option - delete everything by
		 * default
		 */
		host = domain = 1;
	}

	buf[0] = '\0';
	buf2[0] = '\0';

	if (domain && host)
	{
		strlcat(buf, "-all", sizeof(buf));
		strlcat(buf2, "All", sizeof(buf2));
	}
	else
	{
		if (domain)
		{
			strlcat(buf, "-domain", sizeof(buf));
			strlcat(buf2, "Domains", sizeof(buf2));
		}

		if (host)
		{
			strlcat(buf, "-host", sizeof(buf));
			strlcat(buf2, "Hostnames", sizeof(buf2));
		}
	}

	RecordCommand("%s: %s!%s@%s CLEARSTATS %s",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname,
	              buf);

	for (ii = 0; ii < HASHCLIENTS; ii++)
	{
		bad = 0;
		hosth = hostTable[ii].list;
		while (hosth)
		{
			if (!domain && (hosth->flags & SS_DOMAIN))
				bad = 1;
			if (!host && !(hosth->flags & SS_DOMAIN))
				bad = 1;

			if (bad)
			{
				bad = 0;
				hosth = hosth->hnext;
				continue;
			}

			hnext = hosth->hnext;
			MyFree(hosth->hostname);
			MyFree(hosth);

			/*
			 * Make sure we set hostTable[ii].list to hnext as well
			 * or it will not be set to NULL at the end of the list,
			 * which could cause big problems
			 */
			hostTable[ii].list = hosth = hnext;
		}
	}

	notice(n_StatServ, lptr->nick,
	       "Statistics cleared: %s",
	       buf2);
} /* ss_clearstats() */