]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/users.h
Crude hotfix to what's been crashing chatspike
[user/henk/code/inspircd.git] / include / users.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __USERS_H__ 
15 #define __USERS_H__ 
16
17 #include <string>
18 #include "inspircd_config.h" 
19 #include "socket.h"
20 #include "channels.h"
21 #include "inspstring.h"
22 #include "connection.h"
23 #include "hashcomp.h"
24 #include "dns.h"
25 #include "cull_list.h"
26
27 enum ChanStatus {
28         STATUS_OP     = 4,
29         STATUS_HOP    = 2,
30         STATUS_VOICE  = 1,
31         STATUS_NORMAL = 0
32 };
33
34 enum ClassTypes {
35         CC_ALLOW = 0,
36         CC_DENY  = 1
37 };
38
39 /** RFC1459 channel modes
40  *  */
41 enum UserModes {
42         UM_SERVERNOTICE = 's'-65,
43         UM_WALLOPS = 'w'-65,
44         UM_INVISIBLE = 'i'-65,
45         UM_OPERATOR = 'o'-65,
46         UM_SNOMASK = 'n'-65,
47 };
48
49 enum RegistrationState {
50         REG_NONE = 0,           /* Has sent nothing */
51         REG_USER = 1,           /* Has sent USER */
52         REG_NICK = 2,           /* Has sent NICK */
53         REG_NICKUSER = 3,       /* Bitwise combination of REG_NICK and REG_USER */
54         REG_ALL = 7             /* REG_NICKUSER plus next bit along */
55 };
56
57 class InspIRCd;
58
59 /** Derived from Resolver, and performs user forward/reverse lookups.
60  */
61 class UserResolver : public Resolver
62 {
63  private:
64         /** User this class is 'attached' to.
65          */
66         userrec* bound_user;
67         int bound_fd;
68         bool fwd;
69  public:
70         UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt);
71
72         void OnLookupComplete(const std::string &result);
73         void OnError(ResolverError e, const std::string &errormessage);
74 };
75
76
77 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
78  */
79 class ConnectClass : public classbase
80 {
81  public:
82         /** Type of line, either CC_ALLOW or CC_DENY
83          */
84         char type;
85         /** Max time to register the connection in seconds
86          */
87         int registration_timeout;
88         /** Number of lines in buffer before excess flood is triggered
89          */
90         int flood;
91         /** Host mask for this line
92          */
93         std::string host;
94         /** Number of seconds between pings for this line
95          */
96         int pingtime;
97         /** (Optional) Password for this line
98          */
99         std::string pass;
100
101         /** Threshold value for flood disconnect
102          */
103         int threshold;
104
105         /** Maximum size of sendq for users in this class (bytes)
106          */
107         long sendqmax;
108
109         /** Maximum size of recvq for users in this class (bytes)
110          */
111         long recvqmax;
112
113         /** Local max when connecting by this connection class
114          */
115         long maxlocal;
116
117         /** Global max when connecting by this connection class
118          */
119         long maxglobal;
120         
121         ConnectClass() : registration_timeout(0), flood(0), host(""), pingtime(0), pass(""), threshold(0), sendqmax(0), recvqmax(0)
122         {
123         }
124 };
125
126 /** Holds a complete list of all channels to which a user has been invited and has not yet joined.
127  */
128 typedef std::vector<irc::string> InvitedList;
129
130 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
131  */
132 typedef std::vector<ConnectClass> ClassVector;
133
134 /** Typedef for the list of user-channel records for a user
135  */
136 typedef std::map<chanrec*, char> UserChanList;
137 typedef UserChanList::iterator UCListIter;
138
139 /** Holds all information about a user
140  * This class stores all information about a user connected to the irc server. Everything about a
141  * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
142  * user's nickname and hostname. Use the FindNick method of the InspIRCd class to locate a specific user
143  * by nickname, or the FindDescriptor method of the InspIRCd class to find a specific user by their
144  * file descriptor value.
145  */
146 class userrec : public connection
147 {
148  private:
149         /** Pointer to creator.
150          * This is required to make use of core functions
151          * from within the userrec class.
152          */
153         InspIRCd* ServerInstance;
154
155         /** A list of channels the user has a pending invite to.
156          * Upon INVITE channels are added, and upon JOIN, the
157          * channels are removed from this list.
158          */
159         InvitedList invites;
160
161         /** Number of channels this user is currently on
162          */
163         unsigned int ChannelCount;
164  public:
165         /** Resolvers for looking up this users IP address
166          * This will occur if and when res_reverse completes.
167          * When this class completes its lookup, userrec::dns_done
168          * will be set from false to true.
169          */
170         UserResolver* res_forward;
171
172         /** Resolvers for looking up this users hostname
173          * This is instantiated by userrec::StartDNSLookup(),
174          * and on success, instantiates userrec::res_reverse.
175          */
176         UserResolver* res_reverse;
177
178         /** Stored reverse lookup from res_forward
179          */
180         std::string stored_host;
181
182         /** Starts a DNS lookup of the user's IP.
183          * This will cause two UserResolver classes to be instantiated.
184          * When complete, these objects set userrec::dns_done to true.
185          */
186         void StartDNSLookup();
187         
188         /** The users nickname.
189          * An invalid nickname indicates an unregistered connection prior to the NICK command.
190          * Use InspIRCd::IsNick() to validate nicknames.
191          */
192         char nick[NICKMAX];
193         
194         /** The users ident reply.
195          * Two characters are added to the user-defined limit to compensate for the tilde etc.
196          */
197         char ident[IDENTMAX+2];
198
199         /** The host displayed to non-opers (used for cloaking etc).
200          * This usually matches the value of userrec::host.
201          */
202         char dhost[65];
203         
204         /** The users full name (GECOS).
205          */
206         char fullname[MAXGECOS+1];
207         
208         /** The user's mode list.
209          * This is NOT a null terminated string! In the 1.1 version of InspIRCd
210          * this is an array of values in a similar way to channel modes.
211          * A value of 1 in field (modeletter-65) indicates that the mode is
212          * set, for example, to work out if mode +s is set, we  check the field
213          * userrec::modes['s'-65] != 0.
214          * The following RFC characters o, w, s, i have constants defined via an
215          * enum, such as UM_SERVERNOTICE and UM_OPETATOR.
216          */
217         char modes[64];
218
219         /** What snomasks are set on this user.
220          * This functions the same as the above modes.
221          */
222         char snomasks[64];
223
224         /** Channels this user is on, and the permissions they have there
225          */
226         UserChanList chans;
227         
228         /** The server the user is connected to.
229          */
230         const char* server;
231         
232         /** The user's away message.
233          * If this string is empty, the user is not marked as away.
234          */
235         char awaymsg[MAXAWAY+1];
236         
237         /** Number of lines the user can place into the buffer
238          * (up to the global NetBufferSize bytes) before they
239          * are disconnected for excess flood
240          */
241         int flood;
242         
243         /** Number of seconds this user is given to send USER/NICK
244          * If they do not send their details in this time limit they
245          * will be disconnected
246          */
247         unsigned int timeout;
248         
249         /** The oper type they logged in as, if they are an oper.
250          * This is used to check permissions in operclasses, so that
251          * we can say 'yay' or 'nay' to any commands they issue.
252          * The value of this is the value of a valid 'type name=' tag.
253          */
254         char oper[NICKMAX];
255
256         /** True when DNS lookups are completed.
257          * The UserResolver classes res_forward and res_reverse will
258          * set this value once they complete.
259          */
260         bool dns_done;
261
262         /** Number of seconds between PINGs for this user (set from &lt;connect:allow&gt; tag
263          */
264         unsigned int pingmax;
265
266         /** Password specified by the user when they registered.
267          * This is stored even if the <connect> block doesnt need a password, so that
268          * modules may check it.
269          */
270         char password[64];
271
272         /** User's receive queue.
273          * Lines from the IRCd awaiting processing are stored here.
274          * Upgraded april 2005, old system a bit hairy.
275          */
276         std::string recvq;
277
278         /** User's send queue.
279          * Lines waiting to be sent are stored here until their buffer is flushed.
280          */
281         std::string sendq;
282
283         /** Flood counters - lines received
284          */
285         int lines_in;
286
287         /** Flood counters - time lines_in is due to be reset
288          */
289         time_t reset_due;
290
291         /** Flood counters - Highest value lines_in may reach before the user gets disconnected
292          */
293         long threshold;
294
295         /** IPV4 or IPV6 ip address
296          */
297         sockaddr* ip;
298
299         /** Initialize the clients sockaddr
300          * @param protocol_family The protocol family of the IP address, AF_INET or AF_INET6
301          * @param ip A human-readable IP address for this user matching the protcol_family
302          * @param port The port number of this user or zero for a remote user
303          */
304         void SetSockAddr(int protocol_family, const char* ip, int port);
305
306         /** Get port number from sockaddr
307          * @return The port number of this user.
308          */
309         int GetPort();
310
311         /** Get protocol family from sockaddr
312          * @return The protocol family of this user, either AF_INET or AF_INET6
313          */
314         int GetProtocolFamily();
315
316         /** Get IP string from sockaddr, using static internal buffer
317          * @return The IP string
318          */
319         const char* GetIPString();
320
321         /** Get IP string from sockaddr, using caller-specified buffer
322          * @param buf A buffer to use
323          * @return The IP string
324          */
325         const char* GetIPString(char* buf);
326
327         /* Write error string
328          */
329         std::string WriteError;
330
331         /** Maximum size this user's sendq can become
332          */
333         long sendqmax;
334
335         /** Maximum size this user's recvq can become
336          */
337         long recvqmax;
338
339         /** This is true if the user matched an exception when they connected to the ircd.
340          * It isnt valid after this point, and you should not attempt to do anything with it
341          * after this point, because the eline might be removed at a later time, and/or no
342          * longer be applicable to this user. It is only used to save doing the eline lookup
343          * twice (instead we do it once and set this value).
344          */
345         bool exempt;
346
347         /** Default constructor
348          * @throw Nothing at present
349          */
350         userrec(InspIRCd* Instance);
351         
352         /** Returns the full displayed host of the user
353          * This member function returns the hostname of the user as seen by other users
354          * on the server, in nick!ident&at;host form.
355          * @return The full masked host of the user
356          */
357         virtual char* GetFullHost();
358         
359         /** Returns the full real host of the user
360          * This member function returns the hostname of the user as seen by other users
361          * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
362          * e.g. through a module, then this method will ignore it and return the true hostname.
363          * @return The full real host of the user
364          */
365         virtual char* GetFullRealHost();
366
367         /** Create a displayable mode string for this users snomasks
368          * @return The notice mask character sequence
369          */
370         const char* FormatNoticeMasks();
371
372         /** Process a snomask modifier string, e.g. +abc-de
373          * @param sm A sequence of notice mask characters
374          * @return The cleaned mode sequence which can be output,
375          * e.g. in the above example if masks c and e are not
376          * valid, this function will return +ab-d
377          */
378         std::string ProcessNoticeMasks(const char *sm);
379
380         /** Returns true if a notice mask is set
381          * @param sm A notice mask character to check
382          * @return True if the notice mask is set
383          */
384         bool IsNoticeMaskSet(unsigned char sm);
385
386         /** Changed a specific notice mask value
387          * @param sm The server notice mask to change
388          * @param value An on/off value for this mask
389          */
390         void SetNoticeMask(unsigned char sm, bool value);
391
392         /** Create a displayable mode string for this users umodes
393          * @param The mode string
394          */
395         const char* FormatModes();
396
397         /** Returns true if a specific mode is set
398          * @param m The user mode
399          * @return True if the mode is set
400          */
401         bool IsModeSet(unsigned char m);
402
403         /** Set a specific usermode to on or off
404          * @param m The user mode
405          * @param value On or off setting of the mode
406          */
407         void SetMode(unsigned char m, bool value);
408         
409         /** Returns true if a user is invited to a channel.
410          * @param channel A channel name to look up
411          * @return True if the user is invited to the given channel
412          */
413         virtual bool IsInvited(const irc::string &channel);
414         
415         /** Adds a channel to a users invite list (invites them to a channel)
416          * @param channel A channel name to add
417          */
418         virtual void InviteTo(const irc::string &channel);
419         
420         /** Removes a channel from a users invite list.
421          * This member function is called on successfully joining an invite only channel
422          * to which the user has previously been invited, to clear the invitation.
423          * @param channel The channel to remove the invite to
424          */
425         virtual void RemoveInvite(const irc::string &channel);
426         
427         /** Returns true or false for if a user can execute a privilaged oper command.
428          * This is done by looking up their oper type from userrec::oper, then referencing
429          * this to their oper classes and checking the commands they can execute.
430          * @param command A command (should be all CAPS)
431          * @return True if this user can execute the command
432          */
433         bool HasPermission(const std::string &command);
434
435         /** Calls read() to read some data for this user using their fd.
436          * @param buffer The buffer to read into
437          * @param size The size of data to read
438          * @return The number of bytes read, or -1 if an error occured.
439          */
440         int ReadData(void* buffer, size_t size);
441
442         /** This method adds data to the read buffer of the user.
443          * The buffer can grow to any size within limits of the available memory,
444          * managed by the size of a std::string, however if any individual line in
445          * the buffer grows over 600 bytes in length (which is 88 chars over the
446          * RFC-specified limit per line) then the method will return false and the
447          * text will not be inserted.
448          * @param a The string to add to the users read buffer
449          * @return True if the string was successfully added to the read buffer
450          */
451         bool AddBuffer(std::string a);
452
453         /** This method returns true if the buffer contains at least one carriage return
454          * character (e.g. one complete line may be read)
455          * @return True if there is at least one complete line in the users buffer
456          */
457         bool BufferIsReady();
458
459         /** This function clears the entire buffer by setting it to an empty string.
460          */
461         void ClearBuffer();
462
463         /** This method returns the first available string at the tail end of the buffer
464          * and advances the tail end of the buffer past the string. This means it is
465          * a one way operation in a similar way to strtok(), and multiple calls return
466          * multiple lines if they are available. The results of this function if there
467          * are no lines to be read are unknown, always use BufferIsReady() to check if
468          * it is ok to read the buffer before calling GetBuffer().
469          * @return The string at the tail end of this users buffer
470          */
471         std::string GetBuffer();
472
473         /** Sets the write error for a connection. This is done because the actual disconnect
474          * of a client may occur at an inopportune time such as half way through /LIST output.
475          * The WriteErrors of clients are checked at a more ideal time (in the mainloop) and
476          * errored clients purged.
477          * @param error The error string to set.
478          */
479         void SetWriteError(const std::string &error);
480
481         /** Returns the write error which last occured on this connection or an empty string
482          * if none occured.
483          * @return The error string which has occured for this user
484          */
485         const char* GetWriteError();
486
487         /** Adds to the user's write buffer.
488          * You may add any amount of text up to this users sendq value, if you exceed the
489          * sendq value, SetWriteError() will be called to set the users error string to
490          * "SendQ exceeded", and further buffer adds will be dropped.
491          * @param data The data to add to the write buffer
492          */
493         void AddWriteBuf(const std::string &data);
494
495         /** Flushes as much of the user's buffer to the file descriptor as possible.
496          * This function may not always flush the entire buffer, rather instead as much of it
497          * as it possibly can. If the send() call fails to send the entire buffer, the buffer
498          * position is advanced forwards and the rest of the data sent at the next call to
499          * this method.
500          */
501         void FlushWriteBuf();
502
503         /** Returns the list of channels this user has been invited to but has not yet joined.
504          * @return A list of channels the user is invited to
505          */
506         InvitedList* GetInviteList();
507
508         /** Creates a wildcard host.
509          * Takes a buffer to use and fills the given buffer with the host in the format *!*@hostname
510          * @return The wildcarded hostname in *!*@host form
511          */
512         char* MakeWildHost();
513
514         /** Creates a usermask with real host.
515          * Takes a buffer to use and fills the given buffer with the hostmask in the format user@host
516          * @return the usermask in the format user@host
517          */
518         char* MakeHost();
519
520         /** Creates a usermask with real ip.
521          * Takes a buffer to use and fills the given buffer with the ipmask in the format user@ip
522          * @return the usermask in the format user@ip
523          */
524         char* MakeHostIP();
525
526         /** Shuts down and closes the user's socket
527          * This will not cause the user to be deleted. Use InspIRCd::QuitUser for this,
528          * which will call CloseSocket() for you.
529          */
530         void CloseSocket();
531
532         /** Disconnect a user gracefully
533          * @param user The user to remove
534          * @param r The quit reason
535          * @return Although this function has no return type, on exit the user provided will no longer exist.
536          */
537         static void QuitUser(InspIRCd* Instance, userrec *user, const std::string &r);
538
539         /** Add the user to WHOWAS system
540          */
541         void AddToWhoWas();
542
543         /** Oper up the user using the given opertype.
544          * This will also give the +o usermode.
545          * @param opertype The oper type to oper as
546          */
547         void Oper(const std::string &opertype);
548
549         /** Use this method to fully connect a user.
550          * This will send the message of the day, check G/K/E lines, etc.
551          * @param Goners If the user is disconnected by this method call, the
552          * value of 'this' will be pushed onto this CullList. This is used by
553          * the core to connect many users in rapid succession without invalidating
554          * iterators.
555          * @param Goners a CullList to use for failed connections
556          */
557         void FullConnect(CullList* Goners);
558
559         /** Change this users hash key to a new string.
560          * You should not call this function directly. It is used by the core
561          * to update the users hash entry on a nickchange.
562          * @param New new user_hash key
563          * @return Pointer to userrec in hash (usually 'this')
564          */
565         userrec* UpdateNickHash(const char* New);
566
567         /** Force a nickname change.
568          * If the nickname change fails (for example, because the nick in question
569          * already exists) this function will return false, and you must then either
570          * output an error message, or quit the user for nickname collision.
571          * @param newnick The nickname to change to
572          * @return True if the nickchange was successful.
573          */
574         bool ForceNickChange(const char* newnick);
575
576         /** Add a client to the system.
577          * This will create a new userrec, insert it into the user_hash,
578          * initialize it as not yet registered, and add it to the socket engine.
579          * @param Instance a pointer to the server instance
580          * @param socket The socket id (file descriptor) this user is on
581          * @param port The port number this user connected on
582          * @param iscached This variable is reserved for future use
583          * @param ip The IP address of the user
584          * @return This function has no return value, but a call to AddClient may remove the user.
585          */
586         static void AddClient(InspIRCd* Instance, int socket, int port, bool iscached, insp_inaddr ip);
587
588         /** Oper down.
589          * This will clear the +o usermode and unset the user's oper type
590          */
591         void UnOper();
592
593         /** Return the number of global clones of this user
594          * @return The global clone count of this user
595          */
596         long GlobalCloneCount();
597
598         /** Return the number of local clones of this user
599          * @return The local clone count of this user
600          */
601         long LocalCloneCount();
602
603         /** Write text to this user, appending CR/LF.
604          * @param text A std::string to send to the user
605          */
606         void Write(std::string text);
607
608         /** Write text to this user, appending CR/LF.
609          * @param text The format string for text to send to the user
610          * @param ... POD-type format arguments
611          */
612         void Write(const char *text, ...);
613
614         /** Write text to this user, appending CR/LF and prepending :server.name
615          * @param text A std::string to send to the user
616          */
617         void WriteServ(const std::string& text);
618
619         /** Write text to this user, appending CR/LF and prepending :server.name
620          * @param text The format string for text to send to the user
621          * @param ... POD-type format arguments
622          */
623         void WriteServ(const char* text, ...);
624
625         /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
626          * @param user The user to prepend the :nick!user@host of
627          * @param text A std::string to send to the user
628          */
629         void WriteFrom(userrec *user, const std::string &text);
630
631         /** Write text to this user, appending CR/LF and prepending :nick!user@host of the user provided in the first parameter.
632          * @param user The user to prepend the :nick!user@host of
633          * @param text The format string for text to send to the user
634          * @param ... POD-type format arguments
635          */
636         void WriteFrom(userrec *user, const char* text, ...);
637
638         /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
639          * @param dest The user to route the message to
640          * @param text A std::string to send to the user
641          */
642         void WriteTo(userrec *dest, const std::string &data);
643
644         /** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
645          * @param dest The user to route the message to
646          * @param text The format string for text to send to the user
647          * @param ... POD-type format arguments
648          */
649         void WriteTo(userrec *dest, const char *data, ...);
650
651         /** Write to all users that can see this user (including this user in the list), appending CR/LF
652          * @param text A std::string to send to the users
653          */
654         void WriteCommon(const std::string &text);
655
656         /** Write to all users that can see this user (including this user in the list), appending CR/LF
657          * @param text The format string for text to send to the users
658          * @param ... POD-type format arguments
659          */
660         void WriteCommon(const char* text, ...);
661
662         /** Write to all users that can see this user (not including this user in the list), appending CR/LF
663          * @param text The format string for text to send to the users
664          * @param ... POD-type format arguments
665          */
666         void WriteCommonExcept(const char* text, ...);
667
668         /** Write to all users that can see this user (not including this user in the list), appending CR/LF
669          * @param text A std::string to send to the users
670          */
671         void WriteCommonExcept(const std::string &text);
672
673         /** Write a WALLOPS message from this user to all local opers.
674          * If this user is not opered, the function will return without doing anything.
675          * @param text The format string to send in the WALLOPS message
676          * @param ... Format arguments
677          */
678         void WriteWallOps(const char* text, ...);
679
680         /** Write a WALLOPS message from this user to all local opers.
681          * If this user is not opered, the function will return without doing anything.
682          * @param text The text to send in the WALLOPS message
683          */
684         void WriteWallOps(const std::string &text);
685
686         /** Return true if the user shares at least one channel with another user
687          * @param other The other user to compare the channel list against
688          * @return True if the given user shares at least one channel with this user
689          */
690         bool SharesChannelWith(userrec *other);
691
692         /** Change the displayed host of a user.
693          * ALWAYS use this function, rather than writing userrec::dhost directly,
694          * as this triggers module events allowing the change to be syncronized to
695          * remote servers. This will also emulate a QUIT and rejoin (where configured)
696          * before setting their host field.
697          * @param host The new hostname to set
698          * @return True if the change succeeded, false if it didn't
699          */
700         bool ChangeDisplayedHost(const char* host);
701
702         /** Change the ident (username) of a user.
703          * ALWAYS use this function, rather than writing userrec::ident directly,
704          * as this correctly causes the user to seem to quit (where configured)
705          * before setting their ident field.
706          * @param host The new ident to set
707          * @return True if the change succeeded, false if it didn't
708          */
709         bool ChangeIdent(const char* newident);
710
711         /** Change a users realname field.
712          * ALWAYS use this function, rather than writing userrec::fullname directly,
713          * as this triggers module events allowing the change to be syncronized to
714          * remote servers.
715          * @param gecos The user's new realname
716          * @return True if the change succeeded, false if otherwise
717          */
718         bool ChangeName(const char* gecos);
719
720         /** Send a notice to all local users from this user
721          * @param text The text format string to send
722          * @param ... Format arguments
723          */
724         void NoticeAll(char* text, ...);
725
726         /** Compile a channel list for this user, and send it to the user 'source'
727          * Used internally by WHOIS
728          * @param The user to send the channel list to if it is not too long
729          * @return This user's channel list
730          */
731         std::string ChannelList(userrec* source);
732
733         /** Split the channel list in cl which came from dest, and spool it to this user
734          * Used internally by WHOIS
735          * @param dest The user the original channel list came from
736          * @param cl The  channel list as a string obtained from userrec::ChannelList()
737          */
738         void SplitChanList(userrec* dest, const std::string &cl);
739
740         /** Remove this user from all channels they are on, and delete any that are now empty.
741          * This is used by QUIT, and will not send part messages!
742          */
743         void PurgeEmptyChannels();
744
745         /** Get the connect class which matches this user's host or IP address
746          * @return A reference to this user's connect class
747          */
748         ConnectClass& GetClass();
749
750         /** Show the message of the day to this user
751          */
752         void ShowMOTD();
753
754         /** Show the server RULES file to this user
755          */
756         void ShowRULES();
757
758         /** Handle socket event.
759          * From EventHandler class.
760          */
761         void HandleEvent(EventType et, int errornum = 0);
762
763         /** Default destructor
764          */
765         virtual ~userrec();
766 };
767
768
769 namespace irc
770 {
771         /** Holds whowas related functions and classes
772          */
773         namespace whowas
774         {
775
776                 /** Used to hold WHOWAS information
777                  */
778                 class WhoWasGroup : public classbase
779                 {
780                  public:
781                         /** Real host
782                          */
783                         char* host;
784                         /** Displayed host
785                          */
786                         char* dhost;
787                         /** Ident
788                          */
789                         char* ident;
790                         /** Server name
791                          */
792                         const char* server;
793                         /** Fullname (GECOS)
794                          */
795                         char* gecos;
796                         /** Signon time
797                          */
798                         time_t signon;
799         
800                         /** Initialize this WhoQasFroup with a user
801                          */
802                         WhoWasGroup(userrec* user);
803                         /** Destructor
804                          */
805                         ~WhoWasGroup();
806                 };
807
808                 /** A group of users related by nickname
809                  */
810                 typedef std::deque<WhoWasGroup*> whowas_set;
811
812                 /** Sets of users in the whowas system
813                  */
814                 typedef std::map<irc::string,whowas_set*> whowas_users;
815
816                 /** Sets of time and users in whowas list
817                  */
818                 typedef std::map<time_t,irc::string> whowas_users_fifo;
819
820                 /** Called every hour by the core to remove expired entries
821                  */
822                 void MaintainWhoWas(InspIRCd* ServerInstance, time_t TIME);
823
824                 /** Prune for WhoWasGroupSize, WhoWasMaxGroups and
825                  *  WhoWasMaxKeep on rehash
826                  */
827                 void PruneWhoWas(InspIRCd* ServerInstance, time_t TIME);
828         };
829 };
830
831 /* Configuration callbacks */
832 class ServerConfig;
833
834 #endif