#include <users.h>
Inherits connection.
Public Member Functions | |
userrec () | |
virtual | ~userrec () |
virtual char * | GetFullHost () |
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. | |
virtual char * | GetFullRealHost () |
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. | |
virtual bool | IsInvited (char *channel) |
Returns true if a user is invited to a channel. | |
virtual void | InviteTo (char *channel) |
Adds a channel to a users invite list (invites them to a channel). | |
virtual void | RemoveInvite (char *channel) |
Removes a channel from a users invite list. | |
bool | HasPermission (char *command) |
Returns true or false for if a user can execute a privilaged oper command. | |
bool | AddBuffer (std::string a) |
This method adds data to the buffer of the user. | |
bool | BufferIsReady () |
This method returns true if the buffer contains at least one carriage return character (e.g. | |
void | ClearBuffer () |
This function clears the entire buffer by setting it to an empty string. | |
std::string | GetBuffer () |
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. | |
Public Attributes | |
char | nick [NICKMAX] |
The users nickname. | |
char | ident [64] |
The users ident reply. | |
char | dhost [256] |
The host displayed to non-opers (used for cloaking etc). | |
char | fullname [128] |
The users full name. | |
char | modes [MAXBUF] |
The user's mode string. | |
ucrec | chans [MAXCHANS] |
char | server [256] |
The server the user is connected to. | |
char | awaymsg [512] |
The user's away message. | |
char | result [256] |
Stores the result of the last GetFullHost or GetRealHost call. | |
int | flood |
Number of lines the user can place into the buffer (up to the global NetBufferSize bytes) before they are disconnected for excess flood. | |
unsigned long | timeout |
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. | |
char | oper [NICKMAX] |
The oper type they logged in as, if they are an oper. | |
bool | dns_done |
True when DNS lookups are completed. | |
unsigned long | pingmax |
Number of seconds between PINGs for this user (set from <connect:allow> tag. | |
char | password [MAXBUF] |
Password specified by the user when they registered. | |
std::string | recvq |
User's receive queue. | |
long | lines_in |
Flood counters. | |
time_t | reset_due |
long | threshold |
Private Attributes | |
InvitedList | invites |
A list of channels the user has a pending invite to. |
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.
Definition at line 98 of file users.h.
|
Definition at line 28 of file users.cpp. 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.
00029 { 00030 // the PROPER way to do it, AVOID bzero at *ALL* costs 00031 strcpy(nick,""); 00032 strcpy(ip,"127.0.0.1"); 00033 timeout = 0; 00034 strcpy(ident,""); 00035 strcpy(host,""); 00036 strcpy(dhost,""); 00037 strcpy(fullname,""); 00038 strcpy(modes,""); 00039 strcpy(inbuf,""); 00040 strcpy(server,""); 00041 strcpy(awaymsg,""); 00042 strcpy(oper,""); 00043 reset_due = TIME; 00044 lines_in = 0; 00045 fd = lastping = signon = idle_lastmsg = nping = registered = 0; 00046 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0; 00047 haspassed = false; 00048 dns_done = false; 00049 recvq = ""; 00050 strcpy(result,""); 00051 for (int i = 0; i < MAXCHANS; i++) 00052 { 00053 this->chans[i].channel = NULL; 00054 this->chans[i].uc_modes = 0; 00055 } 00056 invites.clear(); 00057 } |
|
Definition at line 195 of file users.h.
00195 { } |
|
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. References recvq.
00170 { 00171 std::string b = ""; 00172 for (int i = 0; i < a.length(); i++) 00173 if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7)) 00174 b = b + a[i]; 00175 std::stringstream stream(recvq); 00176 stream << b; 00177 recvq = stream.str(); 00178 int i = 0; 00179 // count the size of the first line in the buffer. 00180 while (i < recvq.length()) 00181 { 00182 if (recvq[i++] == '\n') 00183 break; 00184 } 00185 // return false if we've had more than 600 characters WITHOUT 00186 // a carriage return (this is BAD, drop the socket) 00187 return (i < 600); 00188 } |
|
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. References recvq.
|
|
This function clears the entire buffer by setting it to an empty string.
Definition at line 198 of file users.cpp. References recvq. Referenced by Server::PseudoToUser(), and Server::UserToPseudo().
00199 { 00200 recvq = ""; 00201 } |
|
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 BufferIsReady() to check if it is ok to read the buffer before calling GetBuffer(). Definition at line 203 of file users.cpp. References recvq.
00204 { 00205 if (recvq == "") 00206 return ""; 00207 char* line = (char*)recvq.c_str(); 00208 std::string ret = ""; 00209 while ((*line != '\n') && (strlen(line))) 00210 { 00211 ret = ret + *line; 00212 line++; 00213 } 00214 if ((*line == '\n') || (*line == '\r')) 00215 line++; 00216 recvq = line; 00217 return ret; 00218 } |
|
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. References dhost, ident, nick, and result.
00062 { 00063 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost); 00064 return result; 00065 } |
|
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. References connection::host, ident, nick, and result.
00069 { 00070 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host); 00071 return result; 00072 } |
|
Returns true or false for if a user can execute a privilaged oper command. This is done by looking up their oper type from userrec::oper, then referencing this to their oper classes and checking the commands they can execute. Definition at line 117 of file users.cpp. References config_f, and DEBUG.
00118 { 00119 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; 00120 char* mycmd; 00121 char* savept; 00122 char* savept2; 00123 00124 // are they even an oper at all? 00125 if (strchr(this->modes,'o')) 00126 { 00127 log(DEBUG,"*** HasPermission: %s is an oper",this->nick); 00128 for (int j =0; j < ConfValueEnum("type",&config_f); j++) 00129 { 00130 ConfValue("type","name",j,TypeName,&config_f); 00131 if (!strcmp(TypeName,this->oper)) 00132 { 00133 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper); 00134 ConfValue("type","classes",j,Classes,&config_f); 00135 char* myclass = strtok_r(Classes," ",&savept); 00136 while (myclass) 00137 { 00138 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass); 00139 for (int k =0; k < ConfValueEnum("class",&config_f); k++) 00140 { 00141 ConfValue("class","name",k,ClassName,&config_f); 00142 if (!strcmp(ClassName,myclass)) 00143 { 00144 ConfValue("class","commands",k,CommandList,&config_f); 00145 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList); 00146 00147 00148 mycmd = strtok_r(CommandList," ",&savept2); 00149 while (mycmd) 00150 { 00151 if (!strcasecmp(mycmd,command)) 00152 { 00153 log(DEBUG,"*** Command %s found, returning true",command); 00154 return true; 00155 } 00156 mycmd = strtok_r(NULL," ",&savept2); 00157 } 00158 } 00159 } 00160 myclass = strtok_r(NULL," ",&savept); 00161 } 00162 } 00163 } 00164 } 00165 return false; 00166 } |
|
Adds a channel to a users invite list (invites them to a channel).
Definition at line 88 of file users.cpp. References Invited::channel, and invites.
|
|
Returns true if a user is invited to a channel.
Definition at line 74 of file users.cpp. References invites.
|
|
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. References DEBUG, and invites.
00096 { 00097 log(DEBUG,"Removing invites"); 00098 if (channel) 00099 { 00100 if (invites.size()) 00101 { 00102 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) 00103 { 00104 if (i->channel) 00105 { 00106 if (!strcasecmp(i->channel,channel)) 00107 { 00108 invites.erase(i); 00109 return; 00110 } 00111 } 00112 } 00113 } 00114 } 00115 } |
|
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. Referenced by userrec(). |
|
Definition at line 132 of file users.h. Referenced by Server::PseudoToUser(), and userrec(). |
|
The host displayed to non-opers (used for cloaking etc). This usually matches the value of userrec::host. Definition at line 120 of file users.h. Referenced by GetFullHost(), and userrec(). |
|
True when DNS lookups are completed.
Definition at line 169 of file users.h. Referenced by userrec(). |
|
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. Referenced by userrec(). |
|
The users full name.
Definition at line 124 of file users.h. Referenced by userrec(). |
|
The users ident reply.
Definition at line 115 of file users.h. Referenced by GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), userrec(), and Server::UserToPseudo(). |
|
A list of channels the user has a pending invite to.
Definition at line 104 of file users.h. Referenced by InviteTo(), IsInvited(), RemoveInvite(), and userrec(). |
|
Flood counters.
Definition at line 189 of file users.h. Referenced by userrec(). |
|
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. Referenced by userrec(). |
|
The users nickname. An invalid nickname indicates an unregistered connection prior to the NICK command. Definition at line 111 of file users.h. Referenced by ConfigReader::DumpErrors(), GetFullHost(), GetFullRealHost(), Server::PseudoToUser(), and userrec(). |
|
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. Referenced by userrec(). |
|
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. |
|
Number of seconds between PINGs for this user (set from <connect:allow> tag.
|
|
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. Referenced by AddBuffer(), BufferIsReady(), ClearBuffer(), GetBuffer(), and userrec(). |
|
Definition at line 190 of file users.h. Referenced by userrec(). |
|
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. Referenced by GetFullHost(), GetFullRealHost(), and userrec(). |
|
The server the user is connected to.
Definition at line 136 of file users.h. Referenced by userrec(). |
|
|
|
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. Referenced by userrec(). |