1 .TH "userrec" 3 "7 May 2005" "InspIRCd" \" -*- nroff -*-
5 userrec \- Holds all information about a user This class stores all information about a user connected to the irc server.
11 \fC#include <users.h>\fP
13 Inherits \fBconnection\fP.
15 .SS "Public Member Functions"
19 .RI "\fBuserrec\fP ()"
22 .RI "virtual \fB~userrec\fP ()"
25 .RI "virtual char * \fBGetFullHost\fP ()"
27 .RI "\fIReturns the full displayed host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. \fP"
29 .RI "virtual char * \fBGetFullRealHost\fP ()"
31 .RI "\fIReturns the full real host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. \fP"
33 .RI "virtual bool \fBIsInvited\fP (char *channel)"
35 .RI "\fIReturns true if a user is invited to a channel. \fP"
37 .RI "virtual void \fBInviteTo\fP (char *channel)"
39 .RI "\fIAdds a channel to a users invite list (invites them to a channel). \fP"
41 .RI "virtual void \fBRemoveInvite\fP (char *channel)"
43 .RI "\fIRemoves a channel from a users invite list. \fP"
45 .RI "bool \fBHasPermission\fP (char *command)"
47 .RI "\fIReturns true or false for if a user can execute a privilaged oper command. \fP"
49 .RI "bool \fBAddBuffer\fP (std::string a)"
51 .RI "\fIThis method adds data to the buffer of the user. \fP"
53 .RI "bool \fBBufferIsReady\fP ()"
55 .RI "\fIThis method returns true if the buffer contains at least one carriage return character (e.g. \fP"
57 .RI "void \fBClearBuffer\fP ()"
59 .RI "\fIThis function clears the entire buffer by setting it to an empty string. \fP"
61 .RI "std::string \fBGetBuffer\fP ()"
63 .RI "\fIThis method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. \fP"
65 .SS "Public Attributes"
69 .RI "char \fBnick\fP [NICKMAX]"
71 .RI "\fIThe users nickname. \fP"
73 .RI "char \fBident\fP [64]"
75 .RI "\fIThe users ident reply. \fP"
77 .RI "char \fBdhost\fP [256]"
79 .RI "\fIThe host displayed to non-opers (used for cloaking etc). \fP"
81 .RI "char \fBfullname\fP [128]"
83 .RI "\fIThe users full name. \fP"
85 .RI "char \fBmodes\fP [MAXBUF]"
87 .RI "\fIThe user's mode string. \fP"
89 .RI "\fBucrec\fP \fBchans\fP [MAXCHANS]"
92 .RI "char \fBserver\fP [256]"
94 .RI "\fIThe server the user is connected to. \fP"
96 .RI "char \fBawaymsg\fP [512]"
98 .RI "\fIThe user's away message. \fP"
100 .RI "char \fBresult\fP [256]"
102 .RI "\fIStores the result of the last GetFullHost or GetRealHost call. \fP"
104 .RI "int \fBflood\fP"
106 .RI "\fINumber of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. \fP"
108 .RI "unsigned long \fBtimeout\fP"
110 .RI "\fINumber of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. \fP"
112 .RI "char \fBoper\fP [NICKMAX]"
114 .RI "\fIThe oper type they logged in as, if they are an oper. \fP"
116 .RI "bool \fBdns_done\fP"
118 .RI "\fITrue when \fBDNS\fP lookups are completed. \fP"
120 .RI "unsigned long \fBpingmax\fP"
122 .RI "\fINumber of seconds between PINGs for this user (set from <connect:allow> tag. \fP"
124 .RI "char \fBpassword\fP [MAXBUF]"
126 .RI "\fIPassword specified by the user when they registered. \fP"
128 .RI "std::string \fBrecvq\fP"
130 .RI "\fIUser's receive queue. \fP"
132 .RI "long \fBlines_in\fP"
134 .RI "\fIFlood counters. \fP"
136 .RI "time_t \fBreset_due\fP"
139 .RI "long \fBthreshold\fP"
142 .SS "Private Attributes"
146 .RI "\fBInvitedList\fP \fBinvites\fP"
148 .RI "\fIA list of channels the user has a pending invite to. \fP"
150 .SH "Detailed Description"
152 Holds all information about a user This class stores all information about a user connected to the irc server.
154 Everything about a connection is stored here primarily, from the user's socket ID (file descriptor) through to the user's nickname and hostname. Use the Find method of the server class to locate a specific user by nickname.
156 Definition at line 98 of file users.h.
157 .SH "Constructor & Destructor Documentation"
159 .SS "userrec::userrec ()"
161 Definition at line 28 of file users.cpp.
163 References awaymsg, connection::bytes_in, connection::bytes_out, ucrec::channel, chans, connection::cmds_in, connection::cmds_out, dhost, dns_done, connection::fd, flood, fullname, connection::haspassed, connection::host, ident, connection::idle_lastmsg, connection::inbuf, invites, connection::ip, connection::lastping, lines_in, modes, nick, connection::nping, oper, connection::port, recvq, connection::registered, reset_due, result, server, connection::signon, TIME, timeout, and ucrec::uc_modes.
167 30 // the PROPER way to do it, AVOID bzero at *ALL* costs
169 32 strcpy(ip,'127.0.0.1');
174 37 strcpy(fullname,'');
177 40 strcpy(server,'');
178 41 strcpy(awaymsg,'');
182 45 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
183 46 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
184 47 haspassed = false;
187 50 strcpy(result,'');
188 51 for (int i = 0; i < MAXCHANS; i++)
190 53 this->chans[i].channel = NULL;
191 54 this->chans[i].uc_modes = 0;
196 .SS "virtual userrec::~\fBuserrec\fP ()\fC [inline, virtual]\fP"
198 Definition at line 195 of file users.h.
203 .SH "Member Function Documentation"
205 .SS "bool userrec::AddBuffer (std::string a)"
207 This method adds data to the buffer of the user. The buffer can grow to any size within limits of the available memory, managed by the size of a std::string, however if any individual line in the buffer grows over 600 bytes in length (which is 88 chars over the RFC-specified limit per line) then the method will return false and the text will not be inserted.Definition at line 169 of file users.cpp.
213 171 std::string b = '';
214 172 for (int i = 0; i < a.length(); i++)
215 173 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7))
217 175 std::stringstream stream(recvq);
219 177 recvq = stream.str();
221 179 // count the size of the first line in the buffer.
222 180 while (i < recvq.length())
224 182 if (recvq[i++] == '\n')
227 185 // return false if we've had more than 600 characters WITHOUT
228 186 // a carriage return (this is BAD, drop the socket)
229 187 return (i < 600);
232 .SS "bool userrec::BufferIsReady ()"
234 This method returns true if the buffer contains at least one carriage return character (e.g. one complete line may be read)Definition at line 190 of file users.cpp.
240 192 for (int i = 0; i < recvq.length(); i++)
241 193 if (recvq[i] == '\n')
246 .SS "void userrec::ClearBuffer ()"
248 This function clears the entire buffer by setting it to an empty string. Definition at line 198 of file users.cpp.
252 Referenced by Server::PseudoToUser(), and Server::UserToPseudo().
259 .SS "std::string userrec::GetBuffer ()"
261 This method returns the first available string at the tail end of the buffer and advances the tail end of the buffer past the string. This means it is a one way operation in a similar way to strtok(), and multiple calls return multiple lines if they are available. The results of this function if there are no lines to be read are unknown, always use \fBBufferIsReady()\fP to check if it is ok to read the buffer before calling \fBGetBuffer()\fP.Definition at line 203 of file users.cpp.
269 207 char* line = (char*)recvq.c_str();
270 208 std::string ret = '';
271 209 while ((*line != '\n') && (strlen(line)))
273 211 ret = ret + *line;
276 214 if ((*line == '\n') || (*line == '\r'))
282 .SS "char * userrec::GetFullHost ()\fC [virtual]\fP"
284 Returns the full displayed host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. Definition at line 61 of file users.cpp.
286 References dhost, ident, nick, and result.
290 63 snprintf(result,MAXBUF,'%s!%s@%s',nick,ident,dhost);
294 .SS "char * userrec::GetFullRealHost ()\fC [virtual]\fP"
296 Returns the full real host of the user This member function returns the hostname of the user as seen by other users on the server, in nick!identhost form. If any form of hostname cloaking is in operation, e.g. through a module, then this method will ignore it and return the true hostname.Definition at line 68 of file users.cpp.
298 References connection::host, ident, nick, and result.
302 70 snprintf(result,MAXBUF,'%s!%s@%s',nick,ident,host);
306 .SS "bool userrec::HasPermission (char * command)"
308 Returns true or false for if a user can execute a privilaged oper command. This is done by looking up their oper type from \fBuserrec::oper\fP, then referencing this to their oper classes and checking the commands they can execute.Definition at line 117 of file users.cpp.
310 References config_f, and DEBUG.
314 119 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
319 124 // are they even an oper at all?
320 125 if (strchr(this->modes,'o'))
322 127 log(DEBUG,'*** HasPermission: %s is an oper',this->nick);
323 128 for (int j =0; j < ConfValueEnum('type',&config_f); j++)
325 130 ConfValue('type','name',j,TypeName,&config_f);
326 131 if (!strcmp(TypeName,this->oper))
328 133 log(DEBUG,'*** HasPermission: %s is an oper of type '%s'',this->nick,this->oper);
329 134 ConfValue('type','classes',j,Classes,&config_f);
330 135 char* myclass = strtok_r(Classes,' ',&savept);
333 138 log(DEBUG,'*** HasPermission: checking classtype '%s'',myclass);
334 139 for (int k =0; k < ConfValueEnum('class',&config_f); k++)
336 141 ConfValue('class','name',k,ClassName,&config_f);
337 142 if (!strcmp(ClassName,myclass))
339 144 ConfValue('class','commands',k,CommandList,&config_f);
340 145 log(DEBUG,'*** HasPermission: found class named %s with commands: '%s'',ClassName,CommandList);
343 148 mycmd = strtok_r(CommandList,' ',&savept2);
346 151 if (!strcasecmp(mycmd,command))
348 153 log(DEBUG,'*** Command %s found, returning true',command);
351 156 mycmd = strtok_r(NULL,' ',&savept2);
355 160 myclass = strtok_r(NULL,' ',&savept);
363 .SS "void userrec::InviteTo (char * channel)\fC [virtual]\fP"
365 Adds a channel to a users invite list (invites them to a channel). Definition at line 88 of file users.cpp.
367 References Invited::channel, and invites.
372 91 strlcpy(i.channel,channel,CHANMAX);
373 92 invites.push_back(i);
376 .SS "bool userrec::IsInvited (char * channel)\fC [virtual]\fP"
378 Returns true if a user is invited to a channel. Definition at line 74 of file users.cpp.
384 76 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
387 79 if (!strcasecmp(i->channel,channel))
396 .SS "void userrec::RemoveInvite (char * channel)\fC [virtual]\fP"
398 Removes a channel from a users invite list. This member function is called on successfully joining an invite only channel to which the user has previously been invited, to clear the invitation.Definition at line 95 of file users.cpp.
400 References DEBUG, and invites.
404 97 log(DEBUG,'Removing invites');
407 100 if (invites.size())
409 102 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
413 106 if (!strcasecmp(i->channel,channel))
415 108 invites.erase(i);
424 .SH "Member Data Documentation"
426 .SS "char \fBuserrec::awaymsg\fP[512]"
428 The user's away message. If this string is empty, the user is not marked as away.Definition at line 141 of file users.h.
430 Referenced by userrec().
431 .SS "\fBucrec\fP \fBuserrec::chans\fP[MAXCHANS]"
433 Definition at line 132 of file users.h.
435 Referenced by Server::PseudoToUser(), and userrec().
436 .SS "char \fBuserrec::dhost\fP[256]"
438 The host displayed to non-opers (used for cloaking etc). This usually matches the value of \fBuserrec::host\fP.Definition at line 120 of file users.h.
440 Referenced by GetFullHost(), and userrec().
441 .SS "bool \fBuserrec::dns_done\fP"
443 True when \fBDNS\fP lookups are completed. Definition at line 169 of file users.h.
445 Referenced by userrec().
446 .SS "int \fBuserrec::flood\fP"
448 Number of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. Definition at line 152 of file users.h.
450 Referenced by userrec().
451 .SS "char \fBuserrec::fullname\fP[128]"
453 The users full name. Definition at line 124 of file users.h.
455 Referenced by userrec().
456 .SS "char \fBuserrec::ident\fP[64]"
458 The users ident reply. Definition at line 115 of file users.h.
460 Referenced by GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), userrec(), and Server::UserToPseudo().
461 .SS "\fBInvitedList\fP \fBuserrec::invites\fP\fC [private]\fP"
463 A list of channels the user has a pending invite to. Definition at line 104 of file users.h.
465 Referenced by InviteTo(), IsInvited(), RemoveInvite(), and userrec().
466 .SS "long \fBuserrec::lines_in\fP"
468 Flood counters. Definition at line 189 of file users.h.
470 Referenced by userrec().
471 .SS "char \fBuserrec::modes\fP[MAXBUF]"
473 The user's mode string. This may contain any of the following RFC characters: o, w, s, i Your module may define other mode characters as it sees fit.Definition at line 130 of file users.h.
475 Referenced by userrec().
476 .SS "char \fBuserrec::nick\fP[NICKMAX]"
478 The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command.Definition at line 111 of file users.h.
480 Referenced by ConfigReader::DumpErrors(), GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), and userrec().
481 .SS "char \fBuserrec::oper\fP[NICKMAX]"
483 The oper type they logged in as, if they are an oper. This is used to check permissions in operclasses, so that we can say 'yay' or 'nay' to any commands they issue. The value of this is the value of a valid 'type name=' tag.Definition at line 165 of file users.h.
485 Referenced by userrec().
486 .SS "char \fBuserrec::password\fP[MAXBUF]"
488 Password specified by the user when they registered. This is stored even if the block doesnt need a password, so that modules may check it.Definition at line 179 of file users.h.
489 .SS "unsigned long \fBuserrec::pingmax\fP"
491 Number of seconds between PINGs for this user (set from <connect:allow> tag. Definition at line 173 of file users.h.
492 .SS "std::string \fBuserrec::recvq\fP"
494 User's receive queue. Lines from the IRCd awaiting processing are stored here. Upgraded april 2005, old system a bit hairy.Definition at line 185 of file users.h.
496 Referenced by AddBuffer(), BufferIsReady(), ClearBuffer(), GetBuffer(), and userrec().
497 .SS "time_t \fBuserrec::reset_due\fP"
499 Definition at line 190 of file users.h.
501 Referenced by userrec().
502 .SS "char \fBuserrec::result\fP[256]"
504 Stores the result of the last GetFullHost or GetRealHost call. You may use this to increase the speed of use of this class.Definition at line 146 of file users.h.
506 Referenced by GetFullHost(), GetFullRealHost(), and userrec().
507 .SS "char \fBuserrec::server\fP[256]"
509 The server the user is connected to. Definition at line 136 of file users.h.
511 Referenced by userrec().
512 .SS "long \fBuserrec::threshold\fP"
514 Definition at line 191 of file users.h.
515 .SS "unsigned long \fBuserrec::timeout\fP"
517 Number of seconds this user is given to send USER/NICK If they do not send their details in this time limit they will be disconnected. Definition at line 158 of file users.h.
519 Referenced by userrec().
523 Generated automatically by Doxygen for InspIRCd from the source code.