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);
155 res_reverse = new UserResolver(this->ServerInstance, this, this->GetIPString(), DNS_QUERY_REVERSE, cached);
157 this->ServerInstance->AddResolver(res_reverse);
161 catch (CoreException& e)
163 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
167 UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt, bool &cache) :
168 Resolver(Instance, to_resolve, qt, cache), bound_user(user)
170 this->fwd = (qt == DNS_QUERY_A || qt == DNS_QUERY_AAAA);
171 this->bound_fd = user->GetFd();
174 void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl)
176 if ((!this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
178 ServerInstance->Log(DEBUG,"Commencing forward lookup");
179 this->bound_user->stored_host = result;
182 /* Check we didnt time out */
183 if (this->bound_user->registered != REG_ALL)
187 const char *ip = this->bound_user->GetIPString();
188 bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, (strstr(ip,"0::ffff:") == ip ? DNS_QUERY_A : DNS_QUERY_AAAA), cached);
190 bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, cached);
193 this->ServerInstance->AddResolver(bound_user->res_forward);
195 delete bound_user->res_forward;
198 catch (CoreException& e)
200 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
203 else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
205 /* Both lookups completed */
206 std::string result2 = "0::ffff:";
207 result2.append(result);
208 if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2)
210 std::string hostname = this->bound_user->stored_host;
211 if (hostname.length() < 65)
213 /* Check we didnt time out */
214 if (this->bound_user->registered != REG_ALL)
216 /* Hostnames starting with : are not a good thing (tm) */
217 if (*(hostname.c_str()) == ':')
218 hostname = "0" + hostname;
220 this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)", hostname.c_str());
221 this->bound_user->dns_done = true;
222 strlcpy(this->bound_user->dhost, hostname.c_str(),64);
223 strlcpy(this->bound_user->host, hostname.c_str(),64);
224 /* Invalidate cache */
225 this->bound_user->InvalidateCache();
230 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());
235 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());
240 void UserResolver::OnError(ResolverError e, const std::string &errormessage)
242 if (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)
244 /* Error message here */
245 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());
246 this->bound_user->dns_done = true;
251 bool userrec::IsNoticeMaskSet(unsigned char sm)
253 return (snomasks[sm-65]);
256 void userrec::SetNoticeMask(unsigned char sm, bool value)
258 snomasks[sm-65] = value;
261 const char* userrec::FormatNoticeMasks()
263 static char data[MAXBUF];
266 for (int n = 0; n < 64; n++)
269 data[offset++] = n+65;
278 bool userrec::IsModeSet(unsigned char m)
280 return (modes[m-65]);
283 void userrec::SetMode(unsigned char m, bool value)
288 const char* userrec::FormatModes()
290 static char data[MAXBUF];
292 for (int n = 0; n < 64; n++)
295 data[offset++] = n+65;
301 void userrec::DecrementModes()
303 for (int n = 0; n < 64; n++)
307 ModeHandler* mh = ServerInstance->Modes->FindMode(n+65, MODETYPE_USER);
314 userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
316 ServerInstance->Log(DEBUG,"userrec::userrec(): Instance: %08x",ServerInstance);
317 // the PROPER way to do it, AVOID bzero at *ALL* costs
318 *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0;
319 server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName);
320 reset_due = ServerInstance->Time();
321 age = ServerInstance->Time(true);
322 lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
323 ChannelCount = timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0;
324 exempt = haspassed = dns_done = false;
329 res_forward = res_reverse = NULL;
333 memset(modes,0,sizeof(modes));
334 memset(snomasks,0,sizeof(snomasks));
335 /* Invalidate cache */
336 cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
341 this->InvalidateCache();
342 this->DecrementModes();
345 clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
346 if (x != ServerInstance->local_clones.end())
351 ServerInstance->local_clones.erase(x);
355 clonemap::iterator y = ServerInstance->global_clones.find(this->GetIPString());
356 if (y != ServerInstance->global_clones.end())
361 ServerInstance->global_clones.erase(y);
365 if (this->GetProtocolFamily() == AF_INET)
367 delete (sockaddr_in*)ip;
369 #ifdef SUPPORT_IP6LINKS
372 delete (sockaddr_in6*)ip;
378 char* userrec::MakeHost()
380 if (this->cached_makehost)
381 return this->cached_makehost;
384 /* This is much faster than snprintf */
386 for(char* n = ident; *n; n++)
389 for(char* n = host; *n; n++)
393 this->cached_makehost = strdup(nhost);
395 return this->cached_makehost;
398 char* userrec::MakeHostIP()
400 if (this->cached_hostip)
401 return this->cached_hostip;
404 /* This is much faster than snprintf */
406 for(char* n = ident; *n; n++)
409 for(const char* n = this->GetIPString(); *n; n++)
413 this->cached_hostip = strdup(ihost);
415 return this->cached_hostip;
418 void userrec::CloseSocket()
420 shutdown(this->fd,2);
424 char* userrec::GetFullHost()
426 if (this->cached_fullhost)
427 return this->cached_fullhost;
431 for(char* n = nick; *n; n++)
434 for(char* n = ident; *n; n++)
437 for(char* n = dhost; *n; n++)
441 this->cached_fullhost = strdup(result);
443 return this->cached_fullhost;
446 char* userrec::MakeWildHost()
448 static char nresult[MAXBUF];
450 *t++ = '*'; *t++ = '!';
451 *t++ = '*'; *t++ = '@';
452 for(char* n = dhost; *n; n++)
458 int userrec::ReadData(void* buffer, size_t size)
462 return read(this->fd, buffer, size);
469 char* userrec::GetFullRealHost()
471 if (this->cached_fullrealhost)
472 return this->cached_fullrealhost;
474 char fresult[MAXBUF];
476 for(char* n = nick; *n; n++)
479 for(char* n = ident; *n; n++)
482 for(char* n = host; *n; n++)
486 this->cached_fullrealhost = strdup(fresult);
488 return this->cached_fullrealhost;
491 bool userrec::IsInvited(const irc::string &channel)
493 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
503 InvitedList* userrec::GetInviteList()
508 void userrec::InviteTo(const irc::string &channel)
510 invites.push_back(channel);
513 void userrec::RemoveInvite(const irc::string &channel)
515 ServerInstance->Log(DEBUG,"Removing invites");
516 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
526 bool userrec::HasPermission(const std::string &command)
533 * users on remote servers can completely bypass all permissions based checks.
534 * This prevents desyncs when one server has different type/class tags to another.
535 * That having been said, this does open things up to the possibility of source changes
536 * allowing remote kills, etc - but if they have access to the src, they most likely have
537 * access to the conf - so it's an end to a means either way.
542 // are they even an oper at all?
545 opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
546 if (iter_opertype != ServerInstance->Config->opertypes.end())
548 char* Classes = strdup(iter_opertype->second);
549 char* myclass = strtok_r(Classes," ",&savept);
552 operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
553 if (iter_operclass != ServerInstance->Config->operclass.end())
555 char* CommandList = strdup(iter_operclass->second);
556 mycmd = strtok_r(CommandList," ",&savept2);
559 if ((!strcasecmp(mycmd,command.c_str())) || (*mycmd == '*'))
565 mycmd = strtok_r(NULL," ",&savept2);
569 myclass = strtok_r(NULL," ",&savept);
577 /** NOTE: We cannot pass a const reference to this method.
578 * The string is changed by the workings of the method,
579 * so that if we pass const ref, we end up copying it to
580 * something we can change anyway. Makes sense to just let
581 * the compiler do that copy for us.
583 bool userrec::AddBuffer(std::string a)
587 std::string::size_type i = a.rfind('\r');
589 while (i != std::string::npos)
598 if (recvq.length() > (unsigned)this->recvqmax)
600 this->SetWriteError("RecvQ exceeded");
601 ServerInstance->WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
610 ServerInstance->Log(DEBUG,"Exception in userrec::AddBuffer()");
615 bool userrec::BufferIsReady()
617 return (recvq.find('\n') != std::string::npos);
620 void userrec::ClearBuffer()
625 std::string userrec::GetBuffer()
632 /* Strip any leading \r or \n off the string.
633 * Usually there are only one or two of these,
634 * so its is computationally cheap to do.
636 while ((*recvq.begin() == '\r') || (*recvq.begin() == '\n'))
637 recvq.erase(recvq.begin());
639 for (std::string::iterator x = recvq.begin(); x != recvq.end(); x++)
641 /* Find the first complete line, return it as the
642 * result, and leave the recvq as whats left
646 std::string ret = std::string(recvq.begin(), x);
647 recvq.erase(recvq.begin(), x + 1);
656 ServerInstance->Log(DEBUG,"Exception in userrec::GetBuffer()");
661 void userrec::AddWriteBuf(const std::string &data)
663 if (*this->GetWriteError())
666 if (sendq.length() + data.length() > (unsigned)this->sendqmax)
669 * Fix by brain - Set the error text BEFORE calling writeopers, because
670 * if we dont it'll recursively call here over and over again trying
671 * to repeatedly add the text to the sendq!
673 this->SetWriteError("SendQ exceeded");
674 ServerInstance->WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
680 if (data.length() > 512)
681 sendq.append(data.substr(0,510)).append("\r\n");
687 this->SetWriteError("SendQ exceeded");
688 ServerInstance->WriteOpers("*** User %s SendQ got an exception",this->nick);
692 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
693 void userrec::FlushWriteBuf()
697 if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
701 if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
703 int old_sendq_length = sendq.length();
704 int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
709 /* The socket buffer is full. This isnt fatal,
712 ServerInstance->Log(DEBUG,"EAGAIN, want write");
713 this->ServerInstance->SE->WantWrite(this);
717 /* Fatal error, set write error and bail
719 this->SetWriteError(strerror(errno));
725 /* advance the queue */
727 this->sendq = this->sendq.substr(n_sent);
728 /* update the user's stats counters */
729 this->bytes_out += n_sent;
731 if (n_sent != old_sendq_length)
733 ServerInstance->Log(DEBUG,"Not all written, want write");
734 this->ServerInstance->SE->WantWrite(this);
742 ServerInstance->Log(DEBUG,"Exception in userrec::FlushWriteBuf()");
746 void userrec::SetWriteError(const std::string &error)
750 // don't try to set the error twice, its already set take the first string.
751 if (this->WriteError.empty())
753 ServerInstance->Log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
754 this->WriteError = error;
760 ServerInstance->Log(DEBUG,"Exception in userrec::SetWriteError()");
764 const char* userrec::GetWriteError()
766 return this->WriteError.c_str();
769 void userrec::Oper(const std::string &opertype)
773 this->modes[UM_OPERATOR] = 1;
774 this->WriteServ("MODE %s :+o", this->nick);
775 FOREACH_MOD(I_OnOper, OnOper(this, opertype));
776 ServerInstance->Log(DEFAULT,"OPER: %s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str());
777 strlcpy(this->oper, opertype.c_str(), NICKMAX - 1);
778 ServerInstance->all_opers.push_back(this);
779 FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype));
784 ServerInstance->Log(DEBUG,"Exception in userrec::Oper()");
788 void userrec::UnOper()
795 this->modes[UM_OPERATOR] = 0;
796 for (std::vector<userrec*>::iterator a = ServerInstance->all_opers.begin(); a < ServerInstance->all_opers.end(); a++)
800 ServerInstance->Log(DEBUG,"Oper removed from optimization list");
801 ServerInstance->all_opers.erase(a);
810 ServerInstance->Log(DEBUG,"Exception in userrec::UnOper()");
814 void userrec::QuitUser(InspIRCd* Instance, userrec *user, const std::string &quitreason)
816 user_hash::iterator iter = Instance->clientlist->find(user->nick);
817 std::string reason = quitreason;
819 if (reason.length() > MAXQUIT - 1)
820 reason.resize(MAXQUIT - 1);
822 if (user->registered != REG_ALL)
823 if (Instance->unregistered_count)
824 Instance->unregistered_count--;
828 user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str());
829 if ((!user->sendq.empty()) && (!(*user->GetWriteError())))
830 user->FlushWriteBuf();
833 if (user->registered == REG_ALL)
835 user->PurgeEmptyChannels();
836 user->WriteCommonExcept("QUIT :%s",reason.c_str());
837 FOREACH_MOD_I(Instance,I_OnUserQuit,OnUserQuit(user,reason));
840 FOREACH_MOD_I(Instance,I_OnUserDisconnect,OnUserDisconnect(user));
844 if (Instance->Config->GetIOHook(user->GetPort()))
848 Instance->Config->GetIOHook(user->GetPort())->OnRawSocketClose(user->fd);
850 catch (CoreException& modexcept)
852 Instance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
856 Instance->SE->DelFd(user);
861 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
862 * if they were an oper with +sn +qQ.
864 if (user->registered == REG_ALL)
867 Instance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
869 Instance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,reason.c_str());
873 if (iter != Instance->clientlist->end())
875 Instance->Log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
878 std::vector<userrec*>::iterator x = find(Instance->local_users.begin(),Instance->local_users.end(),user);
879 if (x != Instance->local_users.end())
880 Instance->local_users.erase(x);
882 Instance->clientlist->erase(iter);
888 /* adds or updates an entry in the whowas list */
889 void userrec::AddToWhoWas()
891 command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
894 std::deque<classbase*> params;
895 params.push_back(this);
896 whowas_command->HandleInternal(WHOWAS_ADD, params);
900 /* add a client connection to the sockets list */
901 void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, insp_inaddr ip)
903 std::string tempnick = ConvToStr(socket) + "-unknown";
904 user_hash::iterator iter = Instance->clientlist->find(tempnick);
905 const char *ipaddr = insp_ntoa(ip);
909 Instance->unregistered_count++;
913 * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
914 * using one as a registered connection. As they are per fd, we can also safely assume
915 * that we wont have collisions. Therefore, if the nick exists in the list, its only
916 * used by a dead socket, erase the iterator so that the new client may reclaim it.
917 * this was probably the cause of 'server ignores me when i hammer it with reconnects'
918 * issue in earlier alphas/betas
920 if (iter != Instance->clientlist->end())
922 userrec* goner = iter->second;
924 Instance->clientlist->erase(iter);
927 Instance->Log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr);
929 New = new userrec(Instance);
930 (*(Instance->clientlist))[tempnick] = New;
932 strlcpy(New->nick,tempnick.c_str(),NICKMAX-1);
934 New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);
935 /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
936 strcpy(New->ident, "unknown");
938 New->registered = REG_NONE;
939 New->signon = Instance->Time() + Instance->Config->dns_timeout;
942 New->SetSockAddr(AF_FAMILY, ipaddr, port);
944 /* Smarter than your average bear^H^H^H^Hset of strlcpys. */
945 for (const char* temp = New->GetIPString(); *temp && j < 64; temp++, j++)
946 New->dhost[j] = New->host[j] = *temp;
947 New->dhost[j] = New->host[j] = 0;
949 Instance->AddLocalClone(New);
950 Instance->AddGlobalClone(New);
952 ConnectClass* i = New->GetClass();
954 if ((!i) || (i->GetType() == CC_DENY))
956 userrec::QuitUser(Instance, New,"Unauthorised connection");
960 New->pingmax = i->GetPingTime();
961 New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
962 New->timeout = Instance->Time() + i->GetRegTimeout();
963 New->flood = i->GetFlood();
964 New->threshold = i->GetThreshold();
965 New->sendqmax = i->GetSendqMax();
966 New->recvqmax = i->GetRecvqMax();
968 Instance->local_users.push_back(New);
970 if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
972 Instance->WriteOpers("*** Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
973 userrec::QuitUser(Instance, New,"No more connections allowed");
979 * this is done as a safety check to keep the file descriptors within range of fd_ref_table.
980 * its a pretty big but for the moment valid assumption:
981 * file descriptors are handed out starting at 0, and are recycled as theyre freed.
982 * therefore if there is ever an fd over 65535, 65536 clients must be connected to the
983 * irc server at once (or the irc server otherwise initiating this many connections, files etc)
984 * which for the time being is a physical impossibility (even the largest networks dont have more
985 * than about 10,000 users on ONE server!)
987 if ((unsigned int)socket >= MAX_DESCRIPTORS)
989 userrec::QuitUser(Instance, New, "Server is full");
993 New->exempt = (Instance->XLines->matches_exception(New) != NULL);
996 ZLine* r = Instance->XLines->matches_zline(ipaddr);
1000 snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
1001 userrec::QuitUser(Instance, New, reason);
1008 if (!Instance->SE->AddFd(New))
1010 userrec::QuitUser(Instance, New, "Internal error handling connection");
1015 /* NOTE: even if dns lookups are *off*, we still need to display this.
1016 * BOPM and other stuff requires it.
1018 New->WriteServ("NOTICE Auth :*** Looking up your hostname...");
1021 unsigned long userrec::GlobalCloneCount()
1023 clonemap::iterator x = ServerInstance->global_clones.find(this->GetIPString());
1024 if (x != ServerInstance->global_clones.end())
1030 unsigned long userrec::LocalCloneCount()
1032 clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
1033 if (x != ServerInstance->local_clones.end())
1039 void userrec::FullConnect(CullList* Goners)
1041 ServerInstance->stats->statsConnects++;
1042 this->idle_lastmsg = ServerInstance->Time();
1044 ConnectClass* a = this->GetClass();
1046 if ((!a) || (a->GetType() == CC_DENY))
1048 Goners->AddItem(this,"Unauthorised connection");
1052 if ((!a->GetPass().empty()) && (!this->haspassed))
1054 Goners->AddItem(this,"Invalid password");
1058 if (this->LocalCloneCount() > a->GetMaxLocal())
1060 Goners->AddItem(this, "No more connections allowed from your host via this connect class (local)");
1061 ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
1064 else if (this->GlobalCloneCount() > a->GetMaxGlobal())
1066 Goners->AddItem(this, "No more connections allowed from your host via this connect class (global)");
1067 ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a->GetMaxGlobal(), this->GetIPString());
1073 GLine* r = ServerInstance->XLines->matches_gline(this);
1077 char reason[MAXBUF];
1078 snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
1079 Goners->AddItem(this, reason);
1083 KLine* n = ServerInstance->XLines->matches_kline(this);
1087 char reason[MAXBUF];
1088 snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
1089 Goners->AddItem(this, reason);
1095 this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network);
1096 this->WriteServ("001 %s :Welcome to the %s IRC Network %s!%s@%s",this->nick, ServerInstance->Config->Network, this->nick, this->ident, this->host);
1097 this->WriteServ("002 %s :Your host is %s, running version %s",this->nick,ServerInstance->Config->ServerName,VERSION);
1098 this->WriteServ("003 %s :This server was created %s %s", this->nick, __TIME__, __DATE__);
1099 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());
1101 ServerInstance->Config->Send005(this);
1105 /* Now registered */
1106 if (ServerInstance->unregistered_count)
1107 ServerInstance->unregistered_count--;
1110 * fix 3 by brain, move registered = 7 below these so that spurious modes and host
1111 * changes dont go out onto the network and produce 'fake direction'.
1113 FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
1115 this->registered = REG_ALL;
1117 FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
1119 ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
1122 /** userrec::UpdateNick()
1123 * re-allocates a nick in the user_hash after they change nicknames,
1124 * returns a pointer to the new user as it may have moved
1126 userrec* userrec::UpdateNickHash(const char* New)
1130 //user_hash::iterator newnick;
1131 user_hash::iterator oldnick = ServerInstance->clientlist->find(this->nick);
1133 if (!strcasecmp(this->nick,New))
1134 return oldnick->second;
1136 if (oldnick == ServerInstance->clientlist->end())
1137 return NULL; /* doesnt exist */
1139 userrec* olduser = oldnick->second;
1140 (*(ServerInstance->clientlist))[New] = olduser;
1141 ServerInstance->clientlist->erase(oldnick);
1147 ServerInstance->Log(DEBUG,"Exception in userrec::UpdateNickHash()");
1152 void userrec::InvalidateCache()
1154 /* Invalidate cache */
1155 if (cached_fullhost)
1156 free(cached_fullhost);
1158 free(cached_hostip);
1159 if (cached_makehost)
1160 free(cached_makehost);
1161 if (cached_fullrealhost)
1162 free(cached_fullrealhost);
1163 cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
1166 bool userrec::ForceNickChange(const char* newnick)
1172 this->InvalidateCache();
1174 FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
1178 ServerInstance->stats->statsCollisions++;
1182 if (ServerInstance->XLines->matches_qline(newnick))
1184 ServerInstance->stats->statsCollisions++;
1188 if (this->registered == REG_ALL)
1190 const char* pars[1];
1192 std::string cmd = "NICK";
1193 return (ServerInstance->Parser->CallHandler(cmd, pars, 1, this) == CMD_SUCCESS);
1200 ServerInstance->Log(DEBUG,"Exception in userrec::ForceNickChange()");
1205 void userrec::SetSockAddr(int protocol_family, const char* ip, int port)
1207 switch (protocol_family)
1209 #ifdef SUPPORT_IP6LINKS
1212 ServerInstance->Log(DEBUG,"Set inet6 protocol address");
1213 sockaddr_in6* sin = new sockaddr_in6;
1214 sin->sin6_family = AF_INET6;
1215 sin->sin6_port = port;
1216 inet_pton(AF_INET6, ip, &sin->sin6_addr);
1217 this->ip = (sockaddr*)sin;
1223 ServerInstance->Log(DEBUG,"Set inet4 protocol address");
1224 sockaddr_in* sin = new sockaddr_in;
1225 sin->sin_family = AF_INET;
1226 sin->sin_port = port;
1227 inet_pton(AF_INET, ip, &sin->sin_addr);
1228 this->ip = (sockaddr*)sin;
1232 ServerInstance->Log(DEBUG,"Ut oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick);
1237 int userrec::GetPort()
1239 if (this->ip == NULL)
1242 switch (this->GetProtocolFamily())
1244 #ifdef SUPPORT_IP6LINKS
1247 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1248 return sin->sin6_port;
1254 sockaddr_in* sin = (sockaddr_in*)this->ip;
1255 return sin->sin_port;
1264 int userrec::GetProtocolFamily()
1266 if (this->ip == NULL)
1269 sockaddr_in* sin = (sockaddr_in*)this->ip;
1270 return sin->sin_family;
1273 const char* userrec::GetIPString()
1275 static char buf[1024];
1277 if (this->ip == NULL)
1280 switch (this->GetProtocolFamily())
1282 #ifdef SUPPORT_IP6LINKS
1285 static char temp[1024];
1287 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1288 inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
1289 /* IP addresses starting with a : on irc are a Bad Thing (tm) */
1292 strlcpy(&temp[1], buf, sizeof(temp) - 1);
1302 sockaddr_in* sin = (sockaddr_in*)this->ip;
1303 inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
1313 const char* userrec::GetIPString(char* buf)
1315 if (this->ip == NULL)
1321 switch (this->GetProtocolFamily())
1323 #ifdef SUPPORT_IP6LINKS
1326 static char temp[1024];
1328 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1329 inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
1330 /* IP addresses starting with a : on irc are a Bad Thing (tm) */
1333 strlcpy(&temp[1], buf, sizeof(temp) - 1);
1335 strlcpy(buf, temp, sizeof(temp));
1343 sockaddr_in* sin = (sockaddr_in*)this->ip;
1344 inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
1355 /** NOTE: We cannot pass a const reference to this method.
1356 * The string is changed by the workings of the method,
1357 * so that if we pass const ref, we end up copying it to
1358 * something we can change anyway. Makes sense to just let
1359 * the compiler do that copy for us.
1361 void userrec::Write(std::string text)
1363 if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
1368 text.append("\r\n");
1372 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
1376 if (ServerInstance->Config->GetIOHook(this->GetPort()))
1380 ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
1382 catch (CoreException& modexcept)
1384 ServerInstance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
1389 this->AddWriteBuf(text);
1391 ServerInstance->stats->statsSent += text.length();
1392 this->ServerInstance->SE->WantWrite(this);
1397 void userrec::Write(const char *text, ...)
1400 char textbuffer[MAXBUF];
1402 va_start(argsPtr, text);
1403 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1406 this->Write(std::string(textbuffer));
1409 void userrec::WriteServ(const std::string& text)
1411 char textbuffer[MAXBUF];
1413 snprintf(textbuffer,MAXBUF,":%s %s",ServerInstance->Config->ServerName,text.c_str());
1414 this->Write(std::string(textbuffer));
1418 * Same as Write(), except `text' is prefixed with `:server.name '.
1420 void userrec::WriteServ(const char* text, ...)
1423 char textbuffer[MAXBUF];
1425 va_start(argsPtr, text);
1426 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1429 this->WriteServ(std::string(textbuffer));
1433 void userrec::WriteFrom(userrec *user, const std::string &text)
1437 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
1439 this->Write(std::string(tb));
1443 /* write text from an originating user to originating user */
1445 void userrec::WriteFrom(userrec *user, const char* text, ...)
1448 char textbuffer[MAXBUF];
1450 va_start(argsPtr, text);
1451 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1454 this->WriteFrom(user, std::string(textbuffer));
1458 /* write text to an destination user from a source user (e.g. user privmsg) */
1460 void userrec::WriteTo(userrec *dest, const char *data, ...)
1462 char textbuffer[MAXBUF];
1465 va_start(argsPtr, data);
1466 vsnprintf(textbuffer, MAXBUF, data, argsPtr);
1469 this->WriteTo(dest, std::string(textbuffer));
1472 void userrec::WriteTo(userrec *dest, const std::string &data)
1474 dest->WriteFrom(this, data);
1478 void userrec::WriteCommon(const char* text, ...)
1480 char textbuffer[MAXBUF];
1483 if (this->registered != REG_ALL)
1486 va_start(argsPtr, text);
1487 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1490 this->WriteCommon(std::string(textbuffer));
1493 void userrec::WriteCommon(const std::string &text)
1497 bool sent_to_at_least_one = false;
1500 if (this->registered != REG_ALL)
1505 /* We dont want to be doing this n times, just once */
1506 snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
1507 std::string out = tb;
1509 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
1511 CUList* ulist = v->first->GetUsers();
1512 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
1514 if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
1516 already_sent[i->second->fd] = uniq_id;
1517 i->second->Write(out);
1518 sent_to_at_least_one = true;
1524 * if the user was not in any channels, no users will receive the text. Make sure the user
1525 * receives their OWN message for WriteCommon
1527 if (!sent_to_at_least_one)
1529 this->Write(std::string(tb));
1535 ServerInstance->Log(DEBUG,"Exception in userrec::WriteCommon()");
1540 /* write a formatted string to all users who share at least one common
1541 * channel, NOT including the source user e.g. for use in QUIT
1544 void userrec::WriteCommonExcept(const char* text, ...)
1546 char textbuffer[MAXBUF];
1549 va_start(argsPtr, text);
1550 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1553 this->WriteCommonExcept(std::string(textbuffer));
1556 void userrec::WriteCommonExcept(const std::string &text)
1558 bool quit_munge = false;
1559 char oper_quit[MAXBUF];
1560 char textbuffer[MAXBUF];
1566 strlcpy(textbuffer, text.c_str(), MAXBUF);
1568 if (this->registered != REG_ALL)
1573 snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),textbuffer);
1575 /* TODO: We need some form of WriteCommonExcept that will send two lines, one line to
1576 * opers and the other line to non-opers, then all this hidebans and hidesplits gunk
1579 if (ServerInstance->Config->HideSplits)
1581 char* check = textbuffer + 6;
1583 if (!strncasecmp(textbuffer, "QUIT :",6))
1585 std::stringstream split(check);
1586 std::string server_one;
1587 std::string server_two;
1589 split >> server_one;
1590 split >> server_two;
1592 if ((ServerInstance->FindServerName(server_one)) && (ServerInstance->FindServerName(server_two)))
1594 strlcpy(oper_quit,textbuffer,MAXQUIT);
1595 strlcpy(check,"*.net *.split",MAXQUIT);
1597 snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
1603 if ((ServerInstance->Config->HideBans) && (!quit_munge))
1605 if ((!strncasecmp(textbuffer, "QUIT :G-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :K-Lined:",14))
1606 || (!strncasecmp(textbuffer, "QUIT :Q-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :Z-Lined:",14)))
1608 char* check = textbuffer + 13;
1609 strlcpy(oper_quit,textbuffer,MAXQUIT);
1610 *check = 0; // We don't need to strlcpy, we just chop it from the :
1612 snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
1619 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
1621 CUList *ulist = v->first->GetUsers();
1622 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
1624 if (this != i->second)
1626 if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
1628 already_sent[i->second->fd] = uniq_id;
1630 i->second->Write(*i->second->oper ? out2 : out1);
1632 i->second->Write(out1);
1640 void userrec::WriteWallOps(const std::string &text)
1642 /* Does nothing if theyre not opered */
1643 if ((!*this->oper) && (IS_LOCAL(this)))
1646 std::string wallop = "WALLOPS :";
1650 wallop.append(text);
1654 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
1658 for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
1661 if ((IS_LOCAL(t)) && (t->modes[UM_WALLOPS]))
1662 this->WriteTo(t,wallop);
1666 void userrec::WriteWallOps(const char* text, ...)
1668 char textbuffer[MAXBUF];
1671 va_start(argsPtr, text);
1672 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1675 this->WriteWallOps(std::string(textbuffer));
1678 /* return 0 or 1 depending if users u and u2 share one or more common channels
1679 * (used by QUIT, NICK etc which arent channel specific notices)
1681 * The old algorithm in 1.0 for this was relatively inefficient, iterating over
1682 * the first users channels then the second users channels within the outer loop,
1683 * therefore it was a maximum of x*y iterations (upon returning 0 and checking
1684 * all possible iterations). However this new function instead checks against the
1685 * channel's userlist in the inner loop which is a std::map<userrec*,userrec*>
1686 * and saves us time as we already know what pointer value we are after.
1687 * Don't quote me on the maths as i am not a mathematician or computer scientist,
1688 * but i believe this algorithm is now x+(log y) maximum iterations instead.
1690 bool userrec::SharesChannelWith(userrec *other)
1692 if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
1696 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1698 /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
1699 * by replacing it with a map::find which *should* be more efficient
1701 if (i->first->HasUser(other))
1707 bool userrec::ChangeName(const char* gecos)
1709 if (!strcmp(gecos, this->fullname))
1715 FOREACH_RESULT(I_OnChangeLocalUserGECOS,OnChangeLocalUserGECOS(this,gecos));
1718 FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos));
1720 strlcpy(this->fullname,gecos,MAXGECOS+1);
1725 bool userrec::ChangeDisplayedHost(const char* host)
1727 if (!strcmp(host, this->dhost))
1733 FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(this,host));
1736 FOREACH_MOD(I_OnChangeHost,OnChangeHost(this,host));
1738 if (this->ServerInstance->Config->CycleHosts)
1739 this->WriteCommonExcept("QUIT :Changing hosts");
1741 /* Fix by Om: userrec::dhost is 65 long, this was truncating some long hosts */
1742 strlcpy(this->dhost,host,64);
1744 this->InvalidateCache();
1746 if (this->ServerInstance->Config->CycleHosts)
1748 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1750 i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
1751 std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
1753 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
1758 this->WriteServ("396 %s %s :is now your hidden host",this->nick,this->dhost);
1763 bool userrec::ChangeIdent(const char* newident)
1765 if (!strcmp(newident, this->ident))
1768 if (this->ServerInstance->Config->CycleHosts)
1769 this->WriteCommonExcept("%s","QUIT :Changing ident");
1771 strlcpy(this->ident, newident, IDENTMAX+2);
1773 this->InvalidateCache();
1775 if (this->ServerInstance->Config->CycleHosts)
1777 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1779 i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
1780 std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
1782 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
1789 void userrec::NoticeAll(char* text, ...)
1791 char textbuffer[MAXBUF];
1792 char formatbuffer[MAXBUF];
1795 va_start(argsPtr, text);
1796 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1799 snprintf(formatbuffer,MAXBUF,":%s NOTICE $* :%s", this->GetFullHost(), textbuffer);
1800 std::string fmt = formatbuffer;
1802 for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
1809 std::string userrec::ChannelList(userrec* source)
1814 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1816 /* If the target is the same as the sender, let them see all their channels.
1817 * If the channel is NOT private/secret OR the user shares a common channel
1818 * If the user is an oper, and the <options:operspywhois> option is set.
1820 if ((source == this) || (*source->oper && ServerInstance->Config->OperSpyWhois) || (((!i->first->modes[CM_PRIVATE]) && (!i->first->modes[CM_SECRET])) || (i->first->HasUser(source))))
1822 list.append(i->first->GetPrefixChar(this)).append(i->first->name).append(" ");
1829 ServerInstance->Log(DEBUG,"Exception in userrec::ChannelList()");
1834 void userrec::SplitChanList(userrec* dest, const std::string &cl)
1837 std::ostringstream prefix;
1838 std::string::size_type start, pos, length;
1842 prefix << this->nick << " " << dest->nick << " :";
1843 line = prefix.str();
1844 int namelen = strlen(ServerInstance->Config->ServerName) + 6;
1846 for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
1848 length = (pos == std::string::npos) ? cl.length() : pos;
1850 if (line.length() + namelen + length - start > 510)
1852 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
1853 line = prefix.str();
1856 if(pos == std::string::npos)
1858 line.append(cl.substr(start, length - start));
1863 line.append(cl.substr(start, length - start + 1));
1869 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
1875 ServerInstance->Log(DEBUG,"Exception in userrec::SplitChanList()");
1880 /* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
1881 * NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
1882 * then their ip will be taken as 'priority' anyway, so for example,
1883 * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
1885 ConnectClass* userrec::GetClass()
1887 for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
1889 if ((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str())))
1895 void userrec::PurgeEmptyChannels()
1897 std::vector<chanrec*> to_delete;
1899 // firstly decrement the count on each channel
1900 for (UCListIter f = this->chans.begin(); f != this->chans.end(); f++)
1902 f->first->RemoveAllPrefixes(this);
1903 if (f->first->DelUser(this) == 0)
1905 /* No users left in here, mark it for deletion */
1908 to_delete.push_back(f->first);
1912 ServerInstance->Log(DEBUG,"Exception in userrec::PurgeEmptyChannels to_delete.push_back()");
1917 for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
1919 chanrec* thischan = *n;
1920 chan_hash::iterator i2 = ServerInstance->chanlist->find(thischan->name);
1921 if (i2 != ServerInstance->chanlist->end())
1923 FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
1925 ServerInstance->chanlist->erase(i2);
1926 this->chans.erase(*n);
1933 void userrec::ShowMOTD()
1935 if (!ServerInstance->Config->MOTD.size())
1937 this->WriteServ("422 %s :Message of the day file is missing.",this->nick);
1940 this->WriteServ("375 %s :%s message of the day", this->nick, ServerInstance->Config->ServerName);
1942 for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
1943 this->WriteServ("372 %s :- %s",this->nick,i->c_str());
1945 this->WriteServ("376 %s :End of message of the day.", this->nick);
1948 void userrec::ShowRULES()
1950 if (!ServerInstance->Config->RULES.size())
1952 this->WriteServ("NOTICE %s :Rules file is missing.",this->nick);
1955 this->WriteServ("NOTICE %s :%s rules",this->nick,ServerInstance->Config->ServerName);
1957 for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
1958 this->WriteServ("NOTICE %s :%s",this->nick,i->c_str());
1960 this->WriteServ("NOTICE %s :End of %s rules.",this->nick,ServerInstance->Config->ServerName);
1963 void userrec::HandleEvent(EventType et, int errornum)
1965 /* WARNING: May delete this user! */
1966 int thisfd = this->GetFd();
1973 ServerInstance->ProcessUser(this);
1976 this->FlushWriteBuf();
1979 /** This should be safe, but dont DARE do anything after it -- Brain */
1980 this->SetWriteError(errornum ? strerror(errornum) : "EOF from client");
1986 ServerInstance->Log(DEBUG,"Exception in userrec::HandleEvent intercepted");
1989 /* If the user has raised an error whilst being processed, quit them now we're safe to */
1990 if ((ServerInstance->SE->GetRef(thisfd) == this))
1992 if (!WriteError.empty())
1994 userrec::QuitUser(ServerInstance, this, GetWriteError());