2007-07-16 17:30:04 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2010-01-11 03:07:32 +00:00
|
|
|
* InspIRCd: (C) 2002-2010 InspIRCd Development Team
|
2009-03-15 12:42:35 +00:00
|
|
|
* See: http://wiki.inspircd.org/Credits
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
2007-07-17 18:43:39 +00:00
|
|
|
* the file COPYING for details.
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CMD_WHOWAS_H__
|
|
|
|
#define __CMD_WHOWAS_H__
|
2009-09-03 21:06:44 +00:00
|
|
|
#include "modules.h"
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2009-09-03 21:06:44 +00:00
|
|
|
struct WhowasRequest : public Request
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2009-09-03 21:06:44 +00:00
|
|
|
/* list of available internal commands */
|
|
|
|
enum Internals
|
|
|
|
{
|
|
|
|
WHOWAS_ADD = 1,
|
|
|
|
WHOWAS_STATS = 2,
|
|
|
|
WHOWAS_PRUNE = 3,
|
|
|
|
WHOWAS_MAINTAIN = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
const Internals type;
|
|
|
|
std::string value;
|
|
|
|
User* user;
|
|
|
|
|
|
|
|
WhowasRequest(Module* src, Module* whowas, Internals Type) : Request(src, whowas, "WHOWAS"), type(Type)
|
|
|
|
{}
|
2007-07-16 17:30:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Forward ref for timer */
|
|
|
|
class WhoWasMaintainTimer;
|
|
|
|
|
|
|
|
/* Forward ref for typedefs */
|
|
|
|
class WhoWasGroup;
|
|
|
|
|
2007-10-15 21:03:30 +00:00
|
|
|
/** Timer that is used to maintain the whowas list, called once an hour
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
extern WhoWasMaintainTimer* timer;
|
|
|
|
|
|
|
|
/** A group of users related by nickname
|
|
|
|
*/
|
|
|
|
typedef std::deque<WhoWasGroup*> whowas_set;
|
|
|
|
|
|
|
|
/** Sets of users in the whowas system
|
|
|
|
*/
|
|
|
|
typedef std::map<irc::string,whowas_set*> whowas_users;
|
|
|
|
|
|
|
|
/** Sets of time and users in whowas list
|
|
|
|
*/
|
|
|
|
typedef std::deque<std::pair<time_t,irc::string> > whowas_users_fifo;
|
|
|
|
|
|
|
|
/** Handle /WHOWAS. These command handlers can be reloaded by the core,
|
|
|
|
* and handle basic RFC1459 commands. Commands within modules work
|
|
|
|
* the same way, however, they can be fully unloaded, where these
|
|
|
|
* may not.
|
|
|
|
*/
|
2007-10-21 21:43:48 +00:00
|
|
|
class CommandWhowas : public Command
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
/** Whowas container, contains a map of vectors of users tracked by WHOWAS
|
|
|
|
*/
|
|
|
|
whowas_users whowas;
|
2009-02-14 21:14:36 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Whowas container, contains a map of time_t to users tracked by WHOWAS
|
|
|
|
*/
|
|
|
|
whowas_users_fifo whowas_fifo;
|
|
|
|
|
|
|
|
public:
|
2009-09-13 20:32:27 +00:00
|
|
|
CommandWhowas(Module* parent);
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Handle command.
|
|
|
|
* @param parameters The parameters to the comamnd
|
|
|
|
* @param pcnt The number of parameters passed to teh command
|
|
|
|
* @param user The user issuing the command
|
|
|
|
* @return A value from CmdResult to indicate command success or failure.
|
|
|
|
*/
|
2008-05-04 21:37:36 +00:00
|
|
|
CmdResult Handle(const std::vector<std::string>& parameters, User *user);
|
2007-10-15 20:59:05 +00:00
|
|
|
void AddToWhoWas(User* user);
|
2009-09-03 21:06:44 +00:00
|
|
|
std::string GetStats();
|
2007-07-16 17:30:04 +00:00
|
|
|
void PruneWhoWas(time_t t);
|
|
|
|
void MaintainWhoWas(time_t t);
|
2009-09-03 21:06:44 +00:00
|
|
|
~CommandWhowas();
|
2007-07-16 17:30:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Used to hold WHOWAS information
|
|
|
|
*/
|
2009-10-18 16:01:33 +00:00
|
|
|
class WhoWasGroup
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Real host
|
|
|
|
*/
|
2009-09-02 00:47:45 +00:00
|
|
|
std::string host;
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Displayed host
|
|
|
|
*/
|
2009-09-02 00:47:45 +00:00
|
|
|
std::string dhost;
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Ident
|
|
|
|
*/
|
2009-09-02 00:47:45 +00:00
|
|
|
std::string ident;
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Server name
|
|
|
|
*/
|
2009-10-02 03:15:46 +00:00
|
|
|
std::string server;
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Fullname (GECOS)
|
|
|
|
*/
|
2009-09-02 00:47:45 +00:00
|
|
|
std::string gecos;
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Signon time
|
|
|
|
*/
|
|
|
|
time_t signon;
|
|
|
|
|
2009-10-18 16:01:33 +00:00
|
|
|
/** Initialize this WhoWasFroup with a user
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
2007-10-15 20:59:05 +00:00
|
|
|
WhoWasGroup(User* user);
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Destructor
|
|
|
|
*/
|
|
|
|
~WhoWasGroup();
|
|
|
|
};
|
|
|
|
|
2007-10-15 21:03:30 +00:00
|
|
|
class WhoWasMaintainTimer : public Timer
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-26 14:13:13 +00:00
|
|
|
WhoWasMaintainTimer(long interval)
|
|
|
|
: Timer(interval, ServerInstance->Time(), true)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual void Tick(time_t TIME);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|