InspIRCd  3.0
cmd_whowas.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2009 Daniel De Graaf <[email protected]>
5  * Copyright (C) 2007 Dennis Friis <[email protected]>
6  * Copyright (C) 2006 Craig Edwards <[email protected]>
7  *
8  * This file is part of InspIRCd. InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #pragma once
23 
24 #include "modules.h"
25 
26 namespace WhoWas
27 {
30  struct Entry
31  {
34  const std::string host;
35 
38  const std::string dhost;
39 
42  const std::string ident;
43 
46  const std::string server;
47 
50  const std::string real;
51 
54  const time_t signon;
55 
58  Entry(User* user);
59  };
60 
63  struct Nick : public insp::intrusive_list_node<Nick>
64  {
67  typedef std::deque<Entry*> List;
68 
72 
75  const time_t addtime;
76 
79  const std::string nick;
80 
83  Nick(const std::string& nickname);
84 
87  ~Nick();
88  };
89 
90  class Manager
91  {
92  public:
93  struct Stats
94  {
97  size_t entrycount;
98  };
99 
103  void Add(User* user);
104 
108  Stats GetStats() const;
109 
112  void Maintain();
113 
121  void UpdateConfig(unsigned int NewGroupSize, unsigned int NewMaxGroups, unsigned int NewMaxKeep);
122 
127  const Nick* FindNick(const std::string& nick) const;
128 
132  bool IsEnabled() const;
133 
136  Manager();
137 
140  ~Manager();
141 
142  private:
146 
149  typedef TR1NS::unordered_map<std::string, WhoWas::Nick*, irc::insensitive, irc::StrHashComp> whowas_users;
150 
153  whowas_users whowas;
154 
157  FIFO whowas_fifo;
158 
161  unsigned int GroupSize;
162 
166  unsigned int MaxGroups;
167 
170  unsigned int MaxKeep;
171 
174  void Prune();
175 
179  void PurgeNick(whowas_users::iterator it);
180 
184  void PurgeNick(WhoWas::Nick* nick);
185  };
186 }
187 
193 class CommandWhowas : public Command
194 {
195  public:
199 
200  CommandWhowas(Module* parent);
206  CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
207 };
WhoWas::Entry::Entry
Entry(User *user)
CommandWhowas
Definition: cmd_whowas.h:193
WhoWas::Nick::Nick
Nick(const std::string &nickname)
WhoWas::Nick::entries
List entries
Definition: cmd_whowas.h:71
WhoWas::Manager::IsEnabled
bool IsEnabled() const
WhoWas::Manager
Definition: cmd_whowas.h:90
WhoWas::Nick::~Nick
~Nick()
WhoWas::Entry::ident
const std::string ident
Definition: cmd_whowas.h:42
WhoWas::Manager::~Manager
~Manager()
WhoWas::Manager::Stats
Definition: cmd_whowas.h:93
CommandWhowas::manager
WhoWas::Manager manager
Definition: cmd_whowas.h:198
WhoWas::Entry::server
const std::string server
Definition: cmd_whowas.h:46
WhoWas::Entry::real
const std::string real
Definition: cmd_whowas.h:50
WhoWas::Entry::dhost
const std::string dhost
Definition: cmd_whowas.h:38
WhoWas::Manager::Manager
Manager()
WhoWas::Manager::UpdateConfig
void UpdateConfig(unsigned int NewGroupSize, unsigned int NewMaxGroups, unsigned int NewMaxKeep)
WhoWas::Manager::GetStats
Stats GetStats() const
WhoWas::Entry::signon
const time_t signon
Definition: cmd_whowas.h:54
WhoWas::Entry::host
const std::string host
Definition: cmd_whowas.h:34
insp::intrusive_list_node
Definition: intrusive_list.h:33
Module
Definition: modules.h:242
User
Definition: users.h:224
Command
Definition: ctables.h:221
WhoWas::Nick::nick
const std::string nick
Definition: cmd_whowas.h:79
WhoWas::Manager::Stats::entrycount
size_t entrycount
Definition: cmd_whowas.h:97
WhoWas::Manager::Maintain
void Maintain()
WhoWas::Manager::FindNick
const Nick * FindNick(const std::string &nick) const
CommandWhowas::Handle
CmdResult Handle(User *user, const Params &parameters) CXX11_OVERRIDE
WhoWas::Manager::Add
void Add(User *user)
WhoWas::Nick::addtime
const time_t addtime
Definition: cmd_whowas.h:75
WhoWas::Nick
Definition: cmd_whowas.h:63
WhoWas::Nick::List
std::deque< Entry * > List
Definition: cmd_whowas.h:67
insp::intrusive_list_tail< Nick >
WhoWas::Entry
Definition: cmd_whowas.h:30
CommandBase::Params
Definition: ctables.h:114