The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

userrec Class Reference

Holds all information about a user This class stores all information about a user connected to the irc server. More...

#include <users.h>

Inheritance diagram for userrec:

Inheritance graph
[legend]
Collaboration diagram for userrec:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void StartDNSLookup ()
 Starts a DNS lookup of the user's IP.
void SetSockAddr (int protocol_family, const char *ip, int port)
 Initialize the clients sockaddr.
int GetPort ()
 Get port number from sockaddr.
int GetProtocolFamily ()
 Get protocol family from sockaddr.
const char * GetIPString ()
 Get IP string from sockaddr, using static internal buffer.
const char * GetIPString (char *buf)
 Get IP string from sockaddr, using caller-specified buffer.
 userrec (InspIRCd *Instance)
 Default constructor.
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.
void InvalidateCache ()
 This clears any cached results that are used for GetFullRealHost() etc.
const char * FormatNoticeMasks ()
 Create a displayable mode string for this users snomasks.
std::string ProcessNoticeMasks (const char *sm)
 Process a snomask modifier string, e.g.
bool IsNoticeMaskSet (unsigned char sm)
 Returns true if a notice mask is set.
void SetNoticeMask (unsigned char sm, bool value)
 Changed a specific notice mask value.
const char * FormatModes ()
 Create a displayable mode string for this users umodes.
bool IsModeSet (unsigned char m)
 Returns true if a specific mode is set.
void SetMode (unsigned char m, bool value)
 Set a specific usermode to on or off.
virtual bool IsInvited (const irc::string &channel)
 Returns true if a user is invited to a channel.
virtual void InviteTo (const irc::string &channel)
 Adds a channel to a users invite list (invites them to a channel).
virtual void RemoveInvite (const irc::string &channel)
 Removes a channel from a users invite list.
bool HasPermission (const std::string &command)
 Returns true or false for if a user can execute a privilaged oper command.
int ReadData (void *buffer, size_t size)
 Calls read() to read some data for this user using their fd.
bool AddBuffer (std::string a)
 This method adds data to the read 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.
void SetWriteError (const std::string &error)
 Sets the write error for a connection.
const char * GetWriteError ()
 Returns the write error which last occured on this connection or an empty string if none occured.
void AddWriteBuf (const std::string &data)
 Adds to the user's write buffer.
void FlushWriteBuf ()
 Flushes as much of the user's buffer to the file descriptor as possible.
InvitedListGetInviteList ()
 Returns the list of channels this user has been invited to but has not yet joined.
char * MakeWildHost ()
 Creates a wildcard host.
char * MakeHost ()
 Creates a usermask with real host.
char * MakeHostIP ()
 Creates a usermask with real ip.
void CloseSocket ()
 Shuts down and closes the user's socket This will not cause the user to be deleted.
void AddToWhoWas ()
 Add the user to WHOWAS system.
void Oper (const std::string &opertype)
 Oper up the user using the given opertype.
void CheckClass (ConnectClass *a)
 Call this method to check a user against a connect class.
void FullConnect ()
 Use this method to fully connect a user.
userrecUpdateNickHash (const char *New)
 Change this users hash key to a new string.
bool ForceNickChange (const char *newnick)
 Force a nickname change.
void UnOper ()
 Oper down.
unsigned long GlobalCloneCount ()
 Return the number of global clones of this user.
unsigned long LocalCloneCount ()
 Return the number of local clones of this user.
void RemoveCloneCounts ()
 Remove all clone counts from the user, you should use this if you change the user's IP address in userrec::ip after they have registered.
void Write (std::string text)
 Write text to this user, appending CR/LF.
void Write (const char *text,...)
 Write text to this user, appending CR/LF.
void WriteServ (const std::string &text)
 Write text to this user, appending CR/LF and prepending :server.name.
void WriteServ (const char *text,...)
 Write text to this user, appending CR/LF and prepending :server.name.
void WriteFrom (userrec *user, const std::string &text)
 Write text to this user, appending CR/LF and prepending :nick!user of the user provided in the first parameter.
void WriteFrom (userrec *user, const char *text,...)
 Write text to this user, appending CR/LF and prepending :nick!user of the user provided in the first parameter.
void WriteTo (userrec *dest, const std::string &data)
 Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user.
void WriteTo (userrec *dest, const char *data,...)
 Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user.
void WriteCommon (const std::string &text)
 Write to all users that can see this user (including this user in the list), appending CR/LF.
void WriteCommon (const char *text,...)
 Write to all users that can see this user (including this user in the list), appending CR/LF.
void WriteCommonExcept (const char *text,...)
 Write to all users that can see this user (not including this user in the list), appending CR/LF.
void WriteCommonExcept (const std::string &text)
 Write to all users that can see this user (not including this user in the list), appending CR/LF.
void WriteCommonQuit (const std::string &normal_text, const std::string &oper_text)
 Write a quit message to all common users, as in userrec::WriteCommonExcept but with a specific quit message for opers only.
void WriteWallOps (const char *text,...)
 Write a WALLOPS message from this user to all local opers.
void WriteWallOps (const std::string &text)
 Write a WALLOPS message from this user to all local opers.
bool SharesChannelWith (userrec *other)
 Return true if the user shares at least one channel with another user.
bool ChangeDisplayedHost (const char *host)
 Change the displayed host of a user.
bool ChangeIdent (const char *newident)
 Change the ident (username) of a user.
bool ChangeName (const char *gecos)
 Change a users realname field.
void SendAll (const char *command, char *text,...)
 Send a command to all local users from this user The command given must be able to send text with the first parameter as a servermask (e.g.
std::string ChannelList (userrec *source)
 Compile a channel list for this user, and send it to the user 'source' Used internally by WHOIS.
void SplitChanList (userrec *dest, const std::string &cl)
 Split the channel list in cl which came from dest, and spool it to this user Used internally by WHOIS.
void PurgeEmptyChannels ()
 Remove this user from all channels they are on, and delete any that are now empty.
ConnectClassGetClass ()
 Get the connect class which matches this user's host or IP address.
void ShowMOTD ()
 Show the message of the day to this user.
void ShowRULES ()
 Show the server RULES file to this user.
void SetOperQuit (const std::string &oquit)
 Set oper-specific quit message shown to opers only when the user quits (overrides any sent by QuitUser).
const char * GetOperQuit ()
 Get oper-specific quit message shown only to opers when the user quits.
void HandleEvent (EventType et, int errornum=0)
 Handle socket event.
virtual ~userrec ()
 Default destructor.

Static Public Member Functions

static void QuitUser (InspIRCd *Instance, userrec *user, const std::string &r, const char *oreason="")
 Disconnect a user gracefully.
static void AddClient (InspIRCd *Instance, int socket, int port, bool iscached, int socketfamily, sockaddr *ip)
 Add a client to the system.

Public Attributes

UserResolverres_forward
 Resolvers for looking up this users IP address This will occur if and when res_reverse completes.
UserResolverres_reverse
 Resolvers for looking up this users hostname This is instantiated by userrec::StartDNSLookup(), and on success, instantiates userrec::res_reverse.
VisDataVisibility
 User visibility state, see definition of VisData.
std::string stored_host
 Stored reverse lookup from res_forward.
char nick [NICKMAX]
 The users nickname.
char ident [IDENTMAX+2]
 The users ident reply.
char dhost [65]
 The host displayed to non-opers (used for cloaking etc).
char fullname [MAXGECOS+1]
 The users full name (GECOS).
char modes [64]
 The user's mode list.
char snomasks [64]
 What snomasks are set on this user.
UserChanList chans
 Channels this user is on, and the permissions they have there.
const char * server
 The server the user is connected to.
char awaymsg [MAXAWAY+1]
 The user's away message.
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.
time_t timeout
 Timestamp of current time + connection class timeout.
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 int pingmax
 Number of seconds between PINGs for this user (set from <connect:allow> tag.
char password [64]
 Password specified by the user when they registered.
std::string recvq
 User's receive queue.
std::string sendq
 User's send queue.
int lines_in
 Flood counters - lines received.
time_t reset_due
 Flood counters - time lines_in is due to be reset.
long threshold
 Flood counters - Highest value lines_in may reach before the user gets disconnected.
bool quitting
 If this is set to true, then all read operations for the user are dropped into the bit-bucket.
bool silentquit
std::string quitmsg
 Quit message for this user.
std::string operquitmsg
 Oper-only quit message for this user if non-null.
sockaddr * ip
 IPV4 or IPV6 ip address.
std::string WriteError
long sendqmax
 Maximum size this user's sendq can become.
long recvqmax
 Maximum size this user's recvq can become.
bool exempt
 This is true if the user matched an exception when they connected to the ircd.

Private Member Functions

void DecrementModes ()
 When we erase the user (in the destructor), we call this method to subtract one from all mode characters this user is making use of.

Private Attributes

InspIRCdServerInstance
 Pointer to creator.
InvitedList invites
 A list of channels the user has a pending invite to.
unsigned int ChannelCount
 Number of channels this user is currently on.
char * cached_fullhost
 Cached nick!ident value using the real hostname.
char * cached_hostip
 Cached nick!ident value using the real IP address.
char * cached_makehost
 Cached nick!ident value using the masked hostname.
char * cached_fullrealhost
 Cached nick!ident value using the real hostname.

Detailed Description

Holds all information about a user This class stores all information about a user connected to the irc server.

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 FindNick method of the InspIRCd class to locate a specific user by nickname, or the FindDescriptor method of the InspIRCd class to find a specific user by their file descriptor value.

Definition at line 329 of file users.h.


Constructor & Destructor Documentation

userrec::userrec InspIRCd Instance  ) 
 

Default constructor.

Exceptions:
Nothing at present

Definition at line 323 of file users.cpp.

References classbase::age, awaymsg, connection::bytes_in, connection::bytes_out, cached_fullhost, cached_fullrealhost, cached_hostip, cached_makehost, ChannelCount, chans, connection::cmds_in, connection::cmds_out, InspIRCd::Config, dhost, dns_done, exempt, EventHandler::fd, InspIRCd::FindServerNamePtr(), flood, fullname, connection::haspassed, connection::host, ident, connection::idle_lastmsg, invites, ip, connection::lastping, lines_in, modes, nick, connection::nping, oper, password, quitting, recvq, connection::registered, res_forward, res_reverse, reset_due, sendq, server, ServerInstance, ServerConfig::ServerName, connection::signon, silentquit, snomasks, InspIRCd::Time(), timeout, Visibility, and WriteError.

Referenced by AddClient().

00323                                    : ServerInstance(Instance)
00324 {
00325         // the PROPER way to do it, AVOID bzero at *ALL* costs
00326         *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0;
00327         server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName);
00328         reset_due = ServerInstance->Time();
00329         age = ServerInstance->Time(true);
00330         lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
00331         ChannelCount = timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0;
00332         silentquit = quitting = exempt = haspassed = dns_done = false;
00333         fd = -1;
00334         recvq.clear();
00335         sendq.clear();
00336         WriteError.clear();
00337         res_forward = res_reverse = NULL;
00338         Visibility = NULL;
00339         ip = NULL;
00340         chans.clear();
00341         invites.clear();
00342         memset(modes,0,sizeof(modes));
00343         memset(snomasks,0,sizeof(snomasks));
00344         /* Invalidate cache */
00345         cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
00346 }

userrec::~userrec  )  [virtual]
 

Default destructor.

Definition at line 371 of file users.cpp.

References DecrementModes(), InvalidateCache(), ip, and RemoveCloneCounts().

00372 {
00373         this->InvalidateCache();
00374         this->DecrementModes();
00375 
00376         if (ip)
00377         {
00378                 this->RemoveCloneCounts();
00379 
00380                 if (this->GetProtocolFamily() == AF_INET)
00381                 {
00382                         delete (sockaddr_in*)ip;
00383                 }
00384 #ifdef SUPPORT_IP6LINKS
00385                 else
00386                 {
00387                         delete (sockaddr_in6*)ip;
00388                 }
00389 #endif
00390         }
00391 }


Member Function Documentation

bool userrec::AddBuffer std::string  a  ) 
 

This method adds data to the read 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.

Parameters:
a The string to add to the users read buffer
Returns:
True if the string was successfully added to the read buffer

Definition at line 611 of file users.cpp.

References DEBUG, InspIRCd::Log(), recvq, recvqmax, ServerInstance, SetWriteError(), and InspIRCd::WriteOpers().

Referenced by InspIRCd::ProcessUser().

00612 {
00613         try
00614         {
00615                 std::string::size_type i = a.rfind('\r');
00616 
00617                 while (i != std::string::npos)
00618                 {
00619                         a.erase(i, 1);
00620                         i = a.rfind('\r');
00621                 }
00622 
00623                 if (a.length())
00624                         recvq.append(a);
00625 
00626                 if (recvq.length() > (unsigned)this->recvqmax)
00627                 {
00628                         this->SetWriteError("RecvQ exceeded");
00629                         ServerInstance->WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
00630                         return false;
00631                 }
00632 
00633                 return true;
00634         }
00635 
00636         catch (...)
00637         {
00638                 ServerInstance->Log(DEBUG,"Exception in userrec::AddBuffer()");
00639                 return false;
00640         }
00641 }

void userrec::AddClient InspIRCd Instance,
int  socket,
int  port,
bool  iscached,
int  socketfamily,
sockaddr *  ip
[static]
 

Add a client to the system.

This will create a new userrec, insert it into the user_hash, initialize it as not yet registered, and add it to the socket engine.

Parameters:
Instance a pointer to the server instance
socket The socket id (file descriptor) this user is on
port The port number this user connected on
iscached This variable is reserved for future use
ip The IP address of the user
Returns:
This function has no return value, but a call to AddClient may remove the user.

Definition at line 862 of file users.cpp.

References SocketEngine::AddFd(), InspIRCd::AddGlobalClone(), InspIRCd::AddLocalClone(), CheckClass(), InspIRCd::clientlist, InspIRCd::Config, ConvToStr(), DELETE(), dhost, ServerConfig::dns_timeout, exempt, EventHandler::fd, InspIRCd::FindServerNamePtr(), GetClass(), GetIPString(), connection::host, ident, connection::lastping, InspIRCd::local_users, XLineManager::matches_exception(), XLineManager::matches_zline(), MAX_DESCRIPTORS, MAXBUF, MAXCLIENTS, ServerConfig::MoronBanner, nick, NICKMAX, QuitUser(), XLine::reason, REG_NONE, connection::registered, InspIRCd::SE, server, ServerConfig::ServerName, SetSockAddr(), connection::signon, ServerConfig::SoftLimit, strlcpy(), InspIRCd::Time(), InspIRCd::unregistered_count, userrec(), InspIRCd::WriteOpers(), WriteServ(), and InspIRCd::XLines.

Referenced by ListenSocket::HandleEvent().

00863 {
00864         std::string tempnick = ConvToStr(socket) + "-unknown";
00865         user_hash::iterator iter = Instance->clientlist->find(tempnick);
00866         char ipaddr[MAXBUF];
00867 #ifdef IPV6
00868         if (socketfamily == AF_INET6)
00869                 inet_ntop(AF_INET6, &((const sockaddr_in6*)ip)->sin6_addr, ipaddr, sizeof(ipaddr));
00870         else
00871 #endif
00872         inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
00873         userrec* New;
00874         int j = 0;
00875 
00876         Instance->unregistered_count++;
00877 
00878         /*
00879          * fix by brain.
00880          * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
00881          * using one as a registered connection. As they are per fd, we can also safely assume
00882          * that we wont have collisions. Therefore, if the nick exists in the list, its only
00883          * used by a dead socket, erase the iterator so that the new client may reclaim it.
00884          * this was probably the cause of 'server ignores me when i hammer it with reconnects'
00885          * issue in earlier alphas/betas
00886          */
00887         if (iter != Instance->clientlist->end())
00888         {
00889                 userrec* goner = iter->second;
00890                 DELETE(goner);
00891                 Instance->clientlist->erase(iter);
00892         }
00893 
00894         New = new userrec(Instance);
00895         (*(Instance->clientlist))[tempnick] = New;
00896         New->fd = socket;
00897         strlcpy(New->nick,tempnick.c_str(),NICKMAX-1);
00898 
00899         New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);
00900         /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
00901         strcpy(New->ident, "unknown");
00902 
00903         New->registered = REG_NONE;
00904         New->signon = Instance->Time() + Instance->Config->dns_timeout;
00905         New->lastping = 1;
00906 
00907         New->SetSockAddr(socketfamily, ipaddr, port);
00908 
00909         /* Smarter than your average bear^H^H^H^Hset of strlcpys. */
00910         for (const char* temp = New->GetIPString(); *temp && j < 64; temp++, j++)
00911                 New->dhost[j] = New->host[j] = *temp;
00912         New->dhost[j] = New->host[j] = 0;
00913 
00914         Instance->AddLocalClone(New);
00915         Instance->AddGlobalClone(New);
00916 
00917         New->exempt = (Instance->XLines->matches_exception(New) != NULL);
00918         if (!New->exempt)
00919         {
00920                 ZLine* r = Instance->XLines->matches_zline(ipaddr);
00921                 if (r)
00922                 {
00923                         char reason[MAXBUF];
00924                         if (*Instance->Config->MoronBanner)
00925                                 New->WriteServ("NOTICE %s :*** %s", New->nick, Instance->Config->MoronBanner);
00926                         snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
00927                         userrec::QuitUser(Instance, New, reason);
00928                         return;
00929                 }
00930         }
00931 
00932 
00933         /*
00934          * First class check. We do this again in FullConnect after DNS is done, and NICK/USER is recieved.
00935          * See my note down there for why this is required. DO NOT REMOVE. :) -- w00t
00936          */
00937         ConnectClass* i = New->GetClass();
00938 
00939         if (!i)
00940         {
00941                 userrec::QuitUser(Instance, New, "Access denied by configuration");
00942                 return;
00943         }
00944 
00945         /*
00946          * Check connect class settings and initialise settings into userrec.
00947          * This will be done again after DNS resolution. -- w00t
00948          */
00949         New->CheckClass(i);
00950 
00951         Instance->local_users.push_back(New);
00952 
00953         if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
00954         {
00955                 Instance->WriteOpers("*** Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
00956                 userrec::QuitUser(Instance, New,"No more connections allowed");
00957                 return;
00958         }
00959 
00960         /*
00961          * XXX -
00962          * this is done as a safety check to keep the file descriptors within range of fd_ref_table.
00963          * its a pretty big but for the moment valid assumption:
00964          * file descriptors are handed out starting at 0, and are recycled as theyre freed.
00965          * therefore if there is ever an fd over 65535, 65536 clients must be connected to the
00966          * irc server at once (or the irc server otherwise initiating this many connections, files etc)
00967          * which for the time being is a physical impossibility (even the largest networks dont have more
00968          * than about 10,000 users on ONE server!)
00969          */
00970 #ifndef WINDOWS
00971         if ((unsigned int)socket >= MAX_DESCRIPTORS)
00972         {
00973                 userrec::QuitUser(Instance, New, "Server is full");
00974                 return;
00975         }
00976 #endif
00977 
00978         if (socket > -1)
00979         {
00980                 if (!Instance->SE->AddFd(New))
00981                 {
00982                         userrec::QuitUser(Instance, New, "Internal error handling connection");
00983                 }
00984         }
00985 
00986         /* NOTE: even if dns lookups are *off*, we still need to display this.
00987          * BOPM and other stuff requires it.
00988          */
00989         New->WriteServ("NOTICE Auth :*** Looking up your hostname...");
00990 }

void userrec::AddToWhoWas  ) 
 

Add the user to WHOWAS system.

Definition at line 850 of file users.cpp.

References CommandParser::GetHandler(), command_t::HandleInternal(), InspIRCd::Parser, ServerInstance, and WHOWAS_ADD.

00851 {
00852         command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
00853         if (whowas_command)
00854         {
00855                 std::deque<classbase*> params;
00856                 params.push_back(this);
00857                 whowas_command->HandleInternal(WHOWAS_ADD, params);
00858         }
00859 }

void userrec::AddWriteBuf const std::string data  ) 
 

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, SetWriteError() will be called to set the users error string to "SendQ exceeded", and further buffer adds will be dropped.

Parameters:
data The data to add to the write buffer

Definition at line 693 of file users.cpp.

References MAXBUF, sendq, sendqmax, ServerInstance, SetWriteError(), and InspIRCd::WriteOpers().

Referenced by ModuleXMLSocket::OnRawSocketWrite(), and Write().

00694 {
00695         if (*this->GetWriteError())
00696                 return;
00697 
00698         if (sendq.length() + data.length() > (unsigned)this->sendqmax)
00699         {
00700                 /*
00701                  * Fix by brain - Set the error text BEFORE calling writeopers, because
00702                  * if we dont it'll recursively  call here over and over again trying
00703                  * to repeatedly add the text to the sendq!
00704                  */
00705                 this->SetWriteError("SendQ exceeded");
00706                 ServerInstance->WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
00707                 return;
00708         }
00709 
00710         try
00711         {
00712                 if (data.length() > MAXBUF - 2) /* MAXBUF has a value of 514, to account for line terminators */
00713                         sendq.append(data.substr(0,MAXBUF - 4)).append("\r\n"); /* MAXBUF-4 = 510 */
00714                 else
00715                         sendq.append(data);
00716         }
00717         catch (...)
00718         {
00719                 this->SetWriteError("SendQ exceeded");
00720                 ServerInstance->WriteOpers("*** User %s SendQ got an exception",this->nick);
00721         }
00722 }

bool userrec::BufferIsReady  ) 
 

This method returns true if the buffer contains at least one carriage return character (e.g.

one complete line may be read)

Returns:
True if there is at least one complete line in the users buffer

Definition at line 643 of file users.cpp.

References recvq.

Referenced by InspIRCd::ProcessUser().

00644 {
00645         return (recvq.find('\n') != std::string::npos);
00646 }

bool userrec::ChangeDisplayedHost const char *  host  ) 
 

Change the displayed host of a user.

ALWAYS use this function, rather than writing userrec::dhost directly, as this triggers module events allowing the change to be syncronized to remote servers. This will also emulate a QUIT and rejoin (where configured) before setting their host field.

Parameters:
host The new hostname to set
Returns:
True if the change succeeded, false if it didn't

Definition at line 1715 of file users.cpp.

References chans, FOREACH_MOD, FOREACH_RESULT, I_OnChangeHost, I_OnChangeLocalUserHost, InvalidateCache(), IS_LOCAL, InspIRCd::Modes, ModeParser::ModeString(), ServerInstance, strlcpy(), WriteCommonExcept(), and WriteServ().

Referenced by TreeSocket::ChangeHost(), cmd_vhost::Handle(), cmd_sethost::Handle(), cmd_title::Handle(), cmd_chghost::Handle(), cmd_oper::Handle(), CloakUser::OnModeChange(), ModuleHostChange::OnUserConnect(), and ModuleSQLOper::OperUser().

01716 {
01717         if (!strcmp(host, this->dhost))
01718                 return true;
01719 
01720         if (IS_LOCAL(this))
01721         {
01722                 int MOD_RESULT = 0;
01723                 FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(this,host));
01724                 if (MOD_RESULT)
01725                         return false;
01726                 FOREACH_MOD(I_OnChangeHost,OnChangeHost(this,host));
01727         }
01728         if (this->ServerInstance->Config->CycleHosts)
01729                 this->WriteCommonExcept("QUIT :Changing hosts");
01730 
01731         /* Fix by Om: userrec::dhost is 65 long, this was truncating some long hosts */
01732         strlcpy(this->dhost,host,64);
01733 
01734         this->InvalidateCache();
01735 
01736         if (this->ServerInstance->Config->CycleHosts)
01737         {
01738                 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
01739                 {
01740                         i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
01741                         std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
01742                         if (n.length() > 0)
01743                                 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
01744                 }
01745         }
01746 
01747         if (IS_LOCAL(this))
01748                 this->WriteServ("396 %s %s :is now your displayed host",this->nick,this->dhost);
01749 
01750         return true;
01751 }

bool userrec::ChangeIdent const char *  newident  ) 
 

Change the ident (username) of a user.

ALWAYS use this function, rather than writing userrec::ident directly, as this correctly causes the user to seem to quit (where configured) before setting their ident field.

Parameters:
host The new ident to set
Returns:
True if the change succeeded, false if it didn't

Definition at line 1753 of file users.cpp.

References chans, IDENTMAX, InvalidateCache(), InspIRCd::Modes, ModeParser::ModeString(), ServerInstance, strlcpy(), and WriteCommonExcept().

Referenced by cmd_setident::Handle(), and cmd_chgident::Handle().

01754 {
01755         if (!strcmp(newident, this->ident))
01756                 return true;
01757 
01758         if (this->ServerInstance->Config->CycleHosts)
01759                 this->WriteCommonExcept("%s","QUIT :Changing ident");
01760 
01761         strlcpy(this->ident, newident, IDENTMAX+1);
01762 
01763         this->InvalidateCache();
01764 
01765         if (this->ServerInstance->Config->CycleHosts)
01766         {
01767                 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
01768                 {
01769                         i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
01770                         std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
01771                         if (n.length() > 0)
01772                                 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
01773                 }
01774         }
01775 
01776         return true;
01777 }

bool userrec::ChangeName const char *  gecos  ) 
 

Change a users realname field.

ALWAYS use this function, rather than writing userrec::fullname directly, as this triggers module events allowing the change to be syncronized to remote servers.

Parameters:
gecos The user's new realname
Returns:
True if the change succeeded, false if otherwise

Definition at line 1697 of file users.cpp.

References FOREACH_MOD, FOREACH_RESULT, I_OnChangeLocalUserGECOS, I_OnChangeName, IS_LOCAL, MAXGECOS, and strlcpy().

Referenced by TreeSocket::ChangeName(), cmd_setname::Handle(), and cmd_chgname::Handle().

01698 {
01699         if (!strcmp(gecos, this->fullname))
01700                 return true;
01701 
01702         if (IS_LOCAL(this))
01703         {
01704                 int MOD_RESULT = 0;
01705                 FOREACH_RESULT(I_OnChangeLocalUserGECOS,OnChangeLocalUserGECOS(this,gecos));
01706                 if (MOD_RESULT)
01707                         return false;
01708                 FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos));
01709         }
01710         strlcpy(this->fullname,gecos,MAXGECOS+1);
01711 
01712         return true;
01713 }

std::string userrec::ChannelList userrec source  ) 
 

Compile a channel list for this user, and send it to the user 'source' Used internally by WHOIS.

Parameters:
The user to send the channel list to if it is not too long
Returns:
This user's channel list

Definition at line 1799 of file users.cpp.

References chans, InspIRCd::Config, DEBUG, IS_OPER, InspIRCd::Log(), ServerConfig::OperSpyWhois, and ServerInstance.

Referenced by do_whois(), and cmd_check::Handle().

01800 {
01801         try
01802         {
01803                 std::string list;
01804                 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
01805                 {
01806                         /* If the target is the same as the sender, let them see all their channels.
01807                          * If the channel is NOT private/secret OR the user shares a common channel
01808                          * If the user is an oper, and the <options:operspywhois> option is set.
01809                          */
01810                         if ((source == this) || (IS_OPER(source) && ServerInstance->Config->OperSpyWhois) || (((!i->first->IsModeSet('p')) && (!i->first->IsModeSet('s'))) || (i->first->HasUser(source))))
01811                         {
01812                                 list.append(i->first->GetPrefixChar(this)).append(i->first->name).append(" ");
01813                         }
01814                 }
01815                 return list;
01816         }
01817         catch (...)
01818         {
01819                 ServerInstance->Log(DEBUG,"Exception in userrec::ChannelList()");
01820                 return "";
01821         }
01822 }

void userrec::CheckClass ConnectClass a  ) 
 

Call this method to check a user against a connect class.

Parameters:
a The connect class to match them against.

Definition at line 1013 of file users.cpp.

References CC_DENY, InspIRCd::Config, ServerConfig::dns_timeout, flood, ConnectClass::GetFlood(), GetIPString(), ConnectClass::GetMaxGlobal(), ConnectClass::GetMaxLocal(), ConnectClass::GetPingTime(), ConnectClass::GetRecvqMax(), ConnectClass::GetRegTimeout(), ConnectClass::GetSendqMax(), ConnectClass::GetThreshold(), ConnectClass::GetType(), GlobalCloneCount(), LocalCloneCount(), connection::nping, pingmax, QuitUser(), recvqmax, sendqmax, ServerInstance, threshold, InspIRCd::Time(), timeout, and InspIRCd::WriteOpers().

Referenced by AddClient(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), FullConnect(), and ModuleCgiIRC::OnUserConnect().

01014 {
01015         if ((!a) || (a->GetType() == CC_DENY))
01016         {
01017                 userrec::QuitUser(ServerInstance, this, "Unauthorised connection");
01018                 return;
01019         }
01020         else if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
01021         {
01022                 userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (local)");
01023                 ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
01024                 return;
01025         }
01026         else if ((a->GetMaxGlobal()) && (this->GlobalCloneCount() > a->GetMaxGlobal()))
01027         {
01028                 userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (global)");
01029                 ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
01030                 return;
01031         }
01032 
01033         this->pingmax = a->GetPingTime();
01034         this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout;
01035         this->timeout = ServerInstance->Time() + a->GetRegTimeout();
01036         this->flood = a->GetFlood();
01037         this->threshold = a->GetThreshold();
01038         this->sendqmax = a->GetSendqMax();
01039         this->recvqmax = a->GetRecvqMax();
01040 }

void userrec::ClearBuffer  ) 
 

This function clears the entire buffer by setting it to an empty string.

Definition at line 648 of file users.cpp.

References recvq.

00649 {
00650         recvq.clear();
00651 }

void userrec::CloseSocket  ) 
 

Shuts down and closes the user's socket This will not cause the user to be deleted.

Use InspIRCd::QuitUser for this, which will call CloseSocket() for you.

Definition at line 433 of file users.cpp.

Referenced by CullList::Apply().

00434 {
00435         if (this->fd > -1)
00436         {
00437                 shutdown(this->fd,2);
00438                 close(this->fd);
00439         }
00440 }

void userrec::DecrementModes  )  [private]
 

When we erase the user (in the destructor), we call this method to subtract one from all mode characters this user is making use of.

Definition at line 310 of file users.cpp.

References ModeHandler::ChangeCount(), ModeParser::FindMode(), InspIRCd::Modes, modes, MODETYPE_USER, and ServerInstance.

Referenced by ~userrec().

00311 {
00312         for (int n = 0; n < 64; n++)
00313         {
00314                 if (modes[n])
00315                 {
00316                         ModeHandler* mh = ServerInstance->Modes->FindMode(n+65, MODETYPE_USER);
00317                         if (mh)
00318                                 mh->ChangeCount(-1);
00319                 }
00320         }
00321 }

void userrec::FlushWriteBuf  ) 
 

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 725 of file users.cpp.

References connection::bytes_out, connection::cmds_out, DEBUG, EventHandler::fd, FD_MAGIC_NUMBER, FOREACH_MOD, I_OnBufferFlushed, InspIRCd::Log(), InspIRCd::SE, sendq, ServerInstance, SetWriteError(), and SocketEngine::WantWrite().

Referenced by CullList::Apply(), and HandleEvent().

00726 {
00727         try
00728         {
00729                 if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
00730                 {
00731                         sendq.clear();
00732                 }
00733                 if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
00734                 {
00735                         int old_sendq_length = sendq.length();
00736 #ifndef WIN32
00737                 int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
00738 #else
00739                 int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0);
00740 #endif
00741                         if (n_sent == -1)
00742                         {
00743                                 if (errno == EAGAIN)
00744                                 {
00745                                         /* The socket buffer is full. This isnt fatal,
00746                                          * try again later.
00747                                          */
00748                                         this->ServerInstance->SE->WantWrite(this);
00749                                 }
00750                                 else
00751                                 {
00752                                         /* Fatal error, set write error and bail
00753                                          */
00754                                         this->SetWriteError(errno ? strerror(errno) : "EOF from client");
00755                                         return;
00756                                 }
00757                         }
00758                         else
00759                         {
00760                                 /* advance the queue */
00761                                 if (n_sent)
00762                                         this->sendq = this->sendq.substr(n_sent);
00763                                 /* update the user's stats counters */
00764                                 this->bytes_out += n_sent;
00765                                 this->cmds_out++;
00766                                 if (n_sent != old_sendq_length)
00767                                         this->ServerInstance->SE->WantWrite(this);
00768                         }
00769                 }
00770         }
00771 
00772         catch (...)
00773         {
00774                 ServerInstance->Log(DEBUG,"Exception in userrec::FlushWriteBuf()");
00775         }
00776 
00777         if (this->sendq.empty())
00778         {
00779                 FOREACH_MOD(I_OnBufferFlushed,OnBufferFlushed(this));
00780         }
00781 }

bool userrec::ForceNickChange const char *  newnick  ) 
 

Force a nickname change.

If the nickname change fails (for example, because the nick in question already exists) this function will return false, and you must then either output an error message, or quit the user for nickname collision.

Parameters:
newnick The nickname to change to
Returns:
True if the nickchange was successful.

Definition at line 1185 of file users.cpp.

References CommandParser::CallHandler(), CMD_SUCCESS, DEBUG, FOREACH_RESULT, I_OnUserPreNick, InvalidateCache(), InspIRCd::Log(), XLineManager::matches_qline(), InspIRCd::Parser, REG_ALL, ServerInstance, InspIRCd::stats, serverstats::statsCollisions, and InspIRCd::XLines.

Referenced by TreeSocket::ForceNick(), cmd_sanick::Handle(), and cmd_nicklock::Handle().

01186 {
01187         try
01188         {
01189                 int MOD_RESULT = 0;
01190 
01191                 this->InvalidateCache();
01192 
01193                 FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
01194 
01195                 if (MOD_RESULT)
01196                 {
01197                         ServerInstance->stats->statsCollisions++;
01198                         return false;
01199                 }
01200 
01201                 if (ServerInstance->XLines->matches_qline(newnick))
01202                 {
01203                         ServerInstance->stats->statsCollisions++;
01204                         return false;
01205                 }
01206 
01207                 if (this->registered == REG_ALL)
01208                 {
01209                         return (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
01210                 }
01211                 return false;
01212         }
01213 
01214         catch (...)
01215         {
01216                 ServerInstance->Log(DEBUG,"Exception in userrec::ForceNickChange()");
01217                 return false;
01218         }
01219 }

const char * userrec::FormatModes  ) 
 

Create a displayable mode string for this users umodes.

Parameters:
The mode string

Definition at line 297 of file users.cpp.

References MAXBUF, and modes.

Referenced by ModeParser::DisplayCurrentModes(), cmd_check::Handle(), and ModuleSpanningTree::OnUserConnect().

00298 {
00299         static char data[MAXBUF];
00300         int offset = 0;
00301         for (int n = 0; n < 64; n++)
00302         {
00303                 if (modes[n])
00304                         data[offset++] = n+65;
00305         }
00306         data[offset] = 0;
00307         return data;
00308 }

const char * userrec::FormatNoticeMasks  ) 
 

Create a displayable mode string for this users snomasks.

Returns:
The notice mask character sequence

Definition at line 270 of file users.cpp.

References MAXBUF, and snomasks.

Referenced by ModeParser::DisplayCurrentModes(), and cmd_check::Handle().

00271 {
00272         static char data[MAXBUF];
00273         int offset = 0;
00274 
00275         for (int n = 0; n < 64; n++)
00276         {
00277                 if (snomasks[n])
00278                         data[offset++] = n+65;
00279         }
00280 
00281         data[offset] = 0;
00282         return data;
00283 }

void userrec::FullConnect  ) 
 

Use this method to fully connect a user.

This will send the message of the day, check G/K/E lines, etc.

Definition at line 1042 of file users.cpp.

References InspIRCd::CallCommandHandler(), ModeParser::ChannelModeList(), CheckClass(), InspIRCd::Config, exempt, FOREACH_MOD, FOREACH_RESULT, fullname, GetClass(), GetIPString(), connection::haspassed, connection::host, I_OnPostConnect, I_OnPreCommand, I_OnUserConnect, ident, connection::idle_lastmsg, XLineManager::matches_exception(), XLineManager::matches_gline(), XLineManager::matches_kline(), MAXBUF, InspIRCd::Modes, ServerConfig::MoronBanner, ServerConfig::Network, nick, ModeParser::ParaModeList(), QuitUser(), XLine::reason, REG_ALL, connection::registered, ServerConfig::Send005(), ServerInstance, ServerConfig::ServerName, ShowMOTD(), InspIRCd::SNO, InspIRCd::stats, serverstats::statsConnects, InspIRCd::Time(), InspIRCd::unregistered_count, ModeParser::UserModeList(), WriteServ(), SnomaskManager::WriteToSnoMask(), and InspIRCd::XLines.

Referenced by InspIRCd::DoBackgroundUserStuff().

01043 {
01044         ServerInstance->stats->statsConnects++;
01045         this->idle_lastmsg = ServerInstance->Time();
01046 
01047 
01048         ConnectClass *a = this->GetClass();
01049         if (!a)
01050         {
01051                 /*
01052                  * This can happen:
01053                  *  - user connects
01054                  *  - /rehash, removing <connect> tag they matched
01055                  *  - dns completes (putting us here) ...but they no longer have a connect tag
01056                  * Catch it here. Thanks Szymek!
01057                  *  -- w00t
01058                  */
01059                 userrec::QuitUser(ServerInstance, this, "Invalid password");
01060                 return;
01061         }
01062         
01063         /*
01064          * You may be thinking "wtf, we checked this in userrec::AddClient!" - and yes, we did, BUT.
01065          * At the time AddClient is called, we don't have a resolved host, by here we probably do - which
01066          * may put the user into a totally seperate class with different restrictions! so we *must* check again.
01067          * Don't remove this! -- w00t
01068          */
01069         this->CheckClass(a);
01070         
01071         /* Check the password, if one is required by the user's connect class.
01072          * This CANNOT be in CheckClass(), because that is called prior to PASS as well!
01073          */
01074         if ((!this->GetClass()->GetPass().empty()) && (!this->haspassed))
01075         {
01076                 userrec::QuitUser(ServerInstance, this, "Invalid password");
01077                 return;
01078         }
01079         
01080         this->exempt = (ServerInstance->XLines->matches_exception(this) != NULL);
01081         if (!this->exempt)
01082         {
01083                 GLine* r = ServerInstance->XLines->matches_gline(this);
01084 
01085                 if (r)
01086                 {
01087                         char reason[MAXBUF];
01088                         if (*ServerInstance->Config->MoronBanner)
01089                                 this->WriteServ("NOTICE %s :*** %s", this->nick, ServerInstance->Config->MoronBanner);
01090                         snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
01091                         userrec::QuitUser(ServerInstance, this, reason);
01092                         return;
01093                 }
01094 
01095                 KLine* n = ServerInstance->XLines->matches_kline(this);
01096 
01097                 if (n)
01098                 {
01099                         char reason[MAXBUF];
01100                         if (*ServerInstance->Config->MoronBanner)
01101                                 this->WriteServ("NOTICE %s :*** %s", this->nick, ServerInstance->Config->MoronBanner);
01102                         snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
01103                         userrec::QuitUser(ServerInstance, this, reason);
01104                         return;
01105                 }
01106         }
01107 
01108         this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network);
01109         this->WriteServ("001 %s :Welcome to the %s IRC Network %s!%s@%s",this->nick, ServerInstance->Config->Network, this->nick, this->ident, this->host);
01110         this->WriteServ("002 %s :Your host is %s, running version InspIRCd-1.1",this->nick,ServerInstance->Config->ServerName);
01111         this->WriteServ("003 %s :This server was created %s %s", this->nick, __TIME__, __DATE__);
01112         this->WriteServ("004 %s %s InspIRCd-1.1 %s %s %s", this->nick, ServerInstance->Config->ServerName, ServerInstance->Modes->UserModeList().c_str(), ServerInstance->Modes->ChannelModeList().c_str(), ServerInstance->Modes->ParaModeList().c_str());
01113 
01114         ServerInstance->Config->Send005(this);
01115 
01116         this->ShowMOTD();
01117 
01118         /* Now registered */
01119         if (ServerInstance->unregistered_count)
01120                 ServerInstance->unregistered_count--;
01121 
01122         /* Trigger LUSERS output, give modules a chance too */
01123         int MOD_RESULT = 0;
01124         FOREACH_RESULT(I_OnPreCommand, OnPreCommand("LUSERS", NULL, 0, this, true, "LUSERS"));
01125         if (!MOD_RESULT)
01126                 ServerInstance->CallCommandHandler("LUSERS", NULL, 0, this);
01127 
01128         /*
01129          * fix 3 by brain, move registered = 7 below these so that spurious modes and host
01130          * changes dont go out onto the network and produce 'fake direction'.
01131          */
01132         FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
01133 
01134         this->registered = REG_ALL;
01135 
01136         FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
01137 
01138         ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s] [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString(), this->fullname);
01139 }

std::string userrec::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.

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().

Returns:
The string at the tail end of this users buffer

Definition at line 653 of file users.cpp.

References DEBUG, InspIRCd::Log(), recvq, and ServerInstance.

Referenced by InspIRCd::ProcessUser().

00654 {
00655         try
00656         {
00657                 if (!recvq.length())
00658                         return "";
00659 
00660                 /* Strip any leading \r or \n off the string.
00661                  * Usually there are only one or two of these,
00662                  * so its is computationally cheap to do.
00663                  */
00664                 std::string::iterator t = recvq.begin();
00665                 while (t != recvq.end() && (*t == '\r' || *t == '\n'))
00666                 {
00667                         recvq.erase(t);
00668                         t = recvq.begin();
00669                 }
00670 
00671                 for (std::string::iterator x = recvq.begin(); x != recvq.end(); x++)
00672                 {
00673                         /* Find the first complete line, return it as the
00674                          * result, and leave the recvq as whats left
00675                          */
00676                         if (*x == '\n')
00677                         {
00678                                 std::string ret = std::string(recvq.begin(), x);
00679                                 recvq.erase(recvq.begin(), x + 1);
00680                                 return ret;
00681                         }
00682                 }
00683                 return "";
00684         }
00685 
00686         catch (...)
00687         {
00688                 ServerInstance->Log(DEBUG,"Exception in userrec::GetBuffer()");
00689                 return "";
00690         }
00691 }

ConnectClass * userrec::GetClass  ) 
 

Get the connect class which matches this user's host or IP address.

Returns:
A reference to this user's connect class

Definition at line 1875 of file users.cpp.

References ServerConfig::Classes, InspIRCd::Config, match(), and ServerInstance.

Referenced by AddClient(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), FullConnect(), cmd_pass::Handle(), and ModuleCgiIRC::OnUserConnect().

01876 {
01877         for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
01878         {
01879                 if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
01880                 {
01881                         if (i->GetPort())
01882                         {
01883                                 if (this->GetPort() == i->GetPort())
01884                                         return &(*i);
01885                                 else
01886                                         continue;
01887                         }
01888                         else
01889                                 return &(*i);
01890                 }
01891         }
01892         return NULL;
01893 }

char * userrec::GetFullHost  )  [virtual]
 

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.

Returns:
The full masked host of the user

Definition at line 442 of file users.cpp.

References cached_fullhost, dhost, ident, MAXBUF, and nick.

Referenced by cmd_check::Handle(), chanrec::IsBanned(), ModuleSilence::MatchPattern(), ModuleBanException::OnCheckBan(), ModuleInviteException::OnCheckInvite(), ModuleInviteException::OnRequest(), ModuleBanException::OnRequest(), ModuleInvisible::OnUserJoin(), ModuleBanRedirect::OnUserPreJoin(), ModuleSilence::OnUserPreNotice(), ModuleDCCAllow::OnUserPreNotice(), chanrec::WriteAllExcept(), chanrec::WriteChannel(), ModuleInvisible::WriteCommonFrom(), and WriteFrom().

00443 {
00444         if (this->cached_fullhost)
00445                 return this->cached_fullhost;
00446 
00447         char result[MAXBUF];
00448         char* t = result;
00449         for(char* n = nick; *n; n++)
00450                 *t++ = *n;
00451         *t++ = '!';
00452         for(char* n = ident; *n; n++)
00453                 *t++ = *n;
00454         *t++ = '@';
00455         for(char* n = dhost; *n; n++)
00456                 *t++ = *n;
00457         *t = 0;
00458 
00459         this->cached_fullhost = strdup(result);
00460 
00461         return this->cached_fullhost;
00462 }

char * userrec::GetFullRealHost  )  [virtual]
 

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.

Returns:
The full real host of the user

Definition at line 491 of file users.cpp.

References cached_fullrealhost, connection::host, ident, MAXBUF, and nick.

Referenced by cmd_rsquit::Handle(), cmd_check::Handle(), ModuleSpanningTree::HandleSquit(), chanrec::IsBanned(), ModuleBanException::OnCheckBan(), ModuleInviteException::OnCheckInvite(), DNSBLResolver::OnLookupComplete(), ModuleInviteException::OnRequest(), ModuleBanException::OnRequest(), and ModuleBanRedirect::OnUserPreJoin().

00492 {
00493         if (this->cached_fullrealhost)
00494                 return this->cached_fullrealhost;
00495 
00496         char fresult[MAXBUF];
00497         char* t = fresult;
00498         for(char* n = nick; *n; n++)
00499                 *t++ = *n;
00500         *t++ = '!';
00501         for(char* n = ident; *n; n++)
00502                 *t++ = *n;
00503         *t++ = '@';
00504         for(char* n = host; *n; n++)
00505                 *t++ = *n;
00506         *t = 0;
00507 
00508         this->cached_fullrealhost = strdup(fresult);
00509 
00510         return this->cached_fullrealhost;
00511 }

InvitedList * userrec::GetInviteList  ) 
 

Returns the list of channels this user has been invited to but has not yet joined.

Returns:
A list of channels the user is invited to

Definition at line 525 of file users.cpp.

References invites.

Referenced by cmd_invite::Handle().

00526 {
00527         return &invites;
00528 }

const char * userrec::GetIPString char *  buf  ) 
 

Get IP string from sockaddr, using caller-specified buffer.

Parameters:
buf A buffer to use
Returns:
The IP string

Definition at line 1327 of file users.cpp.

References ip, and strlcpy().

01328 {
01329         if (this->ip == NULL)
01330         {
01331                 *buf = 0;
01332                 return buf;
01333         }
01334 
01335         switch (this->GetProtocolFamily())
01336         {
01337 #ifdef SUPPORT_IP6LINKS
01338                 case AF_INET6:
01339                 {
01340                         static char temp[1024];
01341 
01342                         sockaddr_in6* sin = (sockaddr_in6*)this->ip;
01343                         inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
01344                         /* IP addresses starting with a : on irc are a Bad Thing (tm) */
01345                         if (*buf == ':')
01346                         {
01347                                 strlcpy(&temp[1], buf, sizeof(temp) - 1);
01348                                 *temp = '0';
01349                                 strlcpy(buf, temp, sizeof(temp));
01350                         }
01351                         return buf;
01352                 }
01353                 break;
01354 #endif
01355                 case AF_INET:
01356                 {
01357                         sockaddr_in* sin = (sockaddr_in*)this->ip;
01358                         inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
01359                         return buf;
01360                 }
01361                 break;
01362 
01363                 default:
01364                 break;
01365         }
01366         return "";
01367 }

const char * userrec::GetIPString  ) 
 

Get IP string from sockaddr, using static internal buffer.

Returns:
The IP string

Definition at line 1287 of file users.cpp.

References ip, and strlcpy().

Referenced by AddClient(), InspIRCd::AddGlobalClone(), InspIRCd::AddLocalClone(), XLineManager::apply_lines(), CheckClass(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), do_whois(), InspIRCd::DoBackgroundUserStuff(), DoStats(), InspIRCd::FloodQuitUser(), FullConnect(), cmd_userip::Handle(), cmd_title::Handle(), cmd_webirc::Handle(), cmd_zline::Handle(), cmd_oper::Handle(), cmd_kline::Handle(), cmd_gline::Handle(), cmd_eline::Handle(), IdentRequestSocket::IdentRequestSocket(), TreeSocket::IntroduceClient(), chanrec::IsBanned(), MakeHostIP(), XLineManager::matches_exception(), XLineManager::matches_gline(), XLineManager::matches_kline(), ModuleBanException::OnCheckBan(), ModuleInviteException::OnCheckInvite(), UserResolver::OnError(), UserResolver::OnLookupComplete(), DNSBLResolver::OnLookupComplete(), CloakUser::OnModeChange(), ModuleOperSSLCert::OnPreCommand(), FilterBase::OnPreCommand(), ModuleInviteException::OnRequest(), ModuleBanException::OnRequest(), ModuleSpanningTree::OnUserConnect(), ModuleModesOnConnect::OnUserConnect(), ModuleDNSBL::OnUserRegister(), ModuleCgiIRC::OnUserRegister(), ModuleSQLOper::OperUser(), ModuleCgiIRC::Recheck(), and StartDNSLookup().

01288 {
01289         static char buf[1024];
01290 
01291         if (this->ip == NULL)
01292                 return "";
01293 
01294         switch (this->GetProtocolFamily())
01295         {
01296 #ifdef SUPPORT_IP6LINKS
01297                 case AF_INET6:
01298                 {
01299                         static char temp[1024];
01300 
01301                         sockaddr_in6* sin = (sockaddr_in6*)this->ip;
01302                         inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
01303                         /* IP addresses starting with a : on irc are a Bad Thing (tm) */
01304                         if (*buf == ':')
01305                         {
01306                                 strlcpy(&temp[1], buf, sizeof(temp) - 1);
01307                                 *temp = '0';
01308                                 return temp;
01309                         }
01310                         return buf;
01311                 }
01312                 break;
01313 #endif
01314                 case AF_INET:
01315                 {
01316                         sockaddr_in* sin = (sockaddr_in*)this->ip;
01317                         inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
01318                         return buf;
01319                 }
01320                 break;
01321                 default:
01322                 break;
01323         }
01324         return "";
01325 }

const char * userrec::GetOperQuit  ) 
 

Get oper-specific quit message shown only to opers when the user quits.

(overrides any sent by QuitUser)

Definition at line 2006 of file users.cpp.

References operquitmsg.

02007 {
02008         return operquitmsg.c_str();
02009 }

int userrec::GetPort  ) 
 

Get port number from sockaddr.

Returns:
The port number of this user.

Definition at line 1251 of file users.cpp.

References ip.

Referenced by CullList::Apply(), ModuleCgiIRC::CheckIdent(), cmd_check::Handle(), ModuleSSLGnuTLS::OnCleanup(), CGIResolver::OnLookupComplete(), ModuleHostChange::OnUserConnect(), ModuleCgiIRC::OnUserConnect(), InspIRCd::ProcessUser(), and cmd_who::whomatch().

01252 {
01253         if (this->ip == NULL)
01254                 return 0;
01255 
01256         switch (this->GetProtocolFamily())
01257         {
01258 #ifdef SUPPORT_IP6LINKS
01259                 case AF_INET6:
01260                 {
01261                         sockaddr_in6* sin = (sockaddr_in6*)this->ip;
01262                         return sin->sin6_port;
01263                 }
01264                 break;
01265 #endif
01266                 case AF_INET:
01267                 {
01268                         sockaddr_in* sin = (sockaddr_in*)this->ip;
01269                         return sin->sin_port;
01270                 }
01271                 break;
01272                 default:
01273                 break;
01274         }
01275         return 0;
01276 }

int userrec::GetProtocolFamily  ) 
 

Get protocol family from sockaddr.

Returns:
The protocol family of this user, either AF_INET or AF_INET6

Definition at line 1278 of file users.cpp.

References ip.

Referenced by ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), CGIResolver::OnLookupComplete(), CloakUser::OnModeChange(), and ModuleCgiIRC::OnUserConnect().

01279 {
01280         if (this->ip == NULL)
01281                 return 0;
01282 
01283         sockaddr_in* sin = (sockaddr_in*)this->ip;
01284         return sin->sin_family;
01285 }

const char * userrec::GetWriteError  ) 
 

Returns the write error which last occured on this connection or an empty string if none occured.

Returns:
The error string which has occured for this user

Definition at line 798 of file users.cpp.

References WriteError.

Referenced by CullList::Apply(), and HandleEvent().

00799 {
00800         return this->WriteError.c_str();
00801 }

unsigned long userrec::GlobalCloneCount  ) 
 

Return the number of global clones of this user.

Returns:
The global clone count of this user

Definition at line 992 of file users.cpp.

References InspIRCd::global_clones, and ServerInstance.

Referenced by CheckClass().

00993 {
00994         clonemap::iterator x = ServerInstance->global_clones.find(this->GetIPString());
00995         if (x != ServerInstance->global_clones.end())
00996                 return x->second;
00997         else
00998                 return 0;
00999 }

void userrec::HandleEvent EventType  et,
int  errornum = 0
[virtual]
 

Handle socket event.

From EventHandler class.

Parameters:
et Event type
errornum Error number for EVENT_ERROR events

Implements EventHandler.

Definition at line 1963 of file users.cpp.

References DEBUG, EVENT_ERROR, EVENT_READ, EVENT_WRITE, FlushWriteBuf(), EventHandler::GetFd(), SocketEngine::GetRef(), GetWriteError(), InspIRCd::Log(), InspIRCd::ProcessUser(), QuitUser(), InspIRCd::SE, ServerInstance, SetWriteError(), and WriteError.

01964 {
01965         /* WARNING: May delete this user! */
01966         int thisfd = this->GetFd();
01967         
01968         try
01969         {
01970                 switch (et)
01971                 {
01972                         case EVENT_READ:
01973                                 if (this->quitting)
01974                                         return; // we just don't care anymore
01975                                 ServerInstance->ProcessUser(this);
01976                         break;
01977                         case EVENT_WRITE:
01978                                 this->FlushWriteBuf();
01979                         break;
01980                         case EVENT_ERROR:
01982                                 this->SetWriteError(errornum ? strerror(errornum) : "EOF from client");
01983                         break;
01984                 }
01985         }
01986         catch (...)
01987         {
01988                 ServerInstance->Log(DEBUG,"Exception in userrec::HandleEvent intercepted");
01989         }
01990 
01991         /* If the user has raised an error whilst being processed, quit them now we're safe to */
01992         if ((ServerInstance->SE->GetRef(thisfd) == this))
01993         {
01994                 if (!WriteError.empty())
01995                 {
01996                         userrec::QuitUser(ServerInstance, this, GetWriteError());
01997                 }
01998         }
01999 }

bool userrec::HasPermission const std::string command  ) 
 

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.

Parameters:
command A command (should be all CAPS)
Returns:
True if this user can execute the command

Definition at line 554 of file users.cpp.

References InspIRCd::Config, IS_LOCAL, IS_OPER, ServerConfig::operclass, ServerConfig::opertypes, and ServerInstance.

Referenced by CommandParser::CallHandler(), CommandParser::IsValidCommand(), ModuleOperLog::OnPreCommand(), and CommandParser::ProcessCommand().

00555 {
00556         char* mycmd;
00557         char* savept;
00558         char* savept2;
00559 
00560         /*
00561          * users on remote servers can completely bypass all permissions based checks.
00562          * This prevents desyncs when one server has different type/class tags to another.
00563          * That having been said, this does open things up to the possibility of source changes
00564          * allowing remote kills, etc - but if they have access to the src, they most likely have
00565          * access to the conf - so it's an end to a means either way.
00566          */
00567         if (!IS_LOCAL(this))
00568                 return true;
00569 
00570         // are they even an oper at all?
00571         if (IS_OPER(this))
00572         {
00573                 opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
00574                 if (iter_opertype != ServerInstance->Config->opertypes.end())
00575                 {
00576                         char* Classes = strdup(iter_opertype->second);
00577                         char* myclass = strtok_r(Classes," ",&savept);
00578                         while (myclass)
00579                         {
00580                                 operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
00581                                 if (iter_operclass != ServerInstance->Config->operclass.end())
00582                                 {
00583                                         char* CommandList = strdup(iter_operclass->second);
00584                                         mycmd = strtok_r(CommandList," ",&savept2);
00585                                         while (mycmd)
00586                                         {
00587                                                 if ((!strcasecmp(mycmd,command.c_str())) || (*mycmd == '*'))
00588                                                 {
00589                                                         free(Classes);
00590                                                         free(CommandList);
00591                                                         return true;
00592                                                 }
00593                                                 mycmd = strtok_r(NULL," ",&savept2);
00594                                         }
00595                                         free(CommandList);
00596                                 }
00597                                 myclass = strtok_r(NULL," ",&savept);
00598                         }
00599                         free(Classes);
00600                 }
00601         }
00602         return false;
00603 }

void userrec::InvalidateCache  ) 
 

This clears any cached results that are used for GetFullRealHost() etc.

The results of these calls are cached as generating them can be generally expensive.

Definition at line 1171 of file users.cpp.

References cached_fullhost, cached_fullrealhost, cached_hostip, and cached_makehost.

Referenced by ChangeDisplayedHost(), ChangeIdent(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), ForceNickChange(), cmd_nick::Handle(), UserResolver::OnLookupComplete(), CGIResolver::OnLookupComplete(), ModuleCgiIRC::OnUserConnect(), and ~userrec().

01172 {
01173         /* Invalidate cache */
01174         if (cached_fullhost)
01175                 free(cached_fullhost);
01176         if (cached_hostip)
01177                 free(cached_hostip);
01178         if (cached_makehost)
01179                 free(cached_makehost);
01180         if (cached_fullrealhost)
01181                 free(cached_fullrealhost);
01182         cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
01183 }

void userrec::InviteTo const irc::string channel  )  [virtual]
 

Adds a channel to a users invite list (invites them to a channel).

Parameters:
channel A channel name to add

Definition at line 530 of file users.cpp.

References invites.

Referenced by cmd_invite::Handle().

00531 {
00532         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
00533         {
00534                 if (channel == *i)
00535                 {
00536                         return;
00537                 }
00538         }
00539         invites.push_back(channel);
00540 }

bool userrec::IsInvited const irc::string channel  )  [virtual]
 

Returns true if a user is invited to a channel.

Parameters:
channel A channel name to look up
Returns:
True if the user is invited to the given channel

Definition at line 513 of file users.cpp.

References invites.

Referenced by cmd_uninvite::Handle(), chanrec::JoinUser(), and ModuleOverride::OnUserPreJoin().

00514 {
00515         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
00516         {
00517                 if (channel == *i)
00518                 {
00519                         return true;
00520                 }
00521         }
00522         return false;
00523 }

bool userrec::IsModeSet unsigned char  m  ) 
 

Returns true if a specific mode is set.

Parameters:
m The user mode
Returns:
True if the mode is set

Definition at line 287 of file users.cpp.

References modes.

Referenced by InvisibleDeOper::BeforeMode(), CommandParser::CallHandler(), cmd_who::Handle(), cmd_oper::Handle(), CommandParser::IsValidCommand(), ModeHandler::ModeSet(), UserStripColor::OnModeChange(), SeeWhois::OnModeChange(), AUser_R::OnModeChange(), User_R::OnModeChange(), User_r::OnModeChange(), InvisibleMode::OnModeChange(), HideOper::OnModeChange(), HideChans::OnModeChange(), Helpop::OnModeChange(), User_d::OnModeChange(), PrivacyMode::OnModeChange(), CloakUser::OnModeChange(), CensorUser::OnModeChange(), BotMode::OnModeChange(), ModuleInvisible::OnUserJoin(), ModuleInvisible::OnUserPart(), ModuleServices::OnUserPostNick(), ModuleServices::OnUserPreJoin(), ModuleRegOnlyCreate::OnUserPreJoin(), ModuleStripColor::OnUserPreMessage(), ModuleServices::OnUserPreMessage(), ModulePrivacyMode::OnUserPreMessage(), ModuleInvisible::OnUserPreNotice(), ModuleInvisible::OnUserQuit(), ModuleShowwhois::OnWhois(), ModuleServices::OnWhois(), ModuleHelpop::OnWhois(), ModuleBotMode::OnWhois(), ModuleHideOper::OnWhoisLine(), ModuleHideChans::OnWhoisLine(), CommandParser::ProcessCommand(), ModeHandler::RemoveMode(), cmd_who::whomatch(), InspIRCd::WriteMode(), InspIRCd::WriteOpers(), SnomaskManager::WriteToSnoMask(), and WriteWallOps().

00288 {
00289         return (modes[m-65]);
00290 }

bool userrec::IsNoticeMaskSet unsigned char  sm  ) 
 

Returns true if a notice mask is set.

Parameters:
sm A notice mask character to check
Returns:
True if the notice mask is set

Definition at line 260 of file users.cpp.

References snomasks.

Referenced by ProcessNoticeMasks(), and SnomaskManager::WriteToSnoMask().

00261 {
00262         return (snomasks[sm-65]);
00263 }

unsigned long userrec::LocalCloneCount  ) 
 

Return the number of local clones of this user.

Returns:
The local clone count of this user

Definition at line 1001 of file users.cpp.

References InspIRCd::local_clones, and ServerInstance.

Referenced by CheckClass().

01002 {
01003         clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
01004         if (x != ServerInstance->local_clones.end())
01005                 return x->second;
01006         else
01007                 return 0;
01008 }

char * userrec::MakeHost  ) 
 

Creates a usermask with real host.

Takes a buffer to use and fills the given buffer with the hostmask in the format user

Returns:
the usermask in the format user

Definition at line 393 of file users.cpp.

References cached_makehost, connection::host, ident, and MAXBUF.

Referenced by ModuleSecureList::OnPreCommand(), and ModuleHostChange::OnUserConnect().

00394 {
00395         if (this->cached_makehost)
00396                 return this->cached_makehost;
00397 
00398         char nhost[MAXBUF];
00399         /* This is much faster than snprintf */
00400         char* t = nhost;
00401         for(char* n = ident; *n; n++)
00402                 *t++ = *n;
00403         *t++ = '@';
00404         for(char* n = host; *n; n++)
00405                 *t++ = *n;
00406         *t = 0;
00407 
00408         this->cached_makehost = strdup(nhost);
00409 
00410         return this->cached_makehost;
00411 }

char * userrec::MakeHostIP  ) 
 

Creates a usermask with real ip.

Takes a buffer to use and fills the given buffer with the ipmask in the format user

Returns:
the usermask in the format user

Definition at line 413 of file users.cpp.

References cached_hostip, GetIPString(), ident, and MAXBUF.

Referenced by FilterBase::OnPreCommand(), ModuleAntiBear::OnPreCommand(), ModuleHostChange::OnUserConnect(), ModuleBanRedirect::OnUserPreJoin(), and FilterBase::OnUserPreNotice().

00414 {
00415         if (this->cached_hostip)
00416                 return this->cached_hostip;
00417 
00418         char ihost[MAXBUF];
00419         /* This is much faster than snprintf */
00420         char* t = ihost;
00421         for(char* n = ident; *n; n++)
00422                 *t++ = *n;
00423         *t++ = '@';
00424         for(const char* n = this->GetIPString(); *n; n++)
00425                 *t++ = *n;
00426         *t = 0;
00427 
00428         this->cached_hostip = strdup(ihost);
00429 
00430         return this->cached_hostip;
00431 }

char * userrec::MakeWildHost  ) 
 

Creates a wildcard host.

Takes a buffer to use and fills the given buffer with the host in the format *!*

Returns:
The wildcarded hostname in *!* form

Definition at line 464 of file users.cpp.

References dhost, and MAXBUF.

00465 {
00466         static char nresult[MAXBUF];
00467         char* t = nresult;
00468         *t++ = '*';     *t++ = '!';
00469         *t++ = '*';     *t++ = '@';
00470         for(char* n = dhost; *n; n++)
00471                 *t++ = *n;
00472         *t = 0;
00473         return nresult;
00474 }

void userrec::Oper const std::string opertype  ) 
 

Oper up the user using the given opertype.

This will also give the +o usermode.

Parameters:
opertype The oper type to oper as

Definition at line 803 of file users.cpp.

References InspIRCd::all_opers, DEBUG, DEFAULT, FOREACH_MOD, I_OnOper, I_OnPostOper, InspIRCd::Log(), modes, NICKMAX, ServerInstance, strlcpy(), UM_OPERATOR, and WriteServ().

Referenced by cmd_oper::Handle(), and ModuleSQLOper::OperUser().

00804 {
00805         try
00806         {
00807                 this->modes[UM_OPERATOR] = 1;
00808                 this->WriteServ("MODE %s :+o", this->nick);
00809                 FOREACH_MOD(I_OnOper, OnOper(this, opertype));
00810                 ServerInstance->Log(DEFAULT,"OPER: %s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str());
00811                 strlcpy(this->oper, opertype.c_str(), NICKMAX - 1);
00812                 ServerInstance->all_opers.push_back(this);
00813                 FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype));
00814         }
00815 
00816         catch (...)
00817         {
00818                 ServerInstance->Log(DEBUG,"Exception in userrec::Oper()");
00819         }
00820 }

std::string userrec::ProcessNoticeMasks const char *  sm  ) 
 

Process a snomask modifier string, e.g.

+abc-de

Parameters:
sm A sequence of notice mask characters
Returns:
The cleaned mode sequence which can be output, e.g. in the above example if masks c and e are not valid, this function will return +ab-d

Definition at line 82 of file users.cpp.

References SnomaskManager::IsEnabled(), IsNoticeMaskSet(), ServerInstance, SetNoticeMask(), and InspIRCd::SNO.

00083 {
00084         bool adding = true, oldadding = false;
00085         const char *c = sm;
00086         std::string output;
00087 
00088         while (c && *c)
00089         {
00090                 switch (*c)
00091                 {
00092                         case '+':
00093                                 adding = true;
00094                         break;
00095                         case '-':
00096                                 adding = false;
00097                         break;
00098                         case '*':
00099                                 for (unsigned char d = 'A'; d <= 'z'; d++)
00100                                 {
00101                                         if (ServerInstance->SNO->IsEnabled(d))
00102                                         {
00103                                                 if ((!IsNoticeMaskSet(d) && adding) || (IsNoticeMaskSet(d) && !adding))
00104                                                 {
00105                                                         if ((oldadding != adding) || (!output.length()))
00106                                                                 output += (adding ? '+' : '-');
00107 
00108                                                         this->SetNoticeMask(d, adding);
00109 
00110                                                         output += d;
00111                                                 }
00112                                         }
00113                                         oldadding = adding;
00114                                 }
00115                         break;
00116                         default:
00117                                 if ((*c >= 'A') && (*c <= 'z') && (ServerInstance->SNO->IsEnabled(*c)))
00118                                 {
00119                                         if ((!IsNoticeMaskSet(*c) && adding) || (IsNoticeMaskSet(*c) && !adding))
00120                                         {
00121                                                 if ((oldadding != adding) || (!output.length()))
00122                                                         output += (adding ? '+' : '-');
00123 
00124                                                 this->SetNoticeMask(*c, adding);
00125 
00126                                                 output += *c;
00127                                         }
00128                                 }
00129                                 oldadding = adding;
00130                         break;
00131                 }
00132 
00133                 *c++;
00134         }
00135 
00136         return output;
00137 }

void userrec::PurgeEmptyChannels  ) 
 

Remove this user from all channels they are on, and delete any that are now empty.

This is used by QUIT, and will not send part messages!

Definition at line 1895 of file users.cpp.

References InspIRCd::chanlist, chans, DEBUG, DELETE(), FOREACH_MOD, I_OnChannelDelete, InspIRCd::Log(), chanrec::name, ServerInstance, and UnOper().

Referenced by CullList::Apply().

01896 {
01897         std::vector<chanrec*> to_delete;
01898 
01899         // firstly decrement the count on each channel
01900         for (UCListIter f = this->chans.begin(); f != this->chans.end(); f++)
01901         {
01902                 f->first->RemoveAllPrefixes(this);
01903                 if (f->first->DelUser(this) == 0)
01904                 {
01905                         /* No users left in here, mark it for deletion */
01906                         try
01907                         {
01908                                 to_delete.push_back(f->first);
01909                         }
01910                         catch (...)
01911                         {
01912                                 ServerInstance->Log(DEBUG,"Exception in userrec::PurgeEmptyChannels to_delete.push_back()");
01913                         }
01914                 }
01915         }
01916 
01917         for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
01918         {
01919                 chanrec* thischan = *n;
01920                 chan_hash::iterator i2 = ServerInstance->chanlist->find(thischan->name);
01921                 if (i2 != ServerInstance->chanlist->end())
01922                 {
01923                         FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
01924                         DELETE(i2->second);
01925                         ServerInstance->chanlist->erase(i2);
01926                         this->chans.erase(*n);
01927                 }
01928         }
01929 
01930         this->UnOper();
01931 }

void userrec::QuitUser InspIRCd Instance,
userrec user,
const std::string r,
const char *  oreason = ""
[static]
 

Disconnect a user gracefully.

Parameters:
user The user to remove
r The quit reason to show to normal users
oreason The quit reason to show to opers
Returns:
Although this function has no return type, on exit the user provided will no longer exist.

Definition at line 843 of file users.cpp.

References CullList::AddItem(), InspIRCd::GlobalCulls, connection::host, ident, and Write().

Referenced by AddClient(), XLineManager::apply_lines(), CheckClass(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), InspIRCd::DoBackgroundUserStuff(), TreeSocket::ForceNick(), FullConnect(), cmd_saquit::Handle(), cmd_nicklock::Handle(), cmd_jumpserver::Handle(), cmd_close::Handle(), cmd_quit::Handle(), cmd_kill::Handle(), HandleEvent(), TreeSocket::IntroduceClient(), ModuleSSLOpenSSL::OnCleanup(), ModuleSSLGnuTLS::OnCleanup(), DNSBLResolver::OnLookupComplete(), ModuleWaitPong::OnPreCommand(), ModuleBlockAmsg::OnPreCommand(), ModuleSQLAuth::OnRequest(), ModuleCgiIRC::OnUserConnect(), FilterBase::OnUserPreNotice(), ModuleSQLAuth::OnUserRegister(), ModuleLockserv::OnUserRegister(), ModuleLDAPAuth::OnUserRegister(), ModuleJumpServer::OnUserRegister(), ModuleConnFlood::OnUserRegister(), TreeSocket::ProcessLine(), TreeServer::QuitUsers(), ModuleCgiIRC::Recheck(), and TreeSocket::RemoteKill().

00844 {
00845         user->Write("ERROR :Closing link (%s@%s) [%s]", user->ident, user->host, *operreason ? operreason : quitreason.c_str());
00846         Instance->GlobalCulls.AddItem(user, quitreason.c_str(), operreason);
00847 }

int userrec::ReadData void *  buffer,
size_t  size
 

Calls read() to read some data for this user using their fd.

Parameters:
buffer The buffer to read into
size The size of data to read
Returns:
The number of bytes read, or -1 if an error occured.

Definition at line 476 of file users.cpp.

References IS_LOCAL.

Referenced by ModuleXMLSocket::OnRawSocketRead(), and InspIRCd::ProcessUser().

00477 {
00478         if (IS_LOCAL(this))
00479         {
00480 #ifndef WIN32
00481                 return read(this->fd, buffer, size);
00482 #else
00483                 return recv(this->fd, (char*)buffer, size, 0);
00484 #endif
00485         }
00486         else
00487                 return 0;
00488 }

void userrec::RemoveCloneCounts  ) 
 

Remove all clone counts from the user, you should use this if you change the user's IP address in userrec::ip after they have registered.

Definition at line 348 of file users.cpp.

References InspIRCd::global_clones, InspIRCd::local_clones, and ServerInstance.

Referenced by ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), ModuleCgiIRC::OnUserConnect(), and ~userrec().

00349 {
00350         clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
00351         if (x != ServerInstance->local_clones.end())
00352         {
00353                 x->second--;
00354                 if (!x->second)
00355                 {
00356                         ServerInstance->local_clones.erase(x);
00357                 }
00358         }
00359         
00360         clonemap::iterator y = ServerInstance->global_clones.find(this->GetIPString());
00361         if (y != ServerInstance->global_clones.end())
00362         {
00363                 y->second--;
00364                 if (!y->second)
00365                 {
00366                         ServerInstance->global_clones.erase(y);
00367                 }
00368         }
00369 }

void userrec::RemoveInvite const irc::string channel  )  [virtual]
 

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.

Parameters:
channel The channel to remove the invite to

Definition at line 542 of file users.cpp.

References invites.

Referenced by cmd_uninvite::Handle(), and chanrec::JoinUser().

00543 {
00544         for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
00545         {
00546                 if (channel == *i)
00547                 {
00548                         invites.erase(i);
00549                         return;
00550                 }
00551         }
00552 }

void userrec::SendAll const char *  command,
char *  text,
  ...
 

Send a command to all local users from this user The command given must be able to send text with the first parameter as a servermask (e.g.

$*), so basically you should use PRIVMSG or NOTICE.

Parameters:
command the command to send
text The text format string to send
... Format arguments

Definition at line 1779 of file users.cpp.

References InspIRCd::local_users, MAXBUF, and ServerInstance.

Referenced by cmd_privmsg::Handle(), and cmd_notice::Handle().

01780 {
01781         char textbuffer[MAXBUF];
01782         char formatbuffer[MAXBUF];
01783         va_list argsPtr;
01784 
01785         va_start(argsPtr, text);
01786         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01787         va_end(argsPtr);
01788 
01789         snprintf(formatbuffer,MAXBUF,":%s %s $* :%s", this->GetFullHost(), command, textbuffer);
01790         std::string fmt = formatbuffer;
01791 
01792         for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
01793         {
01794                 (*i)->Write(fmt);
01795         }
01796 }

void userrec::SetMode unsigned char  m,
bool  value
 

Set a specific usermode to on or off.

Parameters:
m The user mode
value On or off setting of the mode

Definition at line 292 of file users.cpp.

References modes.

Referenced by UserStripColor::OnModeChange(), SeeWhois::OnModeChange(), AUser_R::OnModeChange(), User_R::OnModeChange(), User_r::OnModeChange(), InvisibleMode::OnModeChange(), HideOper::OnModeChange(), HideChans::OnModeChange(), Helpop::OnModeChange(), User_d::OnModeChange(), PrivacyMode::OnModeChange(), CloakUser::OnModeChange(), CensorUser::OnModeChange(), and BotMode::OnModeChange().

00293 {
00294         modes[m-65] = value;
00295 }

void userrec::SetNoticeMask unsigned char  sm,
bool  value
 

Changed a specific notice mask value.

Parameters:
sm The server notice mask to change
value An on/off value for this mask

Definition at line 265 of file users.cpp.

References snomasks.

Referenced by ProcessNoticeMasks().

00266 {
00267         snomasks[sm-65] = value;
00268 }

void userrec::SetOperQuit const std::string oquit  ) 
 

Set oper-specific quit message shown to opers only when the user quits (overrides any sent by QuitUser).

Definition at line 2001 of file users.cpp.

References operquitmsg.

Referenced by ModuleSpanningTree::OnRemoteKill(), and TreeSocket::OperQuit().

02002 {
02003         operquitmsg = oquit;
02004 }

void userrec::SetSockAddr int  protocol_family,
const char *  ip,
int  port
 

Initialize the clients sockaddr.

Parameters:
protocol_family The protocol family of the IP address, AF_INET or AF_INET6
ip A human-readable IP address for this user matching the protcol_family
port The port number of this user or zero for a remote user

Definition at line 1221 of file users.cpp.

References DEBUG, InspIRCd::Log(), and ServerInstance.

Referenced by AddClient(), ModuleCgiIRC::CheckIdent(), TreeSocket::IntroduceClient(), CGIResolver::OnLookupComplete(), and ModuleCgiIRC::OnUserConnect().

01222 {
01223         switch (protocol_family)
01224         {
01225 #ifdef SUPPORT_IP6LINKS
01226                 case AF_INET6:
01227                 {
01228                         sockaddr_in6* sin = new sockaddr_in6;
01229                         sin->sin6_family = AF_INET6;
01230                         sin->sin6_port = port;
01231                         inet_pton(AF_INET6, ip, &sin->sin6_addr);
01232                         this->ip = (sockaddr*)sin;
01233                 }
01234                 break;
01235 #endif
01236                 case AF_INET:
01237                 {
01238                         sockaddr_in* sin = new sockaddr_in;
01239                         sin->sin_family = AF_INET;
01240                         sin->sin_port = port;
01241                         inet_pton(AF_INET, ip, &sin->sin_addr);
01242                         this->ip = (sockaddr*)sin;
01243                 }
01244                 break;
01245                 default:
01246                         ServerInstance->Log(DEBUG,"Ut oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick);
01247                 break;
01248         }
01249 }

void userrec::SetWriteError const std::string error  ) 
 

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.

Parameters:
error The error string to set.

Definition at line 783 of file users.cpp.

References DEBUG, InspIRCd::Log(), ServerInstance, and WriteError.

Referenced by AddBuffer(), AddWriteBuf(), InspIRCd::FloodQuitUser(), FlushWriteBuf(), HandleEvent(), FilterBase::OnPreCommand(), and InspIRCd::ProcessUser().

00784 {
00785         try
00786         {
00787                 // don't try to set the error twice, its already set take the first string.
00788                 if (this->WriteError.empty())
00789                         this->WriteError = error;
00790         }
00791 
00792         catch (...)
00793         {
00794                 ServerInstance->Log(DEBUG,"Exception in userrec::SetWriteError()");
00795         }
00796 }

bool userrec::SharesChannelWith userrec other  ) 
 

Return true if the user shares at least one channel with another user.

Parameters:
other The other user to compare the channel list against
Returns:
True if the given user shares at least one channel with this user

Definition at line 1680 of file users.cpp.

References chans, REG_ALL, and connection::registered.

Referenced by cmd_who::Handle(), and ModulePrivacyMode::OnUserPreMessage().

01681 {
01682         if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
01683                 return false;
01684 
01685         /* Outer loop */
01686         for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
01687         {
01688                 /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
01689                  * by replacing it with a map::find which *should* be more efficient
01690                  */
01691                 if (i->first->HasUser(other))
01692                         return true;
01693         }
01694         return false;
01695 }

void userrec::ShowMOTD  ) 
 

Show the message of the day to this user.

Definition at line 1933 of file users.cpp.

References InspIRCd::Config, ServerConfig::MOTD, ServerInstance, ServerConfig::ServerName, and WriteServ().

Referenced by FullConnect(), and cmd_motd::Handle().

01934 {
01935         if (!ServerInstance->Config->MOTD.size())
01936         {
01937                 this->WriteServ("422 %s :Message of the day file is missing.",this->nick);
01938                 return;
01939         }
01940         this->WriteServ("375 %s :%s message of the day", this->nick, ServerInstance->Config->ServerName);
01941 
01942         for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
01943                 this->WriteServ("372 %s :- %s",this->nick,i->c_str());
01944 
01945         this->WriteServ("376 %s :End of message of the day.", this->nick);
01946 }

void userrec::ShowRULES  ) 
 

Show the server RULES file to this user.

Definition at line 1948 of file users.cpp.

References InspIRCd::Config, ServerConfig::RULES, ServerInstance, ServerConfig::ServerName, and WriteServ().

Referenced by cmd_rules::Handle().

01949 {
01950         if (!ServerInstance->Config->RULES.size())
01951         {
01952                 this->WriteServ("NOTICE %s :Rules file is missing.",this->nick);
01953                 return;
01954         }
01955         this->WriteServ("NOTICE %s :%s rules",this->nick,ServerInstance->Config->ServerName);
01956 
01957         for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
01958                 this->WriteServ("NOTICE %s :%s",this->nick,i->c_str());
01959 
01960         this->WriteServ("NOTICE %s :End of %s rules.",this->nick,ServerInstance->Config->ServerName);
01961 }

void userrec::SplitChanList userrec dest,
const std::string cl
 

Split the channel list in cl which came from dest, and spool it to this user Used internally by WHOIS.

Parameters:
dest The user the original channel list came from
cl The channel list as a string obtained from userrec::ChannelList()

Definition at line 1824 of file users.cpp.

References InspIRCd::Config, DEBUG, InspIRCd::Log(), nick, prefix, InspIRCd::SendWhoisLine(), ServerInstance, and ServerConfig::ServerName.

01825 {
01826         std::string line;
01827         std::ostringstream prefix;
01828         std::string::size_type start, pos, length;
01829 
01830         try
01831         {
01832                 prefix << this->nick << " " << dest->nick << " :";
01833                 line = prefix.str();
01834                 int namelen = strlen(ServerInstance->Config->ServerName) + 6;
01835 
01836                 for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
01837                 {
01838                         length = (pos == std::string::npos) ? cl.length() : pos;
01839 
01840                         if (line.length() + namelen + length - start > 510)
01841                         {
01842                                 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
01843                                 line = prefix.str();
01844                         }
01845 
01846                         if(pos == std::string::npos)
01847                         {
01848                                 line.append(cl.substr(start, length - start));
01849                                 break;
01850                         }
01851                         else
01852                         {
01853                                 line.append(cl.substr(start, length - start + 1));
01854                         }
01855                 }
01856 
01857                 if (line.length())
01858                 {
01859                         ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
01860                 }
01861         }
01862 
01863         catch (...)
01864         {
01865                 ServerInstance->Log(DEBUG,"Exception in userrec::SplitChanList()");
01866         }
01867 }

void userrec::StartDNSLookup  ) 
 

Starts a DNS lookup of the user's IP.

This will cause two UserResolver classes to be instantiated. When complete, these objects set userrec::dns_done to true.

Definition at line 139 of file users.cpp.

References InspIRCd::AddResolver(), DEBUG, DNS_QUERY_PTR4, DNS_QUERY_PTR6, GetIPString(), CoreException::GetReason(), ip, InspIRCd::Log(), res_reverse, and ServerInstance.

00140 {
00141         try
00142         {
00143                 bool cached;
00144                 const char* ip = this->GetIPString();
00145 
00146                 /* Special case for 4in6 (Have i mentioned i HATE 4in6?) */
00147                 if (!strncmp(ip, "0::ffff:", 8))
00148                         res_reverse = new UserResolver(this->ServerInstance, this, ip + 8, DNS_QUERY_PTR4, cached);
00149                 else
00150                         res_reverse = new UserResolver(this->ServerInstance, this, ip, this->GetProtocolFamily() == AF_INET ? DNS_QUERY_PTR4 : DNS_QUERY_PTR6, cached);
00151 
00152                 this->ServerInstance->AddResolver(res_reverse, cached);
00153         }
00154         catch (CoreException& e)
00155         {
00156                 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
00157         }
00158 }

void userrec::UnOper  ) 
 

Oper down.

This will clear the +o usermode and unset the user's oper type

Definition at line 822 of file users.cpp.

References InspIRCd::all_opers, DEBUG, IS_OPER, InspIRCd::Log(), modes, oper, ServerInstance, and UM_OPERATOR.

Referenced by PurgeEmptyChannels().

00823 {
00824         try
00825         {
00826                 if (IS_OPER(this))
00827                 {
00828                         // unset their oper type (what IS_OPER checks), and remove +o
00829                         *this->oper = 0;
00830                         this->modes[UM_OPERATOR] = 0;
00831                         
00832                         // remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404
00833                         ServerInstance->all_opers.remove(this);
00834                 }
00835         }
00836 
00837         catch (...)
00838         {
00839                 ServerInstance->Log(DEBUG,"Exception in userrec::UnOper()");
00840         }
00841 }

userrec * userrec::UpdateNickHash const char *  New  ) 
 

Change this users hash key to a new string.

You should not call this function directly. It is used by the core to update the users hash entry on a nickchange.

Parameters:
New new user_hash key
Returns:
Pointer to userrec in hash (usually 'this')

Definition at line 1145 of file users.cpp.

References InspIRCd::clientlist, DEBUG, InspIRCd::Log(), and ServerInstance.

Referenced by cmd_nick::Handle().

01146 {
01147         try
01148         {
01149                 //user_hash::iterator newnick;
01150                 user_hash::iterator oldnick = ServerInstance->clientlist->find(this->nick);
01151 
01152                 if (!strcasecmp(this->nick,New))
01153                         return oldnick->second;
01154 
01155                 if (oldnick == ServerInstance->clientlist->end())
01156                         return NULL; /* doesnt exist */
01157 
01158                 userrec* olduser = oldnick->second;
01159                 (*(ServerInstance->clientlist))[New] = olduser;
01160                 ServerInstance->clientlist->erase(oldnick);
01161                 return olduser;
01162         }
01163 
01164         catch (...)
01165         {
01166                 ServerInstance->Log(DEBUG,"Exception in userrec::UpdateNickHash()");
01167                 return NULL;
01168         }
01169 }

void userrec::Write const char *  text,
  ...
 

Write text to this user, appending CR/LF.

Parameters:
text The format string for text to send to the user
... POD-type format arguments

Definition at line 1423 of file users.cpp.

References MAXBUF, and Write().

01424 {
01425         va_list argsPtr;
01426         char textbuffer[MAXBUF];
01427 
01428         va_start(argsPtr, text);
01429         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01430         va_end(argsPtr);
01431 
01432         this->Write(std::string(textbuffer));
01433 }

void userrec::Write std::string  text  ) 
 

Write text to this user, appending CR/LF.

Parameters:
text A std::string to send to the user

Definition at line 1375 of file users.cpp.

References AddWriteBuf(), InspIRCd::Config, DEBUG, ServerConfig::GetIOHook(), CoreException::GetReason(), CoreException::GetSource(), InspIRCd::Log(), MAX_DESCRIPTORS, Module::OnRawSocketWrite(), InspIRCd::SE, ServerInstance, InspIRCd::stats, serverstats::statsSent, and SocketEngine::WantWrite().

Referenced by InspIRCd::DoBackgroundUserStuff(), cmd_alltime::Handle(), cmd_stats::Handle(), cmd_kill::Handle(), ModuleWaitPong::OnUserRegister(), TreeSocket::Push(), QuitUser(), TreeSocket::RemoteKill(), Write(), WriteCommon(), WriteFrom(), and WriteServ().

01376 {
01377 #ifdef WINDOWS
01378         if ((this->fd < 0) || (this->m_internalFd > MAX_DESCRIPTORS))
01379 #else
01380         if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
01381 #endif
01382                 return;
01383 
01384         try
01385         {
01386                 /* ServerInstance->Log(DEBUG,"C[%d] <- %s", this->GetFd(), text.c_str());
01387                  * WARNING: The above debug line is VERY loud, do NOT
01388                  * enable it till we have a good way of filtering it
01389                  * out of the logs (e.g. 1.2 would be good).
01390                  */
01391                 text.append("\r\n");
01392         }
01393         catch (...)
01394         {
01395                 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
01396                 return;
01397         }
01398 
01399         if (ServerInstance->Config->GetIOHook(this->GetPort()))
01400         {
01401                 try
01402                 {
01403                         /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
01404                          * implement their own buffering mechanisms
01405                          */
01406                         ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
01407                 }
01408                 catch (CoreException& modexcept)
01409                 {
01410                         ServerInstance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
01411                 }
01412         }
01413         else
01414         {
01415                 this->AddWriteBuf(text);
01416         }
01417         ServerInstance->stats->statsSent += text.length();
01418         this->ServerInstance->SE->WantWrite(this);
01419 }

void userrec::WriteCommon const char *  text,
  ...
 

Write to all users that can see this user (including this user in the list), appending CR/LF.

Parameters:
text The format string for text to send to the users
... POD-type format arguments

Definition at line 1504 of file users.cpp.

References MAXBUF, REG_ALL, and WriteCommon().

01505 {
01506         char textbuffer[MAXBUF];
01507         va_list argsPtr;
01508 
01509         if (this->registered != REG_ALL)
01510                 return;
01511 
01512         va_start(argsPtr, text);
01513         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01514         va_end(argsPtr);
01515 
01516         this->WriteCommon(std::string(textbuffer));
01517 }

void userrec::WriteCommon const std::string text  ) 
 

Write to all users that can see this user (including this user in the list), appending CR/LF.

Parameters:
text A std::string to send to the users

Definition at line 1519 of file users.cpp.

References already_sent, chans, DEBUG, IS_LOCAL, InspIRCd::Log(), MAXBUF, REG_ALL, ServerInstance, uniq_id, and Write().

Referenced by cmd_nick::Handle(), and WriteCommon().

01520 {
01521         try
01522         {
01523                 bool sent_to_at_least_one = false;
01524                 char tb[MAXBUF];
01525 
01526                 if (this->registered != REG_ALL)
01527                         return;
01528 
01529                 uniq_id++;
01530 
01531                 /* We dont want to be doing this n times, just once */
01532                 snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
01533                 std::string out = tb;
01534 
01535                 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
01536                 {
01537                         CUList* ulist = v->first->GetUsers();
01538                         for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
01539                         {
01540                                 if ((IS_LOCAL(i->first)) && (already_sent[i->first->fd] != uniq_id))
01541                                 {
01542                                         already_sent[i->first->fd] = uniq_id;
01543                                         i->first->Write(out);
01544                                         sent_to_at_least_one = true;
01545                                 }
01546                         }
01547                 }
01548 
01549                 /*
01550                  * if the user was not in any channels, no users will receive the text. Make sure the user
01551                  * receives their OWN message for WriteCommon
01552                  */
01553                 if (!sent_to_at_least_one)
01554                 {
01555                         this->Write(std::string(tb));
01556                 }
01557         }
01558 
01559         catch (...)
01560         {
01561                 ServerInstance->Log(DEBUG,"Exception in userrec::WriteCommon()");
01562         }
01563 }

void userrec::WriteCommonExcept const std::string text  ) 
 

Write to all users that can see this user (not including this user in the list), appending CR/LF.

Parameters:
text A std::string to send to the users

Definition at line 1613 of file users.cpp.

References already_sent, chans, IS_LOCAL, MAXBUF, REG_ALL, and uniq_id.

01614 {
01615         char tb1[MAXBUF];
01616         std::string out1;
01617 
01618         if (this->registered != REG_ALL)
01619                 return;
01620 
01621         uniq_id++;
01622         snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
01623         out1 = tb1;
01624 
01625         for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
01626         {
01627                 CUList *ulist = v->first->GetUsers();
01628                 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
01629                 {
01630                         if (this != i->first)
01631                         {
01632                                 if ((IS_LOCAL(i->first)) && (already_sent[i->first->fd] != uniq_id))
01633                                 {
01634                                         already_sent[i->first->fd] = uniq_id;
01635                                         i->first->Write(out1);
01636                                 }
01637                         }
01638                 }
01639         }
01640 
01641 }

void userrec::WriteCommonExcept const char *  text,
  ...
 

Write to all users that can see this user (not including this user in the list), appending CR/LF.

Parameters:
text The format string for text to send to the users
... POD-type format arguments

Definition at line 1570 of file users.cpp.

References MAXBUF.

Referenced by ChangeDisplayedHost(), and ChangeIdent().

01571 {
01572         char textbuffer[MAXBUF];
01573         va_list argsPtr;
01574 
01575         va_start(argsPtr, text);
01576         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01577         va_end(argsPtr);
01578 
01579         this->WriteCommonExcept(std::string(textbuffer));
01580 }

void userrec::WriteCommonQuit const std::string normal_text,
const std::string oper_text
 

Write a quit message to all common users, as in userrec::WriteCommonExcept but with a specific quit message for opers only.

Parameters:
normal_text Normal user quit message
oper_text Oper only quit message

Definition at line 1582 of file users.cpp.

References already_sent, chans, IS_LOCAL, IS_OPER, MAXBUF, REG_ALL, and uniq_id.

Referenced by CullList::Apply().

01583 {
01584         char tb1[MAXBUF];
01585         char tb2[MAXBUF];
01586 
01587         if (this->registered != REG_ALL)
01588                 return;
01589 
01590         uniq_id++;
01591         snprintf(tb1,MAXBUF,":%s QUIT :%s",this->GetFullHost(),normal_text.c_str());
01592         snprintf(tb2,MAXBUF,":%s QUIT :%s",this->GetFullHost(),oper_text.c_str());
01593         std::string out1 = tb1;
01594         std::string out2 = tb2;
01595 
01596         for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
01597         {
01598                 CUList *ulist = v->first->GetUsers();
01599                 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
01600                 {
01601                         if (this != i->first)
01602                         {
01603                                 if ((IS_LOCAL(i->first)) && (already_sent[i->first->fd] != uniq_id))
01604                                 {
01605                                         already_sent[i->first->fd] = uniq_id;
01606                                         i->first->Write(IS_OPER(i->first) ? out2 : out1);
01607                                 }
01608                         }
01609                 }
01610         }
01611 }

void userrec::WriteFrom userrec user,
const char *  text,
  ...
 

Write text to this user, appending CR/LF and prepending :nick!user of the user provided in the first parameter.

Parameters:
user The user to prepend the :nick!user of
text The format string for text to send to the user
... POD-type format arguments

Definition at line 1471 of file users.cpp.

References MAXBUF, and WriteFrom().

01472 {
01473         va_list argsPtr;
01474         char textbuffer[MAXBUF];
01475 
01476         va_start(argsPtr, text);
01477         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01478         va_end(argsPtr);
01479 
01480         this->WriteFrom(user, std::string(textbuffer));
01481 }

void userrec::WriteFrom userrec user,
const std::string text
 

Write text to this user, appending CR/LF and prepending :nick!user of the user provided in the first parameter.

Parameters:
user The user to prepend the :nick!user of
text A std::string to send to the user

Definition at line 1459 of file users.cpp.

References GetFullHost(), MAXBUF, and Write().

Referenced by cmd_invite::Handle(), ModuleAuditorium::OnUserJoin(), ModuleAuditorium::OnUserKick(), ModuleAuditorium::OnUserPart(), WriteFrom(), and WriteTo().

01460 {
01461         char tb[MAXBUF];
01462 
01463         snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
01464 
01465         this->Write(std::string(tb));
01466 }

void userrec::WriteServ const char *  text,
  ...
 

Write text to this user, appending CR/LF and prepending :server.name.

Parameters:
text The format string for text to send to the user
... POD-type format arguments

Definition at line 1446 of file users.cpp.

References MAXBUF, and WriteServ().

01447 {
01448         va_list argsPtr;
01449         char textbuffer[MAXBUF];
01450 
01451         va_start(argsPtr, text);
01452         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01453         va_end(argsPtr);
01454 
01455         this->WriteServ(std::string(textbuffer));
01456 }

void userrec::WriteServ const std::string text  ) 
 

Write text to this user, appending CR/LF and prepending :server.name.

Parameters:
text A std::string to send to the user

Definition at line 1435 of file users.cpp.

References InspIRCd::Config, MAXBUF, ServerInstance, ServerConfig::ServerName, and Write().

Referenced by cmd_watch::add_watch(), AddClient(), XLineManager::apply_lines(), BanRedirect::BeforeMode(), ChangeDisplayedHost(), ModeParser::DisplayCurrentModes(), cmd_dccallow::DisplayDCCAllowList(), ListModeBase::DisplayEmptyList(), cmd_dccallow::DisplayHelp(), ListModeBase::DisplayList(), FounderProtectBase::DisplayList(), InspIRCd::DoBackgroundUserStuff(), InspIRCd::DumpText(), ModuleDCCAllow::Expire(), FullConnect(), cmd_rsquit::Handle(), cmd_rconnect::Handle(), cmd_watch::Handle(), cmd_vhost::Handle(), cmd_userip::Handle(), cmd_uninvite::Handle(), cmd_tline::Handle(), cmd_tban::Handle(), cmd_dalinfo::Handle(), cmd_taxonomy::Handle(), cmd_swhois::Handle(), cmd_svshold::Handle(), cmd_sslinfo::Handle(), cmd_fingerprint::Handle(), cmd_spynames::Handle(), cmd_spylist::Handle(), cmd_silence::Handle(), cmd_setname::Handle(), cmd_setidle::Handle(), cmd_setident::Handle(), cmd_sethost::Handle(), cmd_saquit::Handle(), cmd_sapart::Handle(), cmd_sanick::Handle(), cmd_samode::Handle(), cmd_sajoin::Handle(), RemoveBase::Handle(), cmd_randquote::Handle(), cmd_nickunlock::Handle(), cmd_nicklock::Handle(), cmd_unlockserv::Handle(), cmd_lockserv::Handle(), cmd_knock::Handle(), cmd_jumpserver::Handle(), cmd_helpop::Handle(), cmd_greloadmodule::Handle(), cmd_gunloadmodule::Handle(), cmd_gloadmodule::Handle(), cmd_filter::Handle(), cmd_dccallow::Handle(), cmd_cycle::Handle(), cmd_title::Handle(), cmd_close::Handle(), cmd_clones::Handle(), cmd_chgname::Handle(), cmd_chgident::Handle(), cmd_chghost::Handle(), cmd_check::Handle(), cmd_cban::Handle(), cmd_reload::Handle(), cmd_zline::Handle(), cmd_whowas::Handle(), cmd_whois::Handle(), cmd_who::Handle(), cmd_version::Handle(), cmd_users::Handle(), cmd_userhost::Handle(), cmd_user::Handle(), cmd_unloadmodule::Handle(), cmd_trace::Handle(), cmd_topic::Handle(), cmd_time::Handle(), cmd_summon::Handle(), cmd_squit::Handle(), cmd_server::Handle(), cmd_reloadmodule::Handle(), cmd_rehash::Handle(), cmd_qline::Handle(), cmd_privmsg::Handle(), cmd_ping::Handle(), cmd_pass::Handle(), cmd_part::Handle(), cmd_oper::Handle(), cmd_notice::Handle(), cmd_nick::Handle(), cmd_names::Handle(), cmd_modules::Handle(), cmd_map::Handle(), cmd_lusers::Handle(), cmd_loadmodule::Handle(), cmd_list::Handle(), cmd_links::Handle(), cmd_kline::Handle(), cmd_kill::Handle(), cmd_kick::Handle(), cmd_join::Handle(), cmd_ison::Handle(), cmd_invite::Handle(), cmd_info::Handle(), cmd_gline::Handle(), cmd_eline::Handle(), cmd_connect::Handle(), cmd_commands::Handle(), cmd_clearcache::Handle(), cmd_away::Handle(), cmd_admin::Handle(), ModuleSpanningTree::HandleAdmin(), ModuleSpanningTree::HandleLinks(), ModuleSafeList::HandleList(), ModuleSpanningTree::HandleLusers(), ModuleSpanningTree::HandleMap(), ModuleSpanningTree::HandleModules(), ModuleSpanningTree::HandleMotd(), ModuleSpanningTree::HandleRemoteWhois(), ModuleSpanningTree::HandleSquit(), ModuleSpanningTree::HandleStats(), ModuleSpanningTree::HandleTime(), ModuleSpanningTree::HandleVersion(), chanrec::JoinUser(), chanrec::KickUser(), TreeSocket::LocalPong(), cmd_mkpasswd::MakeHash(), cmd_rsquit::NoticeUser(), ModuleNoKicks::OnAccessCheck(), ModuleChanProtect::OnAccessCheck(), ModuleSafeList::OnBufferFlushed(), ModuleIdent::OnCheckReady(), UserResolver::OnError(), ModuleOperLevels::OnKill(), UserResolver::OnLookupComplete(), ListModeBase::OnModeChange(), SSLMode::OnModeChange(), User_r::OnModeChange(), Channel_r::OnModeChange(), Redirect::OnModeChange(), NickFlood::OnModeChange(), MsgFlood::OnModeChange(), JoinFlood::OnModeChange(), InvisibleMode::OnModeChange(), User_d::OnModeChange(), AuditoriumMode::OnModeChange(), ModuleChanProtect::OnPostJoin(), ModuleOperSSLCert::OnPreCommand(), ModuleSecureList::OnPreCommand(), FilterBase::OnPreCommand(), ModuleBlockAmsg::OnPreCommand(), ModuleAlias::OnPreCommand(), ModuleHostChange::OnUserConnect(), ModuleAuditorium::OnUserList(), ModuleNoInvite::OnUserPreInvite(), ModuleSSLModes::OnUserPreJoin(), ModuleServicesAccount::OnUserPreJoin(), ModuleServices::OnUserPreJoin(), ModuleRestrictChans::OnUserPreJoin(), ModuleRegOnlyCreate::OnUserPreJoin(), ModuleRedirect::OnUserPreJoin(), ModuleOperChans::OnUserPreJoin(), ModuleKickNoRejoin::OnUserPreJoin(), ModuleJoinFlood::OnUserPreJoin(), ModuleCBan::OnUserPreJoin(), ModuleBanRedirect::OnUserPreJoin(), ModuleServicesAccount::OnUserPreMessage(), ModuleServices::OnUserPreMessage(), ModuleRestrictMsg::OnUserPreMessage(), ModulePrivacyMode::OnUserPreMessage(), ModuleCensor::OnUserPreMessage(), ModuleBlockColour::OnUserPreMessage(), ModuleBlockCAPS::OnUserPreMessage(), ModuleSVSHold::OnUserPreNick(), ModuleNoNickChange::OnUserPreNick(), ModuleNickLock::OnUserPreNick(), ModuleNickFlood::OnUserPreNick(), ModuleNoNotice::OnUserPreNotice(), ModuleNoCTCP::OnUserPreNotice(), ModuleInvisible::OnUserPreNotice(), FilterBase::OnUserPreNotice(), ModuleDCCAllow::OnUserPreNotice(), ModuleJumpServer::OnUserRegister(), ModuleIdent::OnUserRegister(), ModuleWaitPong::OnUserRegister(), ModuleAntiBear::OnUserRegister(), ModuleShowwhois::OnWhois(), Oper(), ModuleSQLOper::OperUser(), ModeParser::Process(), CommandParser::ProcessCommand(), ModuleChanFilter::ProcessMessages(), InspIRCd::ProcessUser(), ModuleTaxonomy::ProtoSendMetaData(), ServerConfig::Read(), ModuleCgiIRC::Recheck(), ModuleSpanningTree::RemoteMessage(), cmd_watch::remove_watch(), ModuleDCCAllow::RemoveNick(), ServerConfig::ReportConfigError(), ModeParser::SanityChecks(), ServerConfig::Send005(), InspIRCd::SendWhoisLine(), InspIRCd::ServerNoticeAll(), InspIRCd::ServerPrivmsgAll(), ModuleSpanningTree::ShowLinks(), ShowMOTD(), ShowOperMOTD(), ShowRULES(), spy_userlist(), ChanFilter::TellAlreadyOnList(), ChanFilter::TellListTooLong(), ChanFilter::TellNotSet(), TreeSocket::Time(), cmd_filter::TooFewParams(), chanrec::UserList(), ChanFilter::ValidateParam(), InspIRCd::WriteMode(), InspIRCd::WriteOpers(), WriteServ(), and SnomaskManager::WriteToSnoMask().

01436 {
01437         char textbuffer[MAXBUF];
01438 
01439         snprintf(textbuffer,MAXBUF,":%s %s",ServerInstance->Config->ServerName,text.c_str());
01440         this->Write(std::string(textbuffer));
01441 }

void userrec::WriteTo userrec dest,
const char *  data,
  ...
 

Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user.

Parameters:
dest The user to route the message to
text The format string for text to send to the user
... POD-type format arguments

Definition at line 1486 of file users.cpp.

References MAXBUF, and WriteTo().

01487 {
01488         char textbuffer[MAXBUF];
01489         va_list argsPtr;
01490 
01491         va_start(argsPtr, data);
01492         vsnprintf(textbuffer, MAXBUF, data, argsPtr);
01493         va_end(argsPtr);
01494 
01495         this->WriteTo(dest, std::string(textbuffer));
01496 }

void userrec::WriteTo userrec dest,
const std::string data
 

Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user.

Parameters:
dest The user to route the message to
text A std::string to send to the user

Definition at line 1498 of file users.cpp.

References WriteFrom().

Referenced by cmd_privmsg::Handle(), cmd_notice::Handle(), cmd_nick::Handle(), ModeParser::Process(), WriteTo(), and WriteWallOps().

01499 {
01500         dest->WriteFrom(this, data);
01501 }

void userrec::WriteWallOps const std::string text  ) 
 

Write a WALLOPS message from this user to all local opers.

If this user is not opered, the function will return without doing anything.

Parameters:
text The text to send in the WALLOPS message

Definition at line 1643 of file users.cpp.

References IsModeSet(), InspIRCd::local_users, ServerInstance, and WriteTo().

01644 {
01645         std::string wallop("WALLOPS :");
01646         wallop.append(text);
01647 
01648         for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
01649         {
01650                 userrec* t = *i;
01651                 if (t->IsModeSet('w'))
01652                         this->WriteTo(t,wallop);
01653         }
01654 }

void userrec::WriteWallOps const char *  text,
  ...
 

Write a WALLOPS message from this user to all local opers.

If this user is not opered, the function will return without doing anything.

Parameters:
text The format string to send in the WALLOPS message
... Format arguments

Definition at line 1656 of file users.cpp.

References MAXBUF.

Referenced by cmd_wallops::Handle().

01657 {
01658         char textbuffer[MAXBUF];
01659         va_list argsPtr;
01660 
01661         va_start(argsPtr, text);
01662         vsnprintf(textbuffer, MAXBUF, text, argsPtr);
01663         va_end(argsPtr);
01664 
01665         this->WriteWallOps(std::string(textbuffer));
01666 }


Member Data Documentation

char userrec::awaymsg[MAXAWAY+1]
 

The user's away message.

If this string is empty, the user is not marked as away.

Definition at line 445 of file users.h.

Referenced by do_whois(), cmd_check::Handle(), cmd_privmsg::Handle(), cmd_away::Handle(), ModuleSpanningTree::OnSetAway(), userrec(), and cmd_who::whomatch().

char* userrec::cached_fullhost [private]
 

Cached nick!ident value using the real hostname.

Definition at line 350 of file users.h.

Referenced by GetFullHost(), InvalidateCache(), and userrec().

char* userrec::cached_fullrealhost [private]
 

Cached nick!ident value using the real hostname.

Definition at line 362 of file users.h.

Referenced by GetFullRealHost(), InvalidateCache(), and userrec().

char* userrec::cached_hostip [private]
 

Cached nick!ident value using the real IP address.

Definition at line 354 of file users.h.

Referenced by InvalidateCache(), MakeHostIP(), and userrec().

char* userrec::cached_makehost [private]
 

Cached nick!ident value using the masked hostname.

Definition at line 358 of file users.h.

Referenced by InvalidateCache(), MakeHost(), and userrec().

unsigned int userrec::ChannelCount [private]
 

Number of channels this user is currently on.

Definition at line 346 of file users.h.

Referenced by userrec().

UserChanList userrec::chans
 

Channels this user is on, and the permissions they have there.

Definition at line 436 of file users.h.

Referenced by ChangeDisplayedHost(), ChangeIdent(), ChannelList(), chanrec::ForceChan(), getlastchanname(), chanrec::GetStatus(), chanrec::GetStatusFlags(), ModeParser::Grant(), chanrec::JoinUser(), chanrec::KickUser(), ModuleBlockAmsg::OnPreCommand(), ModuleRestrictBanned::OnUserPreNick(), ModuleNoNickChange::OnUserPreNick(), ModuleNickFlood::OnUserPreNick(), ModuleInvisible::OnUserQuit(), ModuleHttpStats::OnUserQuit(), ModuleAuditorium::OnUserQuit(), chanrec::PartUser(), PurgeEmptyChannels(), ModeParser::Revoke(), chanrec::ServerKickUser(), SharesChannelWith(), userrec(), WriteCommon(), WriteCommonExcept(), and WriteCommonQuit().

char userrec::dhost[65]
 

The host displayed to non-opers (used for cloaking etc).

This usually matches the value of userrec::host.

Definition at line 412 of file users.h.

Referenced by cmd_watch::add_watch(), AddClient(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), do_whois(), ModuleAlias::DoCommand(), DoStats(), GetFullHost(), cmd_sethost::Handle(), cmd_dccallow::Handle(), cmd_chghost::Handle(), cmd_userhost::Handle(), cmd_die::Handle(), TreeSocket::IntroduceClient(), MakeWildHost(), CGIResolver::OnLookupComplete(), Modulewatch::OnPostConnect(), ModuleSpanningTree::OnUserConnect(), ModuleCgiIRC::OnUserConnect(), Modulewatch::OnUserPostNick(), ModuleDCCAllow::OnUserPreNotice(), Modulewatch::OnUserQuit(), cmd_who::SendWhoLine(), userrec(), cmd_who::whomatch(), and WhoWasGroup::WhoWasGroup().

bool userrec::dns_done
 

True when DNS lookups are completed.

The UserResolver classes res_forward and res_reverse will set this value once they complete.

Definition at line 470 of file users.h.

Referenced by InspIRCd::DoBackgroundUserStuff(), UserResolver::OnError(), UserResolver::OnLookupComplete(), and userrec().

bool userrec::exempt
 

This is true if the user matched an exception when they connected to the ircd.

It isnt valid after this point, and you should not attempt to do anything with it after this point, because the eline might be removed at a later time, and/or no longer be applicable to this user. It is only used to save doing the eline lookup twice (instead we do it once and set this value).

Definition at line 577 of file users.h.

Referenced by AddClient(), FullConnect(), ModuleCgiIRC::Recheck(), and userrec().

int userrec::flood
 

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 451 of file users.h.

Referenced by CheckClass(), InspIRCd::ProcessUser(), and userrec().

char userrec::fullname[MAXGECOS+1]
 

The users full name (GECOS).

Definition at line 416 of file users.h.

Referenced by do_whois(), FullConnect(), cmd_chgname::Handle(), cmd_check::Handle(), cmd_user::Handle(), TreeSocket::IntroduceClient(), ModuleSpanningTree::OnUserConnect(), userrec(), cmd_who::whomatch(), and WhoWasGroup::WhoWasGroup().

char userrec::ident[IDENTMAX+2]
 

The users ident reply.

Two characters are added to the user-defined limit to compensate for the tilde etc.

Definition at line 407 of file users.h.

Referenced by cmd_watch::add_watch(), AddClient(), ModuleSQLAuth::CheckCredentials(), ModuleLDAPAuth::CheckCredentials(), ModuleCgiIRC::CheckIdent(), do_whois(), ModuleAlias::DoCommand(), DoStats(), InspIRCd::FloodQuitUser(), FullConnect(), GetFullHost(), GetFullRealHost(), cmd_userip::Handle(), cmd_setident::Handle(), cmd_dccallow::Handle(), cmd_title::Handle(), cmd_chgident::Handle(), cmd_userhost::Handle(), cmd_user::Handle(), cmd_restart::Handle(), cmd_oper::Handle(), cmd_nick::Handle(), cmd_kill::Handle(), cmd_die::Handle(), TreeSocket::IntroduceClient(), chanrec::IsBanned(), MakeHost(), MakeHostIP(), XLineManager::matches_exception(), XLineManager::matches_gline(), XLineManager::matches_kline(), ModuleBanException::OnCheckBan(), ModuleInviteException::OnCheckInvite(), ModuleIdent::OnCheckReady(), CGIResolver::OnLookupComplete(), Modulewatch::OnPostConnect(), ModuleOperSSLCert::OnPreCommand(), ModuleOperLog::OnPreCommand(), ModuleSQLAuth::OnRequest(), ModuleInviteException::OnRequest(), ModuleBanException::OnRequest(), ModuleSpanningTree::OnStats(), ModuleSpanningTree::OnUserConnect(), ModuleChanCreate::OnUserJoin(), Modulewatch::OnUserPostNick(), ModuleDCCAllow::OnUserPreNotice(), Modulewatch::OnUserQuit(), ModuleIdent::OnUserRegister(), ModuleShowwhois::OnWhois(), ModuleSQLOper::OperUser(), QuitUser(), cmd_who::SendWhoLine(), userrec(), cmd_who::whomatch(), and WhoWasGroup::WhoWasGroup().

InvitedList userrec::invites [private]
 

A list of channels the user has a pending invite to.

Upon INVITE channels are added, and upon JOIN, the channels are removed from this list.

Definition at line 342 of file users.h.

Referenced by GetInviteList(), InviteTo(), IsInvited(), RemoveInvite(), and userrec().

sockaddr* userrec::ip
 

IPV4 or IPV6 ip address.

Use SetSockAddr to set this and GetProtocolFamily/ GetIPString/GetPort to obtain its values.

Definition at line 527 of file users.h.

Referenced by ModuleCgiIRC::CheckPass(), GetIPString(), GetPort(), GetProtocolFamily(), StartDNSLookup(), userrec(), and ~userrec().

int userrec::lines_in
 

Flood counters - lines received.

Definition at line 495 of file users.h.

Referenced by InspIRCd::ProcessUser(), and userrec().

char userrec::modes[64]
 

The user's mode list.

This is NOT a null terminated string! In the 1.1 version of InspIRCd this is an array of values in a similar way to channel modes. A value of 1 in field (modeletter-65) indicates that the mode is set, for example, to work out if mode +s is set, we check the field userrec::modes['s'-65] != 0. The following RFC characters o, w, s, i have constants defined via an enum, such as UM_SERVERNOTICE and UM_OPETATOR.

Definition at line 427 of file users.h.

Referenced by DecrementModes(), FormatModes(), IsModeSet(), ModuleCBan::OnUserPreJoin(), ModuleServicesAccount::OnUserPreMessage(), Oper(), ModuleSQLOper::OperUser(), SetMode(), UnOper(), and userrec().

char userrec::nick[NICKMAX]
 

The users nickname.

An invalid nickname indicates an unregistered connection prior to the NICK command. Use InspIRCd::IsNick() to validate nicknames.

Definition at line 402 of file users.h.

Referenced by cmd_watch::add_watch(), AddClient(), chanrec::AddHalfoppedUser(), chanrec::AddOppedUser(), cmd_whowas::AddToWhoWas(), chanrec::AddUser(), chanrec::AddVoicedUser(), TreeSocket::Admin(), CullList::Apply(), XLineManager::apply_lines(), InvisibleDeOper::BeforeMode(), BanRedirect::BeforeMode(), ModuleSQLAuth::CheckCredentials(), ModuleLDAPAuth::CheckCredentials(), ModuleCgiIRC::CheckIdent(), ModuleCgiIRC::CheckPass(), ModeParser::DisplayCurrentModes(), cmd_dccallow::DisplayDCCAllowList(), ListModeBase::DisplayEmptyList(), cmd_dccallow::DisplayHelp(), ListModeBase::DisplayList(), FounderProtectBase::DisplayList(), do_whois(), ModuleAlias::DoCommand(), DoStats(), ModuleDCCAllow::Expire(), InspIRCd::FloodQuitUser(), chanrec::ForceChan(), TreeSocket::ForceJoin(), FullConnect(), GetFullHost(), GetFullRealHost(), ModeParser::Grant(), cmd_rsquit::Handle(), cmd_rconnect::Handle(), cmd_watch::Handle(), cmd_vhost::Handle(), cmd_userip::Handle(), cmd_uninvite::Handle(), cmd_tline::Handle(), cmd_tban::Handle(), cmd_dalinfo::Handle(), cmd_taxonomy::Handle(), cmd_swhois::Handle(), cmd_svshold::Handle(), cmd_sslinfo::Handle(), cmd_fingerprint::Handle(), cmd_spynames::Handle(), cmd_spylist::Handle(), cmd_silence::Handle(), cmd_setname::Handle(), cmd_setidle::Handle(), cmd_setident::Handle(), cmd_sethost::Handle(), cmd_saquit::Handle(), cmd_sapart::Handle(), cmd_sanick::Handle(), cmd_samode::Handle(), cmd_sajoin::Handle(), RemoveBase::Handle(), cmd_randquote::Handle(), cmd_nickunlock::Handle(), cmd_nicklock::Handle(), cmd_unlockserv::Handle(), cmd_lockserv::Handle(), cmd_knock::Handle(), cmd_jumpserver::Handle(), cmd_helpop::Handle(), cmd_globops::Handle(), cmd_greloadmodule::Handle(), cmd_gunloadmodule::Handle(), cmd_gloadmodule::Handle(), cmd_filter::Handle(), cmd_devoice::Handle(), cmd_dccallow::Handle(), cmd_cycle::Handle(), cmd_title::Handle(), cmd_close::Handle(), cmd_clones::Handle(), cmd_chgname::Handle(), cmd_chgident::Handle(), cmd_chghost::Handle(), cmd_check::Handle(), cmd_webirc::Handle(), cmd_cban::Handle(), cmd_alltime::Handle(), cmd_reload::Handle(), cmd_zline::Handle(), cmd_whowas::Handle(), cmd_whois::Handle(), cmd_who::Handle(), cmd_version::Handle(), cmd_users::Handle(), cmd_userhost::Handle(), cmd_user::Handle(), cmd_unloadmodule::Handle(), cmd_trace::Handle(), cmd_topic::Handle(), cmd_time::Handle(), cmd_summon::Handle(), cmd_squit::Handle(), cmd_server::Handle(), cmd_restart::Handle(), cmd_reloadmodule::Handle(), cmd_rehash::Handle(), cmd_qline::Handle(), cmd_privmsg::Handle(), cmd_pass::Handle(), cmd_part::Handle(), cmd_oper::Handle(), cmd_notice::Handle(), cmd_nick::Handle(), cmd_names::Handle(), cmd_modules::Handle(), cmd_map::Handle(), cmd_lusers::Handle(), cmd_loadmodule::Handle(), cmd_list::Handle(), cmd_links::Handle(), cmd_kline::Handle(), cmd_kill::Handle(), cmd_kick::Handle(), cmd_join::Handle(), cmd_ison::Handle(), cmd_invite::Handle(), cmd_info::Handle(), cmd_gline::Handle(), cmd_eline::Handle(), cmd_die::Handle(), cmd_connect::Handle(), cmd_commands::Handle(), cmd_clearcache::Handle(), cmd_away::Handle(), cmd_admin::Handle(), ModuleSpanningTree::HandleAdmin(), FounderProtectBase::HandleChange(), ModuleSpanningTree::HandleLinks(), ModuleSafeList::HandleList(), ModuleSpanningTree::HandleLusers(), ModuleSpanningTree::HandleMap(), ModuleSpanningTree::HandleModules(), ModuleSpanningTree::HandleMotd(), ModuleSpanningTree::HandleRemoteWhois(), ModuleSpanningTree::HandleSquit(), ModuleSpanningTree::HandleStats(), ModuleSpanningTree::HandleTime(), ModuleSpanningTree::HandleVersion(), InspIRCd::HostMatchesEveryone(), TreeSocket::IntroduceClient(), InspIRCd::IPMatchesEveryone(), chanrec::IsBanned(), chanrec::JoinUser(), chanrec::KickUser(), cmd_mkpasswd::MakeHash(), FounderProtectBase::ModeSet(), ModeParser::ModeString(), TreeSocket::Modules(), TreeSocket::Motd(), InspIRCd::NickMatchesEveryone(), cmd_rsquit::NoticeUser(), ModuleNoKicks::OnAccessCheck(), ModuleChanProtect::OnAccessCheck(), ModuleSafeList::OnBufferFlushed(), ModuleSpanningTree::OnCancelAway(), ModuleSpanningTree::OnChangeHost(), ModuleSpanningTree::OnChangeName(), ModuleBanException::OnCheckBan(), ModuleInviteException::OnCheckInvite(), ModuleIdent::OnCheckReady(), CGIResolver::OnError(), ModuleSQLLog::OnGlobalOper(), ModuleSQLLog::OnKill(), ModuleOperLevels::OnKill(), ModuleSpanningTree::OnLine(), CGIResolver::OnLookupComplete(), ModuleSpanningTree::OnMode(), ListModeBase::OnModeChange(), SSLMode::OnModeChange(), User_r::OnModeChange(), Channel_r::OnModeChange(), Redirect::OnModeChange(), NickFlood::OnModeChange(), MsgFlood::OnModeChange(), JoinFlood::OnModeChange(), InvisibleMode::OnModeChange(), User_d::OnModeChange(), AuditoriumMode::OnModeChange(), ModuleSpanningTree::OnOper(), ModuleSQLLog::OnOper(), ModuleSpanningTree::OnPostCommand(), ModuleSWhois::OnPostCommand(), ModuleOverride::OnPostCommand(), Modulewatch::OnPostConnect(), ModuleChanProtect::OnPostJoin(), ModuleSpanningTree::OnPostLocalTopicChange(), ModuleModesOnOper::OnPostOper(), ModuleOperSSLCert::OnPreCommand(), ModuleSQLLog::OnPreCommand(), ModuleSecureList::OnPreCommand(), ModuleOperLog::OnPreCommand(), FilterBase::OnPreCommand(), ModuleBlockAmsg::OnPreCommand(), ModuleAlias::OnPreCommand(), ModuleSpanningTree::OnRehash(), ModuleSpanningTree::OnRemoteKill(), ModuleSQLAuth::OnRequest(), ModuleInviteException::OnRequest(), ModuleBanException::OnRequest(), ModuleSpanningTree::OnSetAway(), ModuleSpanningTree::OnStats(), ModuleZLib::OnStats(), ModuleSVSHold::OnStats(), ModuleFilterPCRE::OnStats(), ModuleFilter::OnStats(), ModuleDNSBL::OnStats(), ModuleCBan::OnStats(), ModuleSpanningTree::OnUserConnect(), ModuleSQLLog::OnUserConnect(), ModuleHostChange::OnUserConnect(), ModuleFoobar::OnUserConnect(), ModuleModesOnConnect::OnUserConnect(), ModuleSQLutils::OnUserDisconnect(), ModuleIdent::OnUserDisconnect(), ModuleSpanningTree::OnUserInvite(), ModuleSpanningTree::OnUserJoin(), ModuleFoobar::OnUserJoin(), ModuleChanCreate::OnUserJoin(), ModuleSpanningTree::OnUserKick(), ModuleAuditorium::OnUserKick(), ModuleAuditorium::OnUserList(), ModuleSpanningTree::OnUserMessage(), ModuleSpanningTree::OnUserNotice(), ModuleSpanningTree::OnUserPart(), ModuleFoobar::OnUserPart(), ModuleSpanningTree::OnUserPostNick(), Modulewatch::OnUserPostNick(), ModuleServices::OnUserPostNick(), ModuleSeeNicks::OnUserPostNick(), ModuleNoInvite::OnUserPreInvite(), ModuleSSLModes::OnUserPreJoin(), ModuleServicesAccount::OnUserPreJoin(), ModuleServices::OnUserPreJoin(), ModuleRestrictChans::OnUserPreJoin(), ModuleRegOnlyCreate::OnUserPreJoin(), ModuleRedirect::OnUserPreJoin(), ModuleOverride::OnUserPreJoin(), ModuleOperChans::OnUserPreJoin(), ModuleKickNoRejoin::OnUserPreJoin(), ModuleJoinFlood::OnUserPreJoin(), ModuleCBan::OnUserPreJoin(), ModuleBanRedirect::OnUserPreJoin(), ModuleServicesAccount::OnUserPreMessage(), ModuleServices::OnUserPreMessage(), ModuleRestrictMsg::OnUserPreMessage(), ModulePrivacyMode::OnUserPreMessage(), ModuleCensor::OnUserPreMessage(), ModuleBlockColour::OnUserPreMessage(), ModuleBlockCAPS::OnUserPreMessage(), ModuleSVSHold::OnUserPreNick(), ModuleNoNickChange::OnUserPreNick(), ModuleNickLock::OnUserPreNick(), ModuleNickFlood::OnUserPreNick(), ModuleNoNotice::OnUserPreNotice(), ModuleNoCTCP::OnUserPreNotice(), ModuleInvisible::OnUserPreNotice(), FilterBase::OnUserPreNotice(), ModuleDCCAllow::OnUserPreNotice(), ModuleSpanningTree::OnUserQuit(), Modulewatch::OnUserQuit(), ModuleSQLLog::OnUserQuit(), ModuleFoobar::OnUserQuit(), ModuleSQLAuth::OnUserRegister(), ModuleLDAPAuth::OnUserRegister(), ModuleJumpServer::OnUserRegister(), ModuleWaitPong::OnUserRegister(), ModuleAntiBear::OnUserRegister(), ModuleSpanningTree::OnWallops(), ModuleSSLOpenSSL::OnWhois(), ModuleSSLGnuTLS::OnWhois(), ModuleSSLDummy::OnWhois(), ModuleShowwhois::OnWhois(), ModuleServicesAccount::OnWhois(), ModuleServices::OnWhois(), ModuleHelpop::OnWhois(), ModuleBotMode::OnWhois(), ModuleSWhois::OnWhoisLine(), ModuleCustomTitle::OnWhoisLine(), ModuleSQLOper::OperUser(), ModeParser::Process(), CommandParser::ProcessBuffer(), CommandParser::ProcessCommand(), TreeSocket::ProcessLine(), ModuleChanFilter::ProcessMessages(), InspIRCd::ProcessUser(), ModuleSpanningTree::ProtoSendMetaData(), ModuleTaxonomy::ProtoSendMetaData(), ModuleSpanningTree::ProtoSendMode(), ServerConfig::Read(), ModuleCgiIRC::Recheck(), TreeSocket::RemoteKill(), ModuleSpanningTree::RemoteMessage(), cmd_watch::remove_watch(), ModeHandler::RemoveMode(), ModuleDCCAllow::RemoveNick(), ServerConfig::ReportConfigError(), ModeParser::Revoke(), ModeParser::SanityChecks(), ServerConfig::Send005(), cmd_who::SendWhoLine(), chanrec::ServerKickUser(), ModuleSpanningTree::ShowLinks(), ShowOperMOTD(), SplitChanList(), spy_userlist(), XLineManager::stats_e(), XLineManager::stats_g(), XLineManager::stats_k(), XLineManager::stats_q(), XLineManager::stats_z(), ChanFilter::TellAlreadyOnList(), ChanFilter::TellListTooLong(), ChanFilter::TellNotSet(), TreeSocket::Time(), cmd_filter::TooFewParams(), chanrec::UserList(), userrec(), ChanFilter::ValidateParam(), cmd_who::whomatch(), chanrec::WriteAllExceptSender(), InspIRCd::WriteMode(), InspIRCd::WriteOpers(), and SnomaskManager::WriteToSnoMask().

char userrec::oper[NICKMAX]
 

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 464 of file users.h.

Referenced by ModuleOverride::CanOverride(), do_whois(), cmd_check::Handle(), ModuleSpanningTree::HandleLusers(), TreeSocket::Modules(), ModuleOperLevels::OnKill(), InvisibleMode::OnModeChange(), ModuleSWhois::OnPostCommand(), ModuleModesOnOper::OnPostOper(), ModuleInvisible::OnUserPreNotice(), CommandParser::ProcessCommand(), ModuleSpanningTree::ShowLinks(), ModuleSpanningTree::ShowMap(), UnOper(), and userrec().

std::string userrec::operquitmsg
 

Oper-only quit message for this user if non-null.

Definition at line 522 of file users.h.

Referenced by CullList::AddItem(), CullList::Apply(), GetOperQuit(), and SetOperQuit().

char userrec::password[64]
 

Password specified by the user when they registered.

This is stored even if the <connect> block doesnt need a password, so that modules may check it.

Definition at line 480 of file users.h.

Referenced by ModuleSQLAuth::CheckCredentials(), ModuleLDAPAuth::CheckCredentials(), ModuleCgiIRC::CheckPass(), cmd_pass::Handle(), and userrec().

unsigned int userrec::pingmax
 

Number of seconds between PINGs for this user (set from <connect:allow> tag.

Definition at line 474 of file users.h.

Referenced by CheckClass(), InspIRCd::DoBackgroundUserStuff(), and CommandParser::ProcessCommand().

std::string userrec::quitmsg
 

Quit message for this user.

Definition at line 518 of file users.h.

Referenced by CullList::AddItem(), and CullList::Apply().

bool userrec::quitting
 

If this is set to true, then all read operations for the user are dropped into the bit-bucket.

This is used by the global CullList, but please note that setting this value alone will NOT cause the user to quit. This means it can be used seperately, for example by shun modules etc.

Definition at line 511 of file users.h.

Referenced by CullList::AddItem(), and userrec().

std::string userrec::recvq
 

User's receive queue.

Lines from the IRCd awaiting processing are stored here. Upgraded april 2005, old system a bit hairy.

Definition at line 486 of file users.h.

Referenced by AddBuffer(), BufferIsReady(), ClearBuffer(), GetBuffer(), InspIRCd::ProcessUser(), and userrec().

long userrec::recvqmax
 

Maximum size this user's recvq can become.

Copied from the connect class on connect.

Definition at line 569 of file users.h.

Referenced by AddBuffer(), and CheckClass().

UserResolver* userrec::res_forward
 

Resolvers for looking up this users IP address This will occur if and when res_reverse completes.

When this class completes its lookup, userrec::dns_done will be set from false to true.

Definition at line 376 of file users.h.

Referenced by UserResolver::OnLookupComplete(), and userrec().

UserResolver* userrec::res_reverse
 

Resolvers for looking up this users hostname This is instantiated by userrec::StartDNSLookup(), and on success, instantiates userrec::res_reverse.

Definition at line 382 of file users.h.

Referenced by StartDNSLookup(), and userrec().

time_t userrec::reset_d