1 .TH "userrec" 3 "12 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 .RI "void \fBSetWriteError\fP (std::string error)"
67 .RI "\fISets the write error for a connection. \fP"
69 .RI "std::string \fBGetWriteError\fP ()"
71 .RI "\fIReturns the write error which last occured on this connection or an empty string if none occured. \fP"
73 .RI "void \fBAddWriteBuf\fP (std::string data)"
75 .RI "\fIAdds to the user's write buffer. \fP"
77 .RI "void \fBFlushWriteBuf\fP ()"
79 .RI "\fIFlushes as much of the user's buffer to the file descriptor as possible. \fP"
81 .SS "Public Attributes"
85 .RI "char \fBnick\fP [NICKMAX]"
87 .RI "\fIThe users nickname. \fP"
89 .RI "char \fBident\fP [64]"
91 .RI "\fIThe users ident reply. \fP"
93 .RI "char \fBdhost\fP [256]"
95 .RI "\fIThe host displayed to non-opers (used for cloaking etc). \fP"
97 .RI "char \fBfullname\fP [128]"
99 .RI "\fIThe users full name. \fP"
101 .RI "char \fBmodes\fP [MAXBUF]"
103 .RI "\fIThe user's mode string. \fP"
105 .RI "\fBucrec\fP \fBchans\fP [MAXCHANS]"
108 .RI "char \fBserver\fP [256]"
110 .RI "\fIThe server the user is connected to. \fP"
112 .RI "char \fBawaymsg\fP [512]"
114 .RI "\fIThe user's away message. \fP"
116 .RI "char \fBresult\fP [256]"
118 .RI "\fIStores the result of the last GetFullHost or GetRealHost call. \fP"
120 .RI "int \fBflood\fP"
122 .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"
124 .RI "unsigned long \fBtimeout\fP"
126 .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"
128 .RI "char \fBoper\fP [NICKMAX]"
130 .RI "\fIThe oper type they logged in as, if they are an oper. \fP"
132 .RI "bool \fBdns_done\fP"
134 .RI "\fITrue when \fBDNS\fP lookups are completed. \fP"
136 .RI "unsigned long \fBpingmax\fP"
138 .RI "\fINumber of seconds between PINGs for this user (set from <connect:allow> tag. \fP"
140 .RI "char \fBpassword\fP [MAXBUF]"
142 .RI "\fIPassword specified by the user when they registered. \fP"
144 .RI "std::string \fBrecvq\fP"
146 .RI "\fIUser's receive queue. \fP"
148 .RI "std::string \fBsendq\fP"
150 .RI "\fIUser's send queue. \fP"
152 .RI "long \fBlines_in\fP"
154 .RI "\fIFlood counters. \fP"
156 .RI "time_t \fBreset_due\fP"
159 .RI "long \fBthreshold\fP"
162 .RI "std::string \fBWriteError\fP"
165 .RI "long \fBsendqmax\fP"
167 .RI "\fIMaximum size this user's sendq can become. \fP"
169 .RI "long \fBrecvqmax\fP"
171 .RI "\fIMaximum size this user's recvq can become. \fP"
173 .SS "Private Attributes"
177 .RI "\fBInvitedList\fP \fBinvites\fP"
179 .RI "\fIA list of channels the user has a pending invite to. \fP"
181 .SH "Detailed Description"
183 Holds all information about a user This class stores all information about a user connected to the irc server.
185 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.
187 Definition at line 108 of file users.h.
188 .SH "Constructor & Destructor Documentation"
190 .SS "userrec::userrec ()"
192 Definition at line 28 of file users.cpp.
194 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, sendq, server, connection::signon, TIME, timeout, and ucrec::uc_modes.
198 30 // the PROPER way to do it, AVOID bzero at *ALL* costs
200 32 strcpy(ip,'127.0.0.1');
205 37 strcpy(fullname,'');
208 40 strcpy(server,'');
209 41 strcpy(awaymsg,'');
213 45 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
214 46 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
215 47 haspassed = false;
219 51 strcpy(result,'');
220 52 for (int i = 0; i < MAXCHANS; i++)
222 54 this->chans[i].channel = NULL;
223 55 this->chans[i].uc_modes = 0;
228 .SS "virtual userrec::~\fBuserrec\fP ()\fC [inline, virtual]\fP"
230 Definition at line 222 of file users.h.
235 .SH "Member Function Documentation"
237 .SS "bool userrec::AddBuffer (std::string a)"
239 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 170 of file users.cpp.
241 References recvq, recvqmax, and SetWriteError().
245 172 std::string b = '';
246 173 for (int i = 0; i < a.length(); i++)
247 174 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7))
249 176 std::stringstream stream(recvq);
251 178 recvq = stream.str();
253 180 // count the size of the first line in the buffer.
254 181 while (i < recvq.length())
256 183 if (recvq[i++] == '\n')
259 186 if (recvq.length() > this->recvqmax)
261 188 this->SetWriteError('RecvQ exceeded');
262 189 WriteOpers('*** User %s RecvQ of %d exceeds connect class maximum of %d',this->nick,recvq.length(),this->recvqmax);
264 191 // return false if we've had more than 600 characters WITHOUT
265 192 // a carriage return (this is BAD, drop the socket)
266 193 return (i < 600);
269 .SS "void userrec::AddWriteBuf (std::string data)"
271 Adds to the user's write buffer. You may add any amount of text up to this users sendq value, if you exceed the sendq value, \fBSetWriteError()\fP will be called to set the users error string to 'SendQ exceeded', and further buffer adds will be dropped.Definition at line 226 of file users.cpp.
273 References GetWriteError(), sendq, sendqmax, and SetWriteError().
277 228 if (this->GetWriteError() != '')
279 230 if (sendq.length() + data.length() > this->sendqmax)
281 232 WriteOpers('*** User %s SendQ of %d exceeds connect class maximum of %d',this->nick,sendq.length() + data.length(),this->sendqmax);
282 233 this->SetWriteError('SendQ exceeded');
285 236 std::stringstream stream;
286 237 stream << sendq << data;
287 238 sendq = stream.str();
290 .SS "bool userrec::BufferIsReady ()"
292 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 196 of file users.cpp.
298 198 for (int i = 0; i < recvq.length(); i++)
299 199 if (recvq[i] == '\n')
304 .SS "void userrec::ClearBuffer ()"
306 This function clears the entire buffer by setting it to an empty string. Definition at line 204 of file users.cpp.
310 Referenced by Server::PseudoToUser(), and Server::UserToPseudo().
317 .SS "void userrec::FlushWriteBuf ()"
319 Flushes as much of the user's buffer to the file descriptor as possible. This function may not always flush the entire buffer, rather instead as much of it as it possibly can. If the send() call fails to send the entire buffer, the buffer position is advanced forwards and the rest of the data sent at the next call to this method.Definition at line 242 of file users.cpp.
321 References connection::bytes_out, connection::cmds_out, sendq, and SetWriteError().
325 244 if (sendq.length())
327 246 char* tb = (char*)this->sendq.c_str();
328 247 int n_sent = write(this->fd,tb,this->sendq.length());
329 248 if (n_sent == -1)
331 250 this->SetWriteError(strerror(errno));
335 254 // advance the queue
337 256 this->sendq = tb;
338 257 // update the user's stats counters
339 258 this->bytes_out += n_sent;
340 259 this->cmds_out++;
345 .SS "std::string userrec::GetBuffer ()"
347 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 209 of file users.cpp.
355 213 char* line = (char*)recvq.c_str();
356 214 std::string ret = '';
357 215 while ((*line != '\n') && (strlen(line)))
359 217 ret = ret + *line;
362 220 if ((*line == '\n') || (*line == '\r'))
368 .SS "char * userrec::GetFullHost ()\fC [virtual]\fP"
370 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 62 of file users.cpp.
372 References dhost, ident, nick, and result.
376 64 snprintf(result,MAXBUF,'%s!%s@%s',nick,ident,dhost);
380 .SS "char * userrec::GetFullRealHost ()\fC [virtual]\fP"
382 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 69 of file users.cpp.
384 References connection::host, ident, nick, and result.
388 71 snprintf(result,MAXBUF,'%s!%s@%s',nick,ident,host);
392 .SS "std::string userrec::GetWriteError ()"
394 Returns the write error which last occured on this connection or an empty string if none occured. Definition at line 272 of file users.cpp.
396 References WriteError.
398 Referenced by AddWriteBuf().
402 274 return this->WriteError;
405 .SS "bool userrec::HasPermission (char * command)"
407 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 118 of file users.cpp.
409 References config_f, and DEBUG.
413 120 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
418 125 // are they even an oper at all?
419 126 if (strchr(this->modes,'o'))
421 128 log(DEBUG,'*** HasPermission: %s is an oper',this->nick);
422 129 for (int j =0; j < ConfValueEnum('type',&config_f); j++)
424 131 ConfValue('type','name',j,TypeName,&config_f);
425 132 if (!strcmp(TypeName,this->oper))
427 134 log(DEBUG,'*** HasPermission: %s is an oper of type '%s'',this->nick,this->oper);
428 135 ConfValue('type','classes',j,Classes,&config_f);
429 136 char* myclass = strtok_r(Classes,' ',&savept);
432 139 log(DEBUG,'*** HasPermission: checking classtype '%s'',myclass);
433 140 for (int k =0; k < ConfValueEnum('class',&config_f); k++)
435 142 ConfValue('class','name',k,ClassName,&config_f);
436 143 if (!strcmp(ClassName,myclass))
438 145 ConfValue('class','commands',k,CommandList,&config_f);
439 146 log(DEBUG,'*** HasPermission: found class named %s with commands: '%s'',ClassName,CommandList);
442 149 mycmd = strtok_r(CommandList,' ',&savept2);
445 152 if (!strcasecmp(mycmd,command))
447 154 log(DEBUG,'*** Command %s found, returning true',command);
450 157 mycmd = strtok_r(NULL,' ',&savept2);
454 161 myclass = strtok_r(NULL,' ',&savept);
462 .SS "void userrec::InviteTo (char * channel)\fC [virtual]\fP"
464 Adds a channel to a users invite list (invites them to a channel). Definition at line 89 of file users.cpp.
466 References Invited::channel, and invites.
471 92 strlcpy(i.channel,channel,CHANMAX);
472 93 invites.push_back(i);
475 .SS "bool userrec::IsInvited (char * channel)\fC [virtual]\fP"
477 Returns true if a user is invited to a channel. Definition at line 75 of file users.cpp.
483 77 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
486 80 if (!strcasecmp(i->channel,channel))
495 .SS "void userrec::RemoveInvite (char * channel)\fC [virtual]\fP"
497 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 96 of file users.cpp.
499 References DEBUG, and invites.
503 98 log(DEBUG,'Removing invites');
506 101 if (invites.size())
508 103 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
512 107 if (!strcasecmp(i->channel,channel))
514 109 invites.erase(i);
523 .SS "void userrec::SetWriteError (std::string error)"
525 Sets the write error for a connection. This is done because the actual disconnect of a client may occur at an inopportune time such as half way through /LIST output. The WriteErrors of clients are checked at a more ideal time (in the mainloop) and errored clients purged.Definition at line 264 of file users.cpp.
527 References DEBUG, and WriteError.
529 Referenced by AddBuffer(), AddWriteBuf(), and FlushWriteBuf().
533 266 log(DEBUG,'Setting error string for %s to '%s'',this->nick,error.c_str());
534 267 // don't try to set the error twice, its already set take the first string.
535 268 if (this->WriteError == '')
536 269 this->WriteError = error;
539 .SH "Member Data Documentation"
541 .SS "char \fBuserrec::awaymsg\fP[512]"
543 The user's away message. If this string is empty, the user is not marked as away.Definition at line 151 of file users.h.
545 Referenced by userrec().
546 .SS "\fBucrec\fP \fBuserrec::chans\fP[MAXCHANS]"
548 Definition at line 142 of file users.h.
550 Referenced by Server::PseudoToUser(), and userrec().
551 .SS "char \fBuserrec::dhost\fP[256]"
553 The host displayed to non-opers (used for cloaking etc). This usually matches the value of \fBuserrec::host\fP.Definition at line 130 of file users.h.
555 Referenced by GetFullHost(), and userrec().
556 .SS "bool \fBuserrec::dns_done\fP"
558 True when \fBDNS\fP lookups are completed. Definition at line 179 of file users.h.
560 Referenced by userrec().
561 .SS "int \fBuserrec::flood\fP"
563 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 162 of file users.h.
565 Referenced by userrec().
566 .SS "char \fBuserrec::fullname\fP[128]"
568 The users full name. Definition at line 134 of file users.h.
570 Referenced by userrec().
571 .SS "char \fBuserrec::ident\fP[64]"
573 The users ident reply. Definition at line 125 of file users.h.
575 Referenced by GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), userrec(), and Server::UserToPseudo().
576 .SS "\fBInvitedList\fP \fBuserrec::invites\fP\fC [private]\fP"
578 A list of channels the user has a pending invite to. Definition at line 114 of file users.h.
580 Referenced by InviteTo(), IsInvited(), RemoveInvite(), and userrec().
581 .SS "long \fBuserrec::lines_in\fP"
583 Flood counters. Definition at line 204 of file users.h.
585 Referenced by userrec().
586 .SS "char \fBuserrec::modes\fP[MAXBUF]"
588 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 140 of file users.h.
590 Referenced by userrec().
591 .SS "char \fBuserrec::nick\fP[NICKMAX]"
593 The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command.Definition at line 121 of file users.h.
595 Referenced by ConfigReader::DumpErrors(), GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), and userrec().
596 .SS "char \fBuserrec::oper\fP[NICKMAX]"
598 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 175 of file users.h.
600 Referenced by userrec().
601 .SS "char \fBuserrec::password\fP[MAXBUF]"
603 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 189 of file users.h.
604 .SS "unsigned long \fBuserrec::pingmax\fP"
606 Number of seconds between PINGs for this user (set from <connect:allow> tag. Definition at line 183 of file users.h.
607 .SS "std::string \fBuserrec::recvq\fP"
609 User's receive queue. Lines from the IRCd awaiting processing are stored here. Upgraded april 2005, old system a bit hairy.Definition at line 195 of file users.h.
611 Referenced by AddBuffer(), BufferIsReady(), ClearBuffer(), GetBuffer(), and userrec().
612 .SS "long \fBuserrec::recvqmax\fP"
614 Maximum size this user's recvq can become. Definition at line 218 of file users.h.
616 Referenced by AddBuffer().
617 .SS "time_t \fBuserrec::reset_due\fP"
619 Definition at line 205 of file users.h.
621 Referenced by userrec().
622 .SS "char \fBuserrec::result\fP[256]"
624 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 156 of file users.h.
626 Referenced by GetFullHost(), GetFullRealHost(), and userrec().
627 .SS "std::string \fBuserrec::sendq\fP"
629 User's send queue. Lines waiting to be sent are stored here until their buffer is flushed.Definition at line 200 of file users.h.
631 Referenced by AddWriteBuf(), FlushWriteBuf(), and userrec().
632 .SS "long \fBuserrec::sendqmax\fP"
634 Maximum size this user's sendq can become. Definition at line 214 of file users.h.
636 Referenced by AddWriteBuf().
637 .SS "char \fBuserrec::server\fP[256]"
639 The server the user is connected to. Definition at line 146 of file users.h.
641 Referenced by userrec().
642 .SS "long \fBuserrec::threshold\fP"
644 Definition at line 206 of file users.h.
645 .SS "unsigned long \fBuserrec::timeout\fP"
647 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 168 of file users.h.
649 Referenced by userrec().
650 .SS "std::string \fBuserrec::WriteError\fP"
652 Definition at line 210 of file users.h.
654 Referenced by GetWriteError(), and SetWriteError().
658 Generated automatically by Doxygen for InspIRCd from the source code.