]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/users.h
Updated buffering, faster and more sensible (old code sucks)
[user/henk/code/inspircd.git] / include / users.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "inspircd_config.h" 
18 #include "channels.h"
19 #include "connection.h"
20 #include "inspstring.h"
21 #include <string>
22  
23 #ifndef __USERS_H__ 
24 #define __USERS_H__ 
25  
26 #define STATUS_OP       4
27 #define STATUS_HOP      2
28 #define STATUS_VOICE    1
29 #define STATUS_NORMAL   0
30
31 #define CC_ALLOW        0
32 #define CC_DENY         1
33
34 /** Holds a channel name to which a user has been invited.
35  */
36 class Invited : public classbase
37 {
38  public:
39         char channel[CHANMAX];
40 };
41
42
43 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
44  */
45 class ConnectClass : public classbase
46 {
47  public:
48         /** Type of line, either CC_ALLOW or CC_DENY
49          */
50         int type;
51         /** Max time to register the connection in seconds
52          */
53         int registration_timeout;
54         /** Number of lines in buffer before excess flood is triggered
55          */
56         int flood;
57         /** Host mask for this line
58          */
59         char host[MAXBUF];
60         /** Number of seconds between pings for this line
61          */
62         int pingtime;
63         /** (Optional) Password for this line
64          */
65         char pass[MAXBUF];
66         
67         ConnectClass()
68         {
69                 registration_timeout = 0;
70                 flood = 0;
71                 pingtime = 0;
72                 strlcpy(host,"",MAXBUF);
73                 strlcpy(pass,"",MAXBUF);
74         }
75 };
76
77 /** Holds a complete list of all channels to which a user has been invited and has not yet joined.
78  */
79 typedef std::vector<Invited> InvitedList;
80
81
82
83 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
84  */
85 typedef std::vector<ConnectClass> ClassVector;
86
87 /** Holds all information about a user
88  * This class stores all information about a user connected to the irc server. Everything about a
89  * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
90  * user's nickname and hostname. Use the Find method of the server class to locate a specific user
91  * by nickname.
92  */
93 class userrec : public connection
94 {
95  private:
96
97         /** A list of channels the user has a pending invite to.
98          */
99         InvitedList invites;
100  public:
101         
102         /** The users nickname.
103          * An invalid nickname indicates an unregistered connection prior to the NICK command.
104          */
105         
106         char nick[NICKMAX];
107         
108         /** The users ident reply.
109          */
110         char ident[64];
111
112         /** The host displayed to non-opers (used for cloaking etc).
113          * This usually matches the value of userrec::host.
114          */
115         char dhost[256];
116         
117         /** The users full name.
118          */
119         char fullname[128];
120         
121         /** The user's mode string.
122          * This may contain any of the following RFC characters: o, w, s, i
123          * Your module may define other mode characters as it sees fit.
124          */
125         char modes[MAXBUF];
126         
127         ucrec chans[MAXCHANS];
128         
129         /** The server the user is connected to.
130          */
131         char server[256];
132         
133         /** The user's away message.
134          * If this string is empty, the user is not marked as away.
135          */
136         char awaymsg[512];
137         
138         /** Stores the result of the last GetFullHost or GetRealHost call.
139          * You may use this to increase the speed of use of this class.
140          */
141         char result[256];
142         
143         /** Number of lines the user can place into the buffer
144          * (up to the global NetBufferSize bytes) before they
145          * are disconnected for excess flood
146          */
147         int flood;
148         
149         /** Number of seconds this user is given to send USER/NICK
150          * If they do not send their details in this time limit they
151          * will be disconnected
152          */
153         unsigned long timeout;
154         
155         /** The oper type they logged in as, if they are an oper.
156          * This is used to check permissions in operclasses, so that
157          * we can say 'yay' or 'nay' to any commands they issue.
158          * The value of this is the value of a valid 'type name=' tag.
159          */
160         char oper[NICKMAX];
161
162         /** True when DNS lookups are completed.
163          */
164         bool dns_done;
165
166         /** Number of seconds between PINGs for this user (set from &lt;connect:allow&gt; tag
167          */
168         unsigned long pingmax;
169
170         /** Password specified by the user when they registered.
171          * This is stored even if the <connect> block doesnt need a password, so that
172          * modules may check it.
173          */
174         char password[MAXBUF];
175
176         /** User's receive queue.
177          * Lines from the IRCd awaiting processing are stored here.
178          * Upgraded april 2005, old system a bit hairy.
179          */
180         std::string recvq;
181
182         userrec();
183         
184         virtual ~userrec() {  }
185         
186         /** Returns the full displayed host of the user
187          * This member function returns the hostname of the user as seen by other users
188          * on the server, in nick!ident&at;host form.
189          */
190         virtual char* GetFullHost();
191         
192         /** Returns the full real host of the user
193          * This member function returns the hostname of the user as seen by other users
194          * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
195          * e.g. through a module, then this method will ignore it and return the true hostname.
196          */
197         virtual char* GetFullRealHost();
198         
199         /** Returns true if a user is invited to a channel.
200          */
201         virtual bool IsInvited(char* channel);
202         
203         /** Adds a channel to a users invite list (invites them to a channel)
204          */
205         virtual void InviteTo(char* channel);
206         
207         /** Removes a channel from a users invite list.
208          * This member function is called on successfully joining an invite only channel
209          * to which the user has previously been invited, to clear the invitation.
210          */
211         virtual void RemoveInvite(char* channel);
212         
213         /** Returns true or false for if a user can execute a privilaged oper command.
214          * This is done by looking up their oper type from userrec::oper, then referencing
215          * this to their oper classes and checking the commands they can execute.
216          */
217         bool HasPermission(char* command);
218
219         void userrec::AddBuffer(std::string a);
220         bool userrec::BufferIsReady();
221         void userrec::ClearBuffer();
222         std::string userrec::GetBuffer();
223         
224 };
225
226
227 #endif