1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #include "configreader.h"
19 #include "socketengine.h"
22 #include "cull_list.h"
23 #include "commands/cmd_whowas.h"
25 static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
27 /* XXX: Used for speeding up WriteCommon operations */
28 unsigned long uniq_id = 0;
30 bool InitTypes(ServerConfig* conf, const char* tag)
32 if (conf->opertypes.size())
34 conf->GetInstance()->Log(DEBUG,"Currently %d items to clear",conf->opertypes.size());
35 for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++)
37 conf->GetInstance()->Log(DEBUG,"Clear item");
43 conf->opertypes.clear();
47 bool InitClasses(ServerConfig* conf, const char* tag)
49 if (conf->operclass.size())
51 for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++)
58 conf->operclass.clear();
62 bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types)
64 const char* TypeName = values[0].GetString();
65 const char* Classes = values[1].GetString();
67 conf->opertypes[TypeName] = strdup(Classes);
68 conf->GetInstance()->Log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes);
72 bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types)
74 const char* ClassName = values[0].GetString();
75 const char* CommandList = values[1].GetString();
77 conf->operclass[ClassName] = strdup(CommandList);
78 conf->GetInstance()->Log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList);
82 bool DoneClassesAndTypes(ServerConfig* conf, const char* tag)
87 std::string userrec::ProcessNoticeMasks(const char *sm)
89 bool adding = true, oldadding = false;
93 ServerInstance->Log(DEBUG,"Process notice masks");
97 ServerInstance->Log(DEBUG,"Process notice mask %c",*c);
108 for (unsigned char d = 'A'; d <= 'z'; d++)
110 if (ServerInstance->SNO->IsEnabled(d))
112 if ((!IsNoticeMaskSet(d) && adding) || (IsNoticeMaskSet(d) && !adding))
114 if ((oldadding != adding) || (!output.length()))
115 output += (adding ? '+' : '-');
117 this->SetNoticeMask(d, adding);
126 if ((*c >= 'A') && (*c <= 'z') && (ServerInstance->SNO->IsEnabled(*c)))
128 if ((!IsNoticeMaskSet(*c) && adding) || (IsNoticeMaskSet(*c) && !adding))
130 if ((oldadding != adding) || (!output.length()))
131 output += (adding ? '+' : '-');
133 this->SetNoticeMask(*c, adding);
148 void userrec::StartDNSLookup()
150 ServerInstance->Log(DEBUG,"Commencing reverse lookup");
153 ServerInstance->Log(DEBUG,"Passing instance: %08x",this->ServerInstance);
154 res_reverse = new UserResolver(this->ServerInstance, this, this->GetIPString(), DNS_QUERY_REVERSE);
155 this->ServerInstance->AddResolver(res_reverse);
157 catch (CoreException& e)
159 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
163 UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt) :
164 Resolver(Instance, to_resolve, qt), bound_user(user)
166 this->fwd = (qt == DNS_QUERY_A || qt == DNS_QUERY_AAAA);
167 this->bound_fd = user->GetFd();
170 void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl)
172 if ((!this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
174 ServerInstance->Log(DEBUG,"Commencing forward lookup");
175 this->bound_user->stored_host = result;
178 /* Check we didnt time out */
179 if (this->bound_user->registered != REG_ALL)
182 const char *ip = this->bound_user->GetIPString();
183 bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, (strstr(ip,"0::ffff:") == ip ? DNS_QUERY_A : DNS_QUERY_AAAA));
185 bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A);
187 this->ServerInstance->AddResolver(bound_user->res_forward);
190 catch (CoreException& e)
192 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
195 else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
197 /* Both lookups completed */
198 std::string result2 = "0::ffff:";
199 result2.append(result);
200 if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2)
202 std::string hostname = this->bound_user->stored_host;
203 if (hostname.length() < 65)
205 /* Check we didnt time out */
206 if (this->bound_user->registered != REG_ALL)
208 /* Hostnames starting with : are not a good thing (tm) */
209 if (*(hostname.c_str()) == ':')
210 hostname = "0" + hostname;
212 this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)", hostname.c_str());
213 this->bound_user->dns_done = true;
214 strlcpy(this->bound_user->dhost, hostname.c_str(),64);
215 strlcpy(this->bound_user->host, hostname.c_str(),64);
216 /* Invalidate cache */
217 this->bound_user->InvalidateCache();
222 this->bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", this->bound_user->GetIPString());
227 this->bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", this->bound_user->GetIPString());
232 void UserResolver::OnError(ResolverError e, const std::string &errormessage)
234 if (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)
236 /* Error message here */
237 this->bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), this->bound_user->GetIPString());
238 this->bound_user->dns_done = true;
243 bool userrec::IsNoticeMaskSet(unsigned char sm)
245 return (snomasks[sm-65]);
248 void userrec::SetNoticeMask(unsigned char sm, bool value)
250 snomasks[sm-65] = value;
253 const char* userrec::FormatNoticeMasks()
255 static char data[MAXBUF];
258 for (int n = 0; n < 64; n++)
261 data[offset++] = n+65;
270 bool userrec::IsModeSet(unsigned char m)
272 return (modes[m-65]);
275 void userrec::SetMode(unsigned char m, bool value)
280 const char* userrec::FormatModes()
282 static char data[MAXBUF];
284 for (int n = 0; n < 64; n++)
287 data[offset++] = n+65;
293 void userrec::DecrementModes()
295 for (int n = 0; n < 64; n++)
299 ModeHandler* mh = ServerInstance->Modes->FindMode(n+65, MODETYPE_USER);
306 userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
308 ServerInstance->Log(DEBUG,"userrec::userrec(): Instance: %08x",ServerInstance);
309 // the PROPER way to do it, AVOID bzero at *ALL* costs
310 *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0;
311 server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName);
312 reset_due = ServerInstance->Time();
313 age = ServerInstance->Time(true);
314 lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
315 ChannelCount = timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0;
316 exempt = haspassed = dns_done = false;
321 res_forward = res_reverse = NULL;
325 memset(modes,0,sizeof(modes));
326 memset(snomasks,0,sizeof(snomasks));
327 /* Invalidate cache */
328 cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
333 this->InvalidateCache();
334 this->DecrementModes();
337 clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
338 if (x != ServerInstance->local_clones.end())
343 ServerInstance->local_clones.erase(x);
347 clonemap::iterator y = ServerInstance->global_clones.find(this->GetIPString());
348 if (y != ServerInstance->global_clones.end())
353 ServerInstance->global_clones.erase(y);
357 if (this->GetProtocolFamily() == AF_INET)
359 delete (sockaddr_in*)ip;
361 #ifdef SUPPORT_IP6LINKS
364 delete (sockaddr_in6*)ip;
370 char* userrec::MakeHost()
372 if (this->cached_makehost)
373 return this->cached_makehost;
376 /* This is much faster than snprintf */
378 for(char* n = ident; *n; n++)
381 for(char* n = host; *n; n++)
385 this->cached_makehost = strdup(nhost);
387 return this->cached_makehost;
390 char* userrec::MakeHostIP()
392 if (this->cached_hostip)
393 return this->cached_hostip;
396 /* This is much faster than snprintf */
398 for(char* n = ident; *n; n++)
401 for(const char* n = this->GetIPString(); *n; n++)
405 this->cached_hostip = strdup(ihost);
407 return this->cached_hostip;
410 void userrec::CloseSocket()
412 shutdown(this->fd,2);
416 char* userrec::GetFullHost()
418 if (this->cached_fullhost)
419 return this->cached_fullhost;
423 for(char* n = nick; *n; n++)
426 for(char* n = ident; *n; n++)
429 for(char* n = dhost; *n; n++)
433 this->cached_fullhost = strdup(result);
435 return this->cached_fullhost;
438 char* userrec::MakeWildHost()
440 static char nresult[MAXBUF];
442 *t++ = '*'; *t++ = '!';
443 *t++ = '*'; *t++ = '@';
444 for(char* n = dhost; *n; n++)
450 int userrec::ReadData(void* buffer, size_t size)
454 return read(this->fd, buffer, size);
461 char* userrec::GetFullRealHost()
463 if (this->cached_fullrealhost)
464 return this->cached_fullrealhost;
466 char fresult[MAXBUF];
468 for(char* n = nick; *n; n++)
471 for(char* n = ident; *n; n++)
474 for(char* n = host; *n; n++)
478 this->cached_fullrealhost = strdup(fresult);
480 return this->cached_fullrealhost;
483 bool userrec::IsInvited(const irc::string &channel)
485 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
495 InvitedList* userrec::GetInviteList()
500 void userrec::InviteTo(const irc::string &channel)
502 invites.push_back(channel);
505 void userrec::RemoveInvite(const irc::string &channel)
507 ServerInstance->Log(DEBUG,"Removing invites");
508 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
518 bool userrec::HasPermission(const std::string &command)
525 * users on remote servers can completely bypass all permissions based checks.
526 * This prevents desyncs when one server has different type/class tags to another.
527 * That having been said, this does open things up to the possibility of source changes
528 * allowing remote kills, etc - but if they have access to the src, they most likely have
529 * access to the conf - so it's an end to a means either way.
534 // are they even an oper at all?
537 opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
538 if (iter_opertype != ServerInstance->Config->opertypes.end())
540 char* Classes = strdup(iter_opertype->second);
541 char* myclass = strtok_r(Classes," ",&savept);
544 operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
545 if (iter_operclass != ServerInstance->Config->operclass.end())
547 char* CommandList = strdup(iter_operclass->second);
548 mycmd = strtok_r(CommandList," ",&savept2);
551 if ((!strcasecmp(mycmd,command.c_str())) || (*mycmd == '*'))
557 mycmd = strtok_r(NULL," ",&savept2);
561 myclass = strtok_r(NULL," ",&savept);
569 /** NOTE: We cannot pass a const reference to this method.
570 * The string is changed by the workings of the method,
571 * so that if we pass const ref, we end up copying it to
572 * something we can change anyway. Makes sense to just let
573 * the compiler do that copy for us.
575 bool userrec::AddBuffer(std::string a)
579 std::string::size_type i = a.rfind('\r');
581 while (i != std::string::npos)
590 if (recvq.length() > (unsigned)this->recvqmax)
592 this->SetWriteError("RecvQ exceeded");
593 ServerInstance->WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
602 ServerInstance->Log(DEBUG,"Exception in userrec::AddBuffer()");
607 bool userrec::BufferIsReady()
609 return (recvq.find('\n') != std::string::npos);
612 void userrec::ClearBuffer()
617 std::string userrec::GetBuffer()
624 /* Strip any leading \r or \n off the string.
625 * Usually there are only one or two of these,
626 * so its is computationally cheap to do.
628 while ((*recvq.begin() == '\r') || (*recvq.begin() == '\n'))
629 recvq.erase(recvq.begin());
631 for (std::string::iterator x = recvq.begin(); x != recvq.end(); x++)
633 /* Find the first complete line, return it as the
634 * result, and leave the recvq as whats left
638 std::string ret = std::string(recvq.begin(), x);
639 recvq.erase(recvq.begin(), x + 1);
648 ServerInstance->Log(DEBUG,"Exception in userrec::GetBuffer()");
653 void userrec::AddWriteBuf(const std::string &data)
655 if (*this->GetWriteError())
658 if (sendq.length() + data.length() > (unsigned)this->sendqmax)
661 * Fix by brain - Set the error text BEFORE calling writeopers, because
662 * if we dont it'll recursively call here over and over again trying
663 * to repeatedly add the text to the sendq!
665 this->SetWriteError("SendQ exceeded");
666 ServerInstance->WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
672 if (data.length() > 512)
673 sendq.append(data.substr(0,510)).append("\r\n");
679 this->SetWriteError("SendQ exceeded");
680 ServerInstance->WriteOpers("*** User %s SendQ got an exception",this->nick);
684 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
685 void userrec::FlushWriteBuf()
689 if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
693 if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
695 int old_sendq_length = sendq.length();
696 int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
701 /* The socket buffer is full. This isnt fatal,
704 ServerInstance->Log(DEBUG,"EAGAIN, want write");
705 this->ServerInstance->SE->WantWrite(this);
709 /* Fatal error, set write error and bail
711 this->SetWriteError(strerror(errno));
717 /* advance the queue */
719 this->sendq = this->sendq.substr(n_sent);
720 /* update the user's stats counters */
721 this->bytes_out += n_sent;
723 if (n_sent != old_sendq_length)
725 ServerInstance->Log(DEBUG,"Not all written, want write");
726 this->ServerInstance->SE->WantWrite(this);
734 ServerInstance->Log(DEBUG,"Exception in userrec::FlushWriteBuf()");
738 void userrec::SetWriteError(const std::string &error)
742 // don't try to set the error twice, its already set take the first string.
743 if (this->WriteError.empty())
745 ServerInstance->Log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
746 this->WriteError = error;
752 ServerInstance->Log(DEBUG,"Exception in userrec::SetWriteError()");
756 const char* userrec::GetWriteError()
758 return this->WriteError.c_str();
761 void userrec::Oper(const std::string &opertype)
765 this->modes[UM_OPERATOR] = 1;
766 this->WriteServ("MODE %s :+o", this->nick);
767 FOREACH_MOD(I_OnOper, OnOper(this, opertype));
768 ServerInstance->Log(DEFAULT,"OPER: %s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str());
769 strlcpy(this->oper, opertype.c_str(), NICKMAX - 1);
770 ServerInstance->all_opers.push_back(this);
771 FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype));
776 ServerInstance->Log(DEBUG,"Exception in userrec::Oper()");
780 void userrec::UnOper()
787 this->modes[UM_OPERATOR] = 0;
788 for (std::vector<userrec*>::iterator a = ServerInstance->all_opers.begin(); a < ServerInstance->all_opers.end(); a++)
792 ServerInstance->Log(DEBUG,"Oper removed from optimization list");
793 ServerInstance->all_opers.erase(a);
802 ServerInstance->Log(DEBUG,"Exception in userrec::UnOper()");
806 void userrec::QuitUser(InspIRCd* Instance, userrec *user, const std::string &quitreason)
808 user_hash::iterator iter = Instance->clientlist->find(user->nick);
809 std::string reason = quitreason;
811 if (reason.length() > MAXQUIT - 1)
812 reason.resize(MAXQUIT - 1);
814 if (user->registered != REG_ALL)
815 if (Instance->unregistered_count)
816 Instance->unregistered_count--;
820 user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str());
821 if ((!user->sendq.empty()) && (!(*user->GetWriteError())))
822 user->FlushWriteBuf();
825 if (user->registered == REG_ALL)
827 user->PurgeEmptyChannels();
828 user->WriteCommonExcept("QUIT :%s",reason.c_str());
829 FOREACH_MOD_I(Instance,I_OnUserQuit,OnUserQuit(user,reason));
832 FOREACH_MOD_I(Instance,I_OnUserDisconnect,OnUserDisconnect(user));
836 if (Instance->Config->GetIOHook(user->GetPort()))
840 Instance->Config->GetIOHook(user->GetPort())->OnRawSocketClose(user->fd);
842 catch (CoreException& modexcept)
844 Instance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
848 Instance->SE->DelFd(user);
853 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
854 * if they were an oper with +sn +qQ.
856 if (user->registered == REG_ALL)
859 Instance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
861 Instance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,reason.c_str());
865 if (iter != Instance->clientlist->end())
867 Instance->Log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
870 std::vector<userrec*>::iterator x = find(Instance->local_users.begin(),Instance->local_users.end(),user);
871 if (x != Instance->local_users.end())
872 Instance->local_users.erase(x);
874 Instance->clientlist->erase(iter);
880 /* adds or updates an entry in the whowas list */
881 void userrec::AddToWhoWas()
883 command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
886 std::deque<classbase*> params;
887 params.push_back(this);
888 whowas_command->HandleInternal(WHOWAS_ADD, params);
892 /* add a client connection to the sockets list */
893 void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, insp_inaddr ip)
895 std::string tempnick = ConvToStr(socket) + "-unknown";
896 user_hash::iterator iter = Instance->clientlist->find(tempnick);
897 const char *ipaddr = insp_ntoa(ip);
901 Instance->unregistered_count++;
905 * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
906 * using one as a registered connection. As they are per fd, we can also safely assume
907 * that we wont have collisions. Therefore, if the nick exists in the list, its only
908 * used by a dead socket, erase the iterator so that the new client may reclaim it.
909 * this was probably the cause of 'server ignores me when i hammer it with reconnects'
910 * issue in earlier alphas/betas
912 if (iter != Instance->clientlist->end())
914 userrec* goner = iter->second;
916 Instance->clientlist->erase(iter);
919 Instance->Log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr);
921 New = new userrec(Instance);
922 (*(Instance->clientlist))[tempnick] = New;
924 strlcpy(New->nick,tempnick.c_str(),NICKMAX-1);
926 New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);
927 /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
928 strcpy(New->ident, "unknown");
930 New->registered = REG_NONE;
931 New->signon = Instance->Time() + Instance->Config->dns_timeout;
934 New->SetSockAddr(AF_FAMILY, ipaddr, port);
936 /* Smarter than your average bear^H^H^H^Hset of strlcpys. */
937 for (const char* temp = New->GetIPString(); *temp && j < 64; temp++, j++)
938 New->dhost[j] = New->host[j] = *temp;
939 New->dhost[j] = New->host[j] = 0;
941 Instance->AddLocalClone(New);
942 Instance->AddGlobalClone(New);
944 ConnectClass* i = New->GetClass();
946 if ((!i) || (i->GetType() == CC_DENY))
948 userrec::QuitUser(Instance, New,"Unauthorised connection");
952 New->pingmax = i->GetPingTime();
953 New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
954 New->timeout = Instance->Time() + i->GetRegTimeout();
955 New->flood = i->GetFlood();
956 New->threshold = i->GetThreshold();
957 New->sendqmax = i->GetSendqMax();
958 New->recvqmax = i->GetRecvqMax();
960 Instance->local_users.push_back(New);
962 if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
964 Instance->WriteOpers("*** Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
965 userrec::QuitUser(Instance, New,"No more connections allowed");
971 * this is done as a safety check to keep the file descriptors within range of fd_ref_table.
972 * its a pretty big but for the moment valid assumption:
973 * file descriptors are handed out starting at 0, and are recycled as theyre freed.
974 * therefore if there is ever an fd over 65535, 65536 clients must be connected to the
975 * irc server at once (or the irc server otherwise initiating this many connections, files etc)
976 * which for the time being is a physical impossibility (even the largest networks dont have more
977 * than about 10,000 users on ONE server!)
979 if ((unsigned int)socket >= MAX_DESCRIPTORS)
981 userrec::QuitUser(Instance, New, "Server is full");
985 New->exempt = (Instance->XLines->matches_exception(New) != NULL);
988 ZLine* r = Instance->XLines->matches_zline(ipaddr);
992 snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
993 userrec::QuitUser(Instance, New, reason);
1000 if (!Instance->SE->AddFd(New))
1002 userrec::QuitUser(Instance, New, "Internal error handling connection");
1007 /* NOTE: even if dns lookups are *off*, we still need to display this.
1008 * BOPM and other stuff requires it.
1010 New->WriteServ("NOTICE Auth :*** Looking up your hostname...");
1013 unsigned long userrec::GlobalCloneCount()
1015 clonemap::iterator x = ServerInstance->global_clones.find(this->GetIPString());
1016 if (x != ServerInstance->global_clones.end())
1022 unsigned long userrec::LocalCloneCount()
1024 clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
1025 if (x != ServerInstance->local_clones.end())
1031 void userrec::FullConnect(CullList* Goners)
1033 ServerInstance->stats->statsConnects++;
1034 this->idle_lastmsg = ServerInstance->Time();
1036 ConnectClass* a = this->GetClass();
1038 if ((!a) || (a->GetType() == CC_DENY))
1040 Goners->AddItem(this,"Unauthorised connection");
1044 if ((!a->GetPass().empty()) && (!this->haspassed))
1046 Goners->AddItem(this,"Invalid password");
1050 if (this->LocalCloneCount() > a->GetMaxLocal())
1052 Goners->AddItem(this, "No more connections allowed from your host via this connect class (local)");
1053 ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
1056 else if (this->GlobalCloneCount() > a->GetMaxGlobal())
1058 Goners->AddItem(this, "No more connections allowed from your host via this connect class (global)");
1059 ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a->GetMaxGlobal(), this->GetIPString());
1065 GLine* r = ServerInstance->XLines->matches_gline(this);
1069 char reason[MAXBUF];
1070 snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
1071 Goners->AddItem(this, reason);
1075 KLine* n = ServerInstance->XLines->matches_kline(this);
1079 char reason[MAXBUF];
1080 snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
1081 Goners->AddItem(this, reason);
1087 this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network);
1088 this->WriteServ("001 %s :Welcome to the %s IRC Network %s!%s@%s",this->nick, ServerInstance->Config->Network, this->nick, this->ident, this->host);
1089 this->WriteServ("002 %s :Your host is %s, running version %s",this->nick,ServerInstance->Config->ServerName,VERSION);
1090 this->WriteServ("003 %s :This server was created %s %s", this->nick, __TIME__, __DATE__);
1091 this->WriteServ("004 %s %s %s %s %s %s", this->nick, ServerInstance->Config->ServerName, VERSION, ServerInstance->Modes->UserModeList().c_str(), ServerInstance->Modes->ChannelModeList().c_str(), ServerInstance->Modes->ParaModeList().c_str());
1093 ServerInstance->Config->Send005(this);
1097 /* Now registered */
1098 if (ServerInstance->unregistered_count)
1099 ServerInstance->unregistered_count--;
1102 * fix 3 by brain, move registered = 7 below these so that spurious modes and host
1103 * changes dont go out onto the network and produce 'fake direction'.
1105 FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
1107 this->registered = REG_ALL;
1109 FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
1111 ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
1114 /** userrec::UpdateNick()
1115 * re-allocates a nick in the user_hash after they change nicknames,
1116 * returns a pointer to the new user as it may have moved
1118 userrec* userrec::UpdateNickHash(const char* New)
1122 //user_hash::iterator newnick;
1123 user_hash::iterator oldnick = ServerInstance->clientlist->find(this->nick);
1125 if (!strcasecmp(this->nick,New))
1126 return oldnick->second;
1128 if (oldnick == ServerInstance->clientlist->end())
1129 return NULL; /* doesnt exist */
1131 userrec* olduser = oldnick->second;
1132 (*(ServerInstance->clientlist))[New] = olduser;
1133 ServerInstance->clientlist->erase(oldnick);
1139 ServerInstance->Log(DEBUG,"Exception in userrec::UpdateNickHash()");
1144 void userrec::InvalidateCache()
1146 /* Invalidate cache */
1147 if (cached_fullhost)
1148 free(cached_fullhost);
1150 free(cached_hostip);
1151 if (cached_makehost)
1152 free(cached_makehost);
1153 if (cached_fullrealhost)
1154 free(cached_fullrealhost);
1155 cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
1158 bool userrec::ForceNickChange(const char* newnick)
1164 this->InvalidateCache();
1166 FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
1170 ServerInstance->stats->statsCollisions++;
1174 if (ServerInstance->XLines->matches_qline(newnick))
1176 ServerInstance->stats->statsCollisions++;
1180 if (this->registered == REG_ALL)
1182 const char* pars[1];
1184 std::string cmd = "NICK";
1185 return (ServerInstance->Parser->CallHandler(cmd, pars, 1, this) == CMD_SUCCESS);
1192 ServerInstance->Log(DEBUG,"Exception in userrec::ForceNickChange()");
1197 void userrec::SetSockAddr(int protocol_family, const char* ip, int port)
1199 switch (protocol_family)
1201 #ifdef SUPPORT_IP6LINKS
1204 ServerInstance->Log(DEBUG,"Set inet6 protocol address");
1205 sockaddr_in6* sin = new sockaddr_in6;
1206 sin->sin6_family = AF_INET6;
1207 sin->sin6_port = port;
1208 inet_pton(AF_INET6, ip, &sin->sin6_addr);
1209 this->ip = (sockaddr*)sin;
1215 ServerInstance->Log(DEBUG,"Set inet4 protocol address");
1216 sockaddr_in* sin = new sockaddr_in;
1217 sin->sin_family = AF_INET;
1218 sin->sin_port = port;
1219 inet_pton(AF_INET, ip, &sin->sin_addr);
1220 this->ip = (sockaddr*)sin;
1224 ServerInstance->Log(DEBUG,"Ut oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick);
1229 int userrec::GetPort()
1231 if (this->ip == NULL)
1234 switch (this->GetProtocolFamily())
1236 #ifdef SUPPORT_IP6LINKS
1239 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1240 return sin->sin6_port;
1246 sockaddr_in* sin = (sockaddr_in*)this->ip;
1247 return sin->sin_port;
1256 int userrec::GetProtocolFamily()
1258 if (this->ip == NULL)
1261 sockaddr_in* sin = (sockaddr_in*)this->ip;
1262 return sin->sin_family;
1265 const char* userrec::GetIPString()
1267 static char buf[1024];
1269 if (this->ip == NULL)
1272 switch (this->GetProtocolFamily())
1274 #ifdef SUPPORT_IP6LINKS
1277 static char temp[1024];
1279 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1280 inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
1281 /* IP addresses starting with a : on irc are a Bad Thing (tm) */
1284 strlcpy(&temp[1], buf, sizeof(temp) - 1);
1294 sockaddr_in* sin = (sockaddr_in*)this->ip;
1295 inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
1305 const char* userrec::GetIPString(char* buf)
1307 if (this->ip == NULL)
1313 switch (this->GetProtocolFamily())
1315 #ifdef SUPPORT_IP6LINKS
1318 static char temp[1024];
1320 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1321 inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
1322 /* IP addresses starting with a : on irc are a Bad Thing (tm) */
1325 strlcpy(&temp[1], buf, sizeof(temp) - 1);
1327 strlcpy(buf, temp, sizeof(temp));
1335 sockaddr_in* sin = (sockaddr_in*)this->ip;
1336 inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
1347 /** NOTE: We cannot pass a const reference to this method.
1348 * The string is changed by the workings of the method,
1349 * so that if we pass const ref, we end up copying it to
1350 * something we can change anyway. Makes sense to just let
1351 * the compiler do that copy for us.
1353 void userrec::Write(std::string text)
1355 if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
1360 text.append("\r\n");
1364 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
1368 if (ServerInstance->Config->GetIOHook(this->GetPort()))
1372 ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
1374 catch (CoreException& modexcept)
1376 ServerInstance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
1381 this->AddWriteBuf(text);
1383 ServerInstance->stats->statsSent += text.length();
1384 this->ServerInstance->SE->WantWrite(this);
1389 void userrec::Write(const char *text, ...)
1392 char textbuffer[MAXBUF];
1394 va_start(argsPtr, text);
1395 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1398 this->Write(std::string(textbuffer));
1401 void userrec::WriteServ(const std::string& text)
1403 char textbuffer[MAXBUF];
1405 snprintf(textbuffer,MAXBUF,":%s %s",ServerInstance->Config->ServerName,text.c_str());
1406 this->Write(std::string(textbuffer));
1410 * Same as Write(), except `text' is prefixed with `:server.name '.
1412 void userrec::WriteServ(const char* text, ...)
1415 char textbuffer[MAXBUF];
1417 va_start(argsPtr, text);
1418 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1421 this->WriteServ(std::string(textbuffer));
1425 void userrec::WriteFrom(userrec *user, const std::string &text)
1429 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
1431 this->Write(std::string(tb));
1435 /* write text from an originating user to originating user */
1437 void userrec::WriteFrom(userrec *user, const char* text, ...)
1440 char textbuffer[MAXBUF];
1442 va_start(argsPtr, text);
1443 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1446 this->WriteFrom(user, std::string(textbuffer));
1450 /* write text to an destination user from a source user (e.g. user privmsg) */
1452 void userrec::WriteTo(userrec *dest, const char *data, ...)
1454 char textbuffer[MAXBUF];
1457 va_start(argsPtr, data);
1458 vsnprintf(textbuffer, MAXBUF, data, argsPtr);
1461 this->WriteTo(dest, std::string(textbuffer));
1464 void userrec::WriteTo(userrec *dest, const std::string &data)
1466 dest->WriteFrom(this, data);
1470 void userrec::WriteCommon(const char* text, ...)
1472 char textbuffer[MAXBUF];
1475 if (this->registered != REG_ALL)
1478 va_start(argsPtr, text);
1479 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1482 this->WriteCommon(std::string(textbuffer));
1485 void userrec::WriteCommon(const std::string &text)
1489 bool sent_to_at_least_one = false;
1492 if (this->registered != REG_ALL)
1497 /* We dont want to be doing this n times, just once */
1498 snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
1499 std::string out = tb;
1501 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
1503 CUList* ulist = v->first->GetUsers();
1504 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
1506 if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
1508 already_sent[i->second->fd] = uniq_id;
1509 i->second->Write(out);
1510 sent_to_at_least_one = true;
1516 * if the user was not in any channels, no users will receive the text. Make sure the user
1517 * receives their OWN message for WriteCommon
1519 if (!sent_to_at_least_one)
1521 this->Write(std::string(tb));
1527 ServerInstance->Log(DEBUG,"Exception in userrec::WriteCommon()");
1532 /* write a formatted string to all users who share at least one common
1533 * channel, NOT including the source user e.g. for use in QUIT
1536 void userrec::WriteCommonExcept(const char* text, ...)
1538 char textbuffer[MAXBUF];
1541 va_start(argsPtr, text);
1542 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1545 this->WriteCommonExcept(std::string(textbuffer));
1548 void userrec::WriteCommonExcept(const std::string &text)
1550 bool quit_munge = false;
1551 char oper_quit[MAXBUF];
1552 char textbuffer[MAXBUF];
1558 strlcpy(textbuffer, text.c_str(), MAXBUF);
1560 if (this->registered != REG_ALL)
1565 snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),textbuffer);
1567 /* TODO: We need some form of WriteCommonExcept that will send two lines, one line to
1568 * opers and the other line to non-opers, then all this hidebans and hidesplits gunk
1571 if (ServerInstance->Config->HideSplits)
1573 char* check = textbuffer + 6;
1575 if (!strncasecmp(textbuffer, "QUIT :",6))
1577 std::stringstream split(check);
1578 std::string server_one;
1579 std::string server_two;
1581 split >> server_one;
1582 split >> server_two;
1584 if ((ServerInstance->FindServerName(server_one)) && (ServerInstance->FindServerName(server_two)))
1586 strlcpy(oper_quit,textbuffer,MAXQUIT);
1587 strlcpy(check,"*.net *.split",MAXQUIT);
1589 snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
1595 if ((ServerInstance->Config->HideBans) && (!quit_munge))
1597 if ((!strncasecmp(textbuffer, "QUIT :G-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :K-Lined:",14))
1598 || (!strncasecmp(textbuffer, "QUIT :Q-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :Z-Lined:",14)))
1600 char* check = textbuffer + 13;
1601 strlcpy(oper_quit,textbuffer,MAXQUIT);
1602 *check = 0; // We don't need to strlcpy, we just chop it from the :
1604 snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
1611 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
1613 CUList *ulist = v->first->GetUsers();
1614 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
1616 if (this != i->second)
1618 if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
1620 already_sent[i->second->fd] = uniq_id;
1622 i->second->Write(*i->second->oper ? out2 : out1);
1624 i->second->Write(out1);
1632 void userrec::WriteWallOps(const std::string &text)
1634 /* Does nothing if theyre not opered */
1635 if ((!*this->oper) && (IS_LOCAL(this)))
1638 std::string wallop = "WALLOPS :";
1642 wallop.append(text);
1646 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
1650 for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
1653 if ((IS_LOCAL(t)) && (t->modes[UM_WALLOPS]))
1654 this->WriteTo(t,wallop);
1658 void userrec::WriteWallOps(const char* text, ...)
1660 char textbuffer[MAXBUF];
1663 va_start(argsPtr, text);
1664 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1667 this->WriteWallOps(std::string(textbuffer));
1670 /* return 0 or 1 depending if users u and u2 share one or more common channels
1671 * (used by QUIT, NICK etc which arent channel specific notices)
1673 * The old algorithm in 1.0 for this was relatively inefficient, iterating over
1674 * the first users channels then the second users channels within the outer loop,
1675 * therefore it was a maximum of x*y iterations (upon returning 0 and checking
1676 * all possible iterations). However this new function instead checks against the
1677 * channel's userlist in the inner loop which is a std::map<userrec*,userrec*>
1678 * and saves us time as we already know what pointer value we are after.
1679 * Don't quote me on the maths as i am not a mathematician or computer scientist,
1680 * but i believe this algorithm is now x+(log y) maximum iterations instead.
1682 bool userrec::SharesChannelWith(userrec *other)
1684 if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
1688 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1690 /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
1691 * by replacing it with a map::find which *should* be more efficient
1693 if (i->first->HasUser(other))
1699 bool userrec::ChangeName(const char* gecos)
1701 if (!strcmp(gecos, this->fullname))
1707 FOREACH_RESULT(I_OnChangeLocalUserGECOS,OnChangeLocalUserGECOS(this,gecos));
1710 FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos));
1712 strlcpy(this->fullname,gecos,MAXGECOS+1);
1717 bool userrec::ChangeDisplayedHost(const char* host)
1719 if (!strcmp(host, this->dhost))
1725 FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(this,host));
1728 FOREACH_MOD(I_OnChangeHost,OnChangeHost(this,host));
1730 if (this->ServerInstance->Config->CycleHosts)
1731 this->WriteCommonExcept("QUIT :Changing hosts");
1733 /* Fix by Om: userrec::dhost is 65 long, this was truncating some long hosts */
1734 strlcpy(this->dhost,host,64);
1736 this->InvalidateCache();
1738 if (this->ServerInstance->Config->CycleHosts)
1740 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1742 i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
1743 std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
1745 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
1750 this->WriteServ("396 %s %s :is now your hidden host",this->nick,this->dhost);
1755 bool userrec::ChangeIdent(const char* newident)
1757 if (!strcmp(newident, this->ident))
1760 if (this->ServerInstance->Config->CycleHosts)
1761 this->WriteCommonExcept("%s","QUIT :Changing ident");
1763 strlcpy(this->ident, newident, IDENTMAX+2);
1765 this->InvalidateCache();
1767 if (this->ServerInstance->Config->CycleHosts)
1769 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1771 i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
1772 std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
1774 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
1781 void userrec::NoticeAll(char* text, ...)
1783 char textbuffer[MAXBUF];
1784 char formatbuffer[MAXBUF];
1787 va_start(argsPtr, text);
1788 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1791 snprintf(formatbuffer,MAXBUF,":%s NOTICE $* :%s", this->GetFullHost(), textbuffer);
1792 std::string fmt = formatbuffer;
1794 for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
1801 std::string userrec::ChannelList(userrec* source)
1806 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1808 /* If the target is the same as the sender, let them see all their channels.
1809 * If the channel is NOT private/secret OR the user shares a common channel
1810 * If the user is an oper, and the <options:operspywhois> option is set.
1812 if ((source == this) || (*source->oper && ServerInstance->Config->OperSpyWhois) || (((!i->first->modes[CM_PRIVATE]) && (!i->first->modes[CM_SECRET])) || (i->first->HasUser(source))))
1814 list.append(i->first->GetPrefixChar(this)).append(i->first->name).append(" ");
1821 ServerInstance->Log(DEBUG,"Exception in userrec::ChannelList()");
1826 void userrec::SplitChanList(userrec* dest, const std::string &cl)
1829 std::ostringstream prefix;
1830 std::string::size_type start, pos, length;
1834 prefix << this->nick << " " << dest->nick << " :";
1835 line = prefix.str();
1836 int namelen = strlen(ServerInstance->Config->ServerName) + 6;
1838 for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
1840 length = (pos == std::string::npos) ? cl.length() : pos;
1842 if (line.length() + namelen + length - start > 510)
1844 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
1845 line = prefix.str();
1848 if(pos == std::string::npos)
1850 line.append(cl.substr(start, length - start));
1855 line.append(cl.substr(start, length - start + 1));
1861 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
1867 ServerInstance->Log(DEBUG,"Exception in userrec::SplitChanList()");
1872 /* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
1873 * NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
1874 * then their ip will be taken as 'priority' anyway, so for example,
1875 * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
1877 ConnectClass* userrec::GetClass()
1879 for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
1881 if ((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str())))
1887 void userrec::PurgeEmptyChannels()
1889 std::vector<chanrec*> to_delete;
1891 // firstly decrement the count on each channel
1892 for (UCListIter f = this->chans.begin(); f != this->chans.end(); f++)
1894 f->first->RemoveAllPrefixes(this);
1895 if (f->first->DelUser(this) == 0)
1897 /* No users left in here, mark it for deletion */
1900 to_delete.push_back(f->first);
1904 ServerInstance->Log(DEBUG,"Exception in userrec::PurgeEmptyChannels to_delete.push_back()");
1909 for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
1911 chanrec* thischan = *n;
1912 chan_hash::iterator i2 = ServerInstance->chanlist->find(thischan->name);
1913 if (i2 != ServerInstance->chanlist->end())
1915 FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
1917 ServerInstance->chanlist->erase(i2);
1918 this->chans.erase(*n);
1925 void userrec::ShowMOTD()
1927 if (!ServerInstance->Config->MOTD.size())
1929 this->WriteServ("422 %s :Message of the day file is missing.",this->nick);
1932 this->WriteServ("375 %s :%s message of the day", this->nick, ServerInstance->Config->ServerName);
1934 for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
1935 this->WriteServ("372 %s :- %s",this->nick,i->c_str());
1937 this->WriteServ("376 %s :End of message of the day.", this->nick);
1940 void userrec::ShowRULES()
1942 if (!ServerInstance->Config->RULES.size())
1944 this->WriteServ("NOTICE %s :Rules file is missing.",this->nick);
1947 this->WriteServ("NOTICE %s :%s rules",this->nick,ServerInstance->Config->ServerName);
1949 for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
1950 this->WriteServ("NOTICE %s :%s",this->nick,i->c_str());
1952 this->WriteServ("NOTICE %s :End of %s rules.",this->nick,ServerInstance->Config->ServerName);
1955 void userrec::HandleEvent(EventType et, int errornum)
1957 /* WARNING: May delete this user! */
1958 int thisfd = this->GetFd();
1965 ServerInstance->ProcessUser(this);
1968 this->FlushWriteBuf();
1971 /** This should be safe, but dont DARE do anything after it -- Brain */
1972 this->SetWriteError(errornum ? strerror(errornum) : "EOF from client");
1978 ServerInstance->Log(DEBUG,"Exception in userrec::HandleEvent intercepted");
1981 /* If the user has raised an error whilst being processed, quit them now we're safe to */
1982 if ((ServerInstance->SE->GetRef(thisfd) == this))
1984 if (!WriteError.empty())
1986 userrec::QuitUser(ServerInstance, this, GetWriteError());