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);
156 this->ServerInstance->AddResolver(res_reverse, cached);
158 catch (CoreException& e)
160 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
164 UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt, bool &cache) :
165 Resolver(Instance, to_resolve, qt, cache), bound_user(user)
167 this->fwd = (qt == DNS_QUERY_A || qt == DNS_QUERY_AAAA);
168 this->bound_fd = user->GetFd();
171 void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
173 if ((!this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
175 ServerInstance->Log(DEBUG,"Commencing forward lookup");
176 this->bound_user->stored_host = result;
179 /* Check we didnt time out */
180 if (this->bound_user->registered != REG_ALL)
184 const char *ip = this->bound_user->GetIPString();
185 bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, (strstr(ip,"0::ffff:") == ip ? DNS_QUERY_A : DNS_QUERY_AAAA), cached);
187 bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, cached);
189 this->ServerInstance->AddResolver(bound_user->res_forward, cached);
192 catch (CoreException& e)
194 ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
197 else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
199 /* Both lookups completed */
200 std::string result2 = "0::ffff:";
201 result2.append(result);
202 if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2)
204 std::string hostname = this->bound_user->stored_host;
205 if (hostname.length() < 65)
207 /* Check we didnt time out */
208 if (this->bound_user->registered != REG_ALL)
210 /* Hostnames starting with : are not a good thing (tm) */
211 if (*(hostname.c_str()) == ':')
212 hostname = "0" + hostname;
214 this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname.c_str(), (cached ? " -- cached" : ""));
215 this->bound_user->dns_done = true;
216 strlcpy(this->bound_user->dhost, hostname.c_str(),64);
217 strlcpy(this->bound_user->host, hostname.c_str(),64);
218 /* Invalidate cache */
219 this->bound_user->InvalidateCache();
224 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());
229 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());
234 void UserResolver::OnError(ResolverError e, const std::string &errormessage)
236 if (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user)
238 /* Error message here */
239 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());
240 this->bound_user->dns_done = true;
245 bool userrec::IsNoticeMaskSet(unsigned char sm)
247 return (snomasks[sm-65]);
250 void userrec::SetNoticeMask(unsigned char sm, bool value)
252 snomasks[sm-65] = value;
255 const char* userrec::FormatNoticeMasks()
257 static char data[MAXBUF];
260 for (int n = 0; n < 64; n++)
263 data[offset++] = n+65;
272 bool userrec::IsModeSet(unsigned char m)
274 return (modes[m-65]);
277 void userrec::SetMode(unsigned char m, bool value)
282 const char* userrec::FormatModes()
284 static char data[MAXBUF];
286 for (int n = 0; n < 64; n++)
289 data[offset++] = n+65;
295 void userrec::DecrementModes()
297 for (int n = 0; n < 64; n++)
301 ModeHandler* mh = ServerInstance->Modes->FindMode(n+65, MODETYPE_USER);
308 userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
310 ServerInstance->Log(DEBUG,"userrec::userrec(): Instance: %08x",ServerInstance);
311 // the PROPER way to do it, AVOID bzero at *ALL* costs
312 *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = 0;
313 server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName);
314 reset_due = ServerInstance->Time();
315 age = ServerInstance->Time(true);
316 lines_in = lastping = signon = idle_lastmsg = nping = registered = 0;
317 ChannelCount = timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0;
318 exempt = haspassed = dns_done = false;
323 res_forward = res_reverse = NULL;
327 memset(modes,0,sizeof(modes));
328 memset(snomasks,0,sizeof(snomasks));
329 /* Invalidate cache */
330 cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
335 this->InvalidateCache();
336 this->DecrementModes();
339 clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
340 if (x != ServerInstance->local_clones.end())
345 ServerInstance->local_clones.erase(x);
349 clonemap::iterator y = ServerInstance->global_clones.find(this->GetIPString());
350 if (y != ServerInstance->global_clones.end())
355 ServerInstance->global_clones.erase(y);
359 if (this->GetProtocolFamily() == AF_INET)
361 delete (sockaddr_in*)ip;
363 #ifdef SUPPORT_IP6LINKS
366 delete (sockaddr_in6*)ip;
372 char* userrec::MakeHost()
374 if (this->cached_makehost)
375 return this->cached_makehost;
378 /* This is much faster than snprintf */
380 for(char* n = ident; *n; n++)
383 for(char* n = host; *n; n++)
387 this->cached_makehost = strdup(nhost);
389 return this->cached_makehost;
392 char* userrec::MakeHostIP()
394 if (this->cached_hostip)
395 return this->cached_hostip;
398 /* This is much faster than snprintf */
400 for(char* n = ident; *n; n++)
403 for(const char* n = this->GetIPString(); *n; n++)
407 this->cached_hostip = strdup(ihost);
409 return this->cached_hostip;
412 void userrec::CloseSocket()
414 shutdown(this->fd,2);
418 char* userrec::GetFullHost()
420 if (this->cached_fullhost)
421 return this->cached_fullhost;
425 for(char* n = nick; *n; n++)
428 for(char* n = ident; *n; n++)
431 for(char* n = dhost; *n; n++)
435 this->cached_fullhost = strdup(result);
437 return this->cached_fullhost;
440 char* userrec::MakeWildHost()
442 static char nresult[MAXBUF];
444 *t++ = '*'; *t++ = '!';
445 *t++ = '*'; *t++ = '@';
446 for(char* n = dhost; *n; n++)
452 int userrec::ReadData(void* buffer, size_t size)
456 return read(this->fd, buffer, size);
463 char* userrec::GetFullRealHost()
465 if (this->cached_fullrealhost)
466 return this->cached_fullrealhost;
468 char fresult[MAXBUF];
470 for(char* n = nick; *n; n++)
473 for(char* n = ident; *n; n++)
476 for(char* n = host; *n; n++)
480 this->cached_fullrealhost = strdup(fresult);
482 return this->cached_fullrealhost;
485 bool userrec::IsInvited(const irc::string &channel)
487 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
497 InvitedList* userrec::GetInviteList()
502 void userrec::InviteTo(const irc::string &channel)
504 invites.push_back(channel);
507 void userrec::RemoveInvite(const irc::string &channel)
509 ServerInstance->Log(DEBUG,"Removing invites");
510 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
520 bool userrec::HasPermission(const std::string &command)
527 * users on remote servers can completely bypass all permissions based checks.
528 * This prevents desyncs when one server has different type/class tags to another.
529 * That having been said, this does open things up to the possibility of source changes
530 * allowing remote kills, etc - but if they have access to the src, they most likely have
531 * access to the conf - so it's an end to a means either way.
536 // are they even an oper at all?
539 opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
540 if (iter_opertype != ServerInstance->Config->opertypes.end())
542 char* Classes = strdup(iter_opertype->second);
543 char* myclass = strtok_r(Classes," ",&savept);
546 operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass);
547 if (iter_operclass != ServerInstance->Config->operclass.end())
549 char* CommandList = strdup(iter_operclass->second);
550 mycmd = strtok_r(CommandList," ",&savept2);
553 if ((!strcasecmp(mycmd,command.c_str())) || (*mycmd == '*'))
559 mycmd = strtok_r(NULL," ",&savept2);
563 myclass = strtok_r(NULL," ",&savept);
571 /** NOTE: We cannot pass a const reference to this method.
572 * The string is changed by the workings of the method,
573 * so that if we pass const ref, we end up copying it to
574 * something we can change anyway. Makes sense to just let
575 * the compiler do that copy for us.
577 bool userrec::AddBuffer(std::string a)
581 std::string::size_type i = a.rfind('\r');
583 while (i != std::string::npos)
592 if (recvq.length() > (unsigned)this->recvqmax)
594 this->SetWriteError("RecvQ exceeded");
595 ServerInstance->WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
604 ServerInstance->Log(DEBUG,"Exception in userrec::AddBuffer()");
609 bool userrec::BufferIsReady()
611 return (recvq.find('\n') != std::string::npos);
614 void userrec::ClearBuffer()
619 std::string userrec::GetBuffer()
626 /* Strip any leading \r or \n off the string.
627 * Usually there are only one or two of these,
628 * so its is computationally cheap to do.
630 while ((*recvq.begin() == '\r') || (*recvq.begin() == '\n'))
631 recvq.erase(recvq.begin());
633 for (std::string::iterator x = recvq.begin(); x != recvq.end(); x++)
635 /* Find the first complete line, return it as the
636 * result, and leave the recvq as whats left
640 std::string ret = std::string(recvq.begin(), x);
641 recvq.erase(recvq.begin(), x + 1);
650 ServerInstance->Log(DEBUG,"Exception in userrec::GetBuffer()");
655 void userrec::AddWriteBuf(const std::string &data)
657 if (*this->GetWriteError())
660 if (sendq.length() + data.length() > (unsigned)this->sendqmax)
663 * Fix by brain - Set the error text BEFORE calling writeopers, because
664 * if we dont it'll recursively call here over and over again trying
665 * to repeatedly add the text to the sendq!
667 this->SetWriteError("SendQ exceeded");
668 ServerInstance->WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
674 if (data.length() > 512)
675 sendq.append(data.substr(0,510)).append("\r\n");
681 this->SetWriteError("SendQ exceeded");
682 ServerInstance->WriteOpers("*** User %s SendQ got an exception",this->nick);
686 // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
687 void userrec::FlushWriteBuf()
691 if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
695 if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
697 int old_sendq_length = sendq.length();
698 int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
703 /* The socket buffer is full. This isnt fatal,
706 ServerInstance->Log(DEBUG,"EAGAIN, want write");
707 this->ServerInstance->SE->WantWrite(this);
711 /* Fatal error, set write error and bail
713 this->SetWriteError(strerror(errno));
719 /* advance the queue */
721 this->sendq = this->sendq.substr(n_sent);
722 /* update the user's stats counters */
723 this->bytes_out += n_sent;
725 if (n_sent != old_sendq_length)
727 ServerInstance->Log(DEBUG,"Not all written, want write");
728 this->ServerInstance->SE->WantWrite(this);
736 ServerInstance->Log(DEBUG,"Exception in userrec::FlushWriteBuf()");
740 void userrec::SetWriteError(const std::string &error)
744 // don't try to set the error twice, its already set take the first string.
745 if (this->WriteError.empty())
747 ServerInstance->Log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
748 this->WriteError = error;
754 ServerInstance->Log(DEBUG,"Exception in userrec::SetWriteError()");
758 const char* userrec::GetWriteError()
760 return this->WriteError.c_str();
763 void userrec::Oper(const std::string &opertype)
767 this->modes[UM_OPERATOR] = 1;
768 this->WriteServ("MODE %s :+o", this->nick);
769 FOREACH_MOD(I_OnOper, OnOper(this, opertype));
770 ServerInstance->Log(DEFAULT,"OPER: %s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str());
771 strlcpy(this->oper, opertype.c_str(), NICKMAX - 1);
772 ServerInstance->all_opers.push_back(this);
773 FOREACH_MOD(I_OnPostOper,OnPostOper(this, opertype));
778 ServerInstance->Log(DEBUG,"Exception in userrec::Oper()");
782 void userrec::UnOper()
789 this->modes[UM_OPERATOR] = 0;
790 for (std::vector<userrec*>::iterator a = ServerInstance->all_opers.begin(); a < ServerInstance->all_opers.end(); a++)
794 ServerInstance->Log(DEBUG,"Oper removed from optimization list");
795 ServerInstance->all_opers.erase(a);
804 ServerInstance->Log(DEBUG,"Exception in userrec::UnOper()");
808 void userrec::QuitUser(InspIRCd* Instance, userrec *user, const std::string &quitreason)
810 user_hash::iterator iter = Instance->clientlist->find(user->nick);
811 std::string reason = quitreason;
813 if (reason.length() > MAXQUIT - 1)
814 reason.resize(MAXQUIT - 1);
816 if (user->registered != REG_ALL)
817 if (Instance->unregistered_count)
818 Instance->unregistered_count--;
822 user->Write("ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason.c_str());
823 if ((!user->sendq.empty()) && (!(*user->GetWriteError())))
824 user->FlushWriteBuf();
827 if (user->registered == REG_ALL)
829 user->PurgeEmptyChannels();
830 user->WriteCommonExcept("QUIT :%s",reason.c_str());
831 FOREACH_MOD_I(Instance,I_OnUserQuit,OnUserQuit(user,reason));
834 FOREACH_MOD_I(Instance,I_OnUserDisconnect,OnUserDisconnect(user));
838 if (Instance->Config->GetIOHook(user->GetPort()))
842 Instance->Config->GetIOHook(user->GetPort())->OnRawSocketClose(user->fd);
844 catch (CoreException& modexcept)
846 Instance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
850 Instance->SE->DelFd(user);
855 * this must come before the ServerInstance->SNO->WriteToSnoMaskso that it doesnt try to fill their buffer with anything
856 * if they were an oper with +sn +qQ.
858 if (user->registered == REG_ALL)
861 Instance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
863 Instance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,reason.c_str());
867 if (iter != Instance->clientlist->end())
869 Instance->Log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
872 std::vector<userrec*>::iterator x = find(Instance->local_users.begin(),Instance->local_users.end(),user);
873 if (x != Instance->local_users.end())
874 Instance->local_users.erase(x);
876 Instance->clientlist->erase(iter);
882 /* adds or updates an entry in the whowas list */
883 void userrec::AddToWhoWas()
885 command_t* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
888 std::deque<classbase*> params;
889 params.push_back(this);
890 whowas_command->HandleInternal(WHOWAS_ADD, params);
894 /* add a client connection to the sockets list */
895 void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, insp_inaddr ip)
897 std::string tempnick = ConvToStr(socket) + "-unknown";
898 user_hash::iterator iter = Instance->clientlist->find(tempnick);
899 const char *ipaddr = insp_ntoa(ip);
903 Instance->unregistered_count++;
907 * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
908 * using one as a registered connection. As they are per fd, we can also safely assume
909 * that we wont have collisions. Therefore, if the nick exists in the list, its only
910 * used by a dead socket, erase the iterator so that the new client may reclaim it.
911 * this was probably the cause of 'server ignores me when i hammer it with reconnects'
912 * issue in earlier alphas/betas
914 if (iter != Instance->clientlist->end())
916 userrec* goner = iter->second;
918 Instance->clientlist->erase(iter);
921 Instance->Log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr);
923 New = new userrec(Instance);
924 (*(Instance->clientlist))[tempnick] = New;
926 strlcpy(New->nick,tempnick.c_str(),NICKMAX-1);
928 New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);
929 /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
930 strcpy(New->ident, "unknown");
932 New->registered = REG_NONE;
933 New->signon = Instance->Time() + Instance->Config->dns_timeout;
936 New->SetSockAddr(AF_FAMILY, ipaddr, port);
938 /* Smarter than your average bear^H^H^H^Hset of strlcpys. */
939 for (const char* temp = New->GetIPString(); *temp && j < 64; temp++, j++)
940 New->dhost[j] = New->host[j] = *temp;
941 New->dhost[j] = New->host[j] = 0;
943 Instance->AddLocalClone(New);
944 Instance->AddGlobalClone(New);
946 ConnectClass* i = New->GetClass();
948 if ((!i) || (i->GetType() == CC_DENY))
950 userrec::QuitUser(Instance, New,"Unauthorised connection");
954 New->pingmax = i->GetPingTime();
955 New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
956 New->timeout = Instance->Time() + i->GetRegTimeout();
957 New->flood = i->GetFlood();
958 New->threshold = i->GetThreshold();
959 New->sendqmax = i->GetSendqMax();
960 New->recvqmax = i->GetRecvqMax();
962 Instance->local_users.push_back(New);
964 if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
966 Instance->WriteOpers("*** Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit);
967 userrec::QuitUser(Instance, New,"No more connections allowed");
973 * this is done as a safety check to keep the file descriptors within range of fd_ref_table.
974 * its a pretty big but for the moment valid assumption:
975 * file descriptors are handed out starting at 0, and are recycled as theyre freed.
976 * therefore if there is ever an fd over 65535, 65536 clients must be connected to the
977 * irc server at once (or the irc server otherwise initiating this many connections, files etc)
978 * which for the time being is a physical impossibility (even the largest networks dont have more
979 * than about 10,000 users on ONE server!)
981 if ((unsigned int)socket >= MAX_DESCRIPTORS)
983 userrec::QuitUser(Instance, New, "Server is full");
987 New->exempt = (Instance->XLines->matches_exception(New) != NULL);
990 ZLine* r = Instance->XLines->matches_zline(ipaddr);
994 snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
995 userrec::QuitUser(Instance, New, reason);
1002 if (!Instance->SE->AddFd(New))
1004 userrec::QuitUser(Instance, New, "Internal error handling connection");
1009 /* NOTE: even if dns lookups are *off*, we still need to display this.
1010 * BOPM and other stuff requires it.
1012 New->WriteServ("NOTICE Auth :*** Looking up your hostname...");
1015 unsigned long userrec::GlobalCloneCount()
1017 clonemap::iterator x = ServerInstance->global_clones.find(this->GetIPString());
1018 if (x != ServerInstance->global_clones.end())
1024 unsigned long userrec::LocalCloneCount()
1026 clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
1027 if (x != ServerInstance->local_clones.end())
1033 void userrec::FullConnect(CullList* Goners)
1035 ServerInstance->stats->statsConnects++;
1036 this->idle_lastmsg = ServerInstance->Time();
1038 ConnectClass* a = this->GetClass();
1040 if ((!a) || (a->GetType() == CC_DENY))
1042 Goners->AddItem(this,"Unauthorised connection");
1046 if ((!a->GetPass().empty()) && (!this->haspassed))
1048 Goners->AddItem(this,"Invalid password");
1052 if (this->LocalCloneCount() > a->GetMaxLocal())
1054 Goners->AddItem(this, "No more connections allowed from your host via this connect class (local)");
1055 ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
1058 else if (this->GlobalCloneCount() > a->GetMaxGlobal())
1060 Goners->AddItem(this, "No more connections allowed from your host via this connect class (global)");
1061 ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a->GetMaxGlobal(), this->GetIPString());
1067 GLine* r = ServerInstance->XLines->matches_gline(this);
1071 char reason[MAXBUF];
1072 snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
1073 Goners->AddItem(this, reason);
1077 KLine* n = ServerInstance->XLines->matches_kline(this);
1081 char reason[MAXBUF];
1082 snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
1083 Goners->AddItem(this, reason);
1089 this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network);
1090 this->WriteServ("001 %s :Welcome to the %s IRC Network %s!%s@%s",this->nick, ServerInstance->Config->Network, this->nick, this->ident, this->host);
1091 this->WriteServ("002 %s :Your host is %s, running version %s",this->nick,ServerInstance->Config->ServerName,VERSION);
1092 this->WriteServ("003 %s :This server was created %s %s", this->nick, __TIME__, __DATE__);
1093 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());
1095 ServerInstance->Config->Send005(this);
1099 /* Now registered */
1100 if (ServerInstance->unregistered_count)
1101 ServerInstance->unregistered_count--;
1104 * fix 3 by brain, move registered = 7 below these so that spurious modes and host
1105 * changes dont go out onto the network and produce 'fake direction'.
1107 FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
1109 this->registered = REG_ALL;
1111 FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
1113 ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
1116 /** userrec::UpdateNick()
1117 * re-allocates a nick in the user_hash after they change nicknames,
1118 * returns a pointer to the new user as it may have moved
1120 userrec* userrec::UpdateNickHash(const char* New)
1124 //user_hash::iterator newnick;
1125 user_hash::iterator oldnick = ServerInstance->clientlist->find(this->nick);
1127 if (!strcasecmp(this->nick,New))
1128 return oldnick->second;
1130 if (oldnick == ServerInstance->clientlist->end())
1131 return NULL; /* doesnt exist */
1133 userrec* olduser = oldnick->second;
1134 (*(ServerInstance->clientlist))[New] = olduser;
1135 ServerInstance->clientlist->erase(oldnick);
1141 ServerInstance->Log(DEBUG,"Exception in userrec::UpdateNickHash()");
1146 void userrec::InvalidateCache()
1148 /* Invalidate cache */
1149 if (cached_fullhost)
1150 free(cached_fullhost);
1152 free(cached_hostip);
1153 if (cached_makehost)
1154 free(cached_makehost);
1155 if (cached_fullrealhost)
1156 free(cached_fullrealhost);
1157 cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
1160 bool userrec::ForceNickChange(const char* newnick)
1166 this->InvalidateCache();
1168 FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
1172 ServerInstance->stats->statsCollisions++;
1176 if (ServerInstance->XLines->matches_qline(newnick))
1178 ServerInstance->stats->statsCollisions++;
1182 if (this->registered == REG_ALL)
1184 const char* pars[1];
1186 std::string cmd = "NICK";
1187 return (ServerInstance->Parser->CallHandler(cmd, pars, 1, this) == CMD_SUCCESS);
1194 ServerInstance->Log(DEBUG,"Exception in userrec::ForceNickChange()");
1199 void userrec::SetSockAddr(int protocol_family, const char* ip, int port)
1201 switch (protocol_family)
1203 #ifdef SUPPORT_IP6LINKS
1206 ServerInstance->Log(DEBUG,"Set inet6 protocol address");
1207 sockaddr_in6* sin = new sockaddr_in6;
1208 sin->sin6_family = AF_INET6;
1209 sin->sin6_port = port;
1210 inet_pton(AF_INET6, ip, &sin->sin6_addr);
1211 this->ip = (sockaddr*)sin;
1217 ServerInstance->Log(DEBUG,"Set inet4 protocol address");
1218 sockaddr_in* sin = new sockaddr_in;
1219 sin->sin_family = AF_INET;
1220 sin->sin_port = port;
1221 inet_pton(AF_INET, ip, &sin->sin_addr);
1222 this->ip = (sockaddr*)sin;
1226 ServerInstance->Log(DEBUG,"Ut oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick);
1231 int userrec::GetPort()
1233 if (this->ip == NULL)
1236 switch (this->GetProtocolFamily())
1238 #ifdef SUPPORT_IP6LINKS
1241 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1242 return sin->sin6_port;
1248 sockaddr_in* sin = (sockaddr_in*)this->ip;
1249 return sin->sin_port;
1258 int userrec::GetProtocolFamily()
1260 if (this->ip == NULL)
1263 sockaddr_in* sin = (sockaddr_in*)this->ip;
1264 return sin->sin_family;
1267 const char* userrec::GetIPString()
1269 static char buf[1024];
1271 if (this->ip == NULL)
1274 switch (this->GetProtocolFamily())
1276 #ifdef SUPPORT_IP6LINKS
1279 static char temp[1024];
1281 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1282 inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
1283 /* IP addresses starting with a : on irc are a Bad Thing (tm) */
1286 strlcpy(&temp[1], buf, sizeof(temp) - 1);
1296 sockaddr_in* sin = (sockaddr_in*)this->ip;
1297 inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
1307 const char* userrec::GetIPString(char* buf)
1309 if (this->ip == NULL)
1315 switch (this->GetProtocolFamily())
1317 #ifdef SUPPORT_IP6LINKS
1320 static char temp[1024];
1322 sockaddr_in6* sin = (sockaddr_in6*)this->ip;
1323 inet_ntop(sin->sin6_family, &sin->sin6_addr, buf, sizeof(buf));
1324 /* IP addresses starting with a : on irc are a Bad Thing (tm) */
1327 strlcpy(&temp[1], buf, sizeof(temp) - 1);
1329 strlcpy(buf, temp, sizeof(temp));
1337 sockaddr_in* sin = (sockaddr_in*)this->ip;
1338 inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
1349 /** NOTE: We cannot pass a const reference to this method.
1350 * The string is changed by the workings of the method,
1351 * so that if we pass const ref, we end up copying it to
1352 * something we can change anyway. Makes sense to just let
1353 * the compiler do that copy for us.
1355 void userrec::Write(std::string text)
1357 if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
1362 text.append("\r\n");
1366 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
1370 if (ServerInstance->Config->GetIOHook(this->GetPort()))
1374 ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
1376 catch (CoreException& modexcept)
1378 ServerInstance->Log(DEBUG, "%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
1383 this->AddWriteBuf(text);
1385 ServerInstance->stats->statsSent += text.length();
1386 this->ServerInstance->SE->WantWrite(this);
1391 void userrec::Write(const char *text, ...)
1394 char textbuffer[MAXBUF];
1396 va_start(argsPtr, text);
1397 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1400 this->Write(std::string(textbuffer));
1403 void userrec::WriteServ(const std::string& text)
1405 char textbuffer[MAXBUF];
1407 snprintf(textbuffer,MAXBUF,":%s %s",ServerInstance->Config->ServerName,text.c_str());
1408 this->Write(std::string(textbuffer));
1412 * Same as Write(), except `text' is prefixed with `:server.name '.
1414 void userrec::WriteServ(const char* text, ...)
1417 char textbuffer[MAXBUF];
1419 va_start(argsPtr, text);
1420 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1423 this->WriteServ(std::string(textbuffer));
1427 void userrec::WriteFrom(userrec *user, const std::string &text)
1431 snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
1433 this->Write(std::string(tb));
1437 /* write text from an originating user to originating user */
1439 void userrec::WriteFrom(userrec *user, const char* text, ...)
1442 char textbuffer[MAXBUF];
1444 va_start(argsPtr, text);
1445 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1448 this->WriteFrom(user, std::string(textbuffer));
1452 /* write text to an destination user from a source user (e.g. user privmsg) */
1454 void userrec::WriteTo(userrec *dest, const char *data, ...)
1456 char textbuffer[MAXBUF];
1459 va_start(argsPtr, data);
1460 vsnprintf(textbuffer, MAXBUF, data, argsPtr);
1463 this->WriteTo(dest, std::string(textbuffer));
1466 void userrec::WriteTo(userrec *dest, const std::string &data)
1468 dest->WriteFrom(this, data);
1472 void userrec::WriteCommon(const char* text, ...)
1474 char textbuffer[MAXBUF];
1477 if (this->registered != REG_ALL)
1480 va_start(argsPtr, text);
1481 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1484 this->WriteCommon(std::string(textbuffer));
1487 void userrec::WriteCommon(const std::string &text)
1491 bool sent_to_at_least_one = false;
1494 if (this->registered != REG_ALL)
1499 /* We dont want to be doing this n times, just once */
1500 snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str());
1501 std::string out = tb;
1503 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
1505 CUList* ulist = v->first->GetUsers();
1506 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
1508 if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
1510 already_sent[i->second->fd] = uniq_id;
1511 i->second->Write(out);
1512 sent_to_at_least_one = true;
1518 * if the user was not in any channels, no users will receive the text. Make sure the user
1519 * receives their OWN message for WriteCommon
1521 if (!sent_to_at_least_one)
1523 this->Write(std::string(tb));
1529 ServerInstance->Log(DEBUG,"Exception in userrec::WriteCommon()");
1534 /* write a formatted string to all users who share at least one common
1535 * channel, NOT including the source user e.g. for use in QUIT
1538 void userrec::WriteCommonExcept(const char* text, ...)
1540 char textbuffer[MAXBUF];
1543 va_start(argsPtr, text);
1544 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1547 this->WriteCommonExcept(std::string(textbuffer));
1550 void userrec::WriteCommonExcept(const std::string &text)
1552 bool quit_munge = false;
1553 char oper_quit[MAXBUF];
1554 char textbuffer[MAXBUF];
1560 strlcpy(textbuffer, text.c_str(), MAXBUF);
1562 if (this->registered != REG_ALL)
1567 snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),textbuffer);
1569 /* TODO: We need some form of WriteCommonExcept that will send two lines, one line to
1570 * opers and the other line to non-opers, then all this hidebans and hidesplits gunk
1573 if (ServerInstance->Config->HideSplits)
1575 char* check = textbuffer + 6;
1577 if (!strncasecmp(textbuffer, "QUIT :",6))
1579 std::stringstream split(check);
1580 std::string server_one;
1581 std::string server_two;
1583 split >> server_one;
1584 split >> server_two;
1586 if ((ServerInstance->FindServerName(server_one)) && (ServerInstance->FindServerName(server_two)))
1588 strlcpy(oper_quit,textbuffer,MAXQUIT);
1589 strlcpy(check,"*.net *.split",MAXQUIT);
1591 snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
1597 if ((ServerInstance->Config->HideBans) && (!quit_munge))
1599 if ((!strncasecmp(textbuffer, "QUIT :G-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :K-Lined:",14))
1600 || (!strncasecmp(textbuffer, "QUIT :Q-Lined:",14)) || (!strncasecmp(textbuffer, "QUIT :Z-Lined:",14)))
1602 char* check = textbuffer + 13;
1603 strlcpy(oper_quit,textbuffer,MAXQUIT);
1604 *check = 0; // We don't need to strlcpy, we just chop it from the :
1606 snprintf(tb2,MAXBUF,":%s %s",this->GetFullHost(),oper_quit);
1613 for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
1615 CUList *ulist = v->first->GetUsers();
1616 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
1618 if (this != i->second)
1620 if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
1622 already_sent[i->second->fd] = uniq_id;
1624 i->second->Write(*i->second->oper ? out2 : out1);
1626 i->second->Write(out1);
1634 void userrec::WriteWallOps(const std::string &text)
1636 /* Does nothing if theyre not opered */
1637 if ((!*this->oper) && (IS_LOCAL(this)))
1640 std::string wallop = "WALLOPS :";
1644 wallop.append(text);
1648 ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
1652 for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
1655 if ((IS_LOCAL(t)) && (t->modes[UM_WALLOPS]))
1656 this->WriteTo(t,wallop);
1660 void userrec::WriteWallOps(const char* text, ...)
1662 char textbuffer[MAXBUF];
1665 va_start(argsPtr, text);
1666 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1669 this->WriteWallOps(std::string(textbuffer));
1672 /* return 0 or 1 depending if users u and u2 share one or more common channels
1673 * (used by QUIT, NICK etc which arent channel specific notices)
1675 * The old algorithm in 1.0 for this was relatively inefficient, iterating over
1676 * the first users channels then the second users channels within the outer loop,
1677 * therefore it was a maximum of x*y iterations (upon returning 0 and checking
1678 * all possible iterations). However this new function instead checks against the
1679 * channel's userlist in the inner loop which is a std::map<userrec*,userrec*>
1680 * and saves us time as we already know what pointer value we are after.
1681 * Don't quote me on the maths as i am not a mathematician or computer scientist,
1682 * but i believe this algorithm is now x+(log y) maximum iterations instead.
1684 bool userrec::SharesChannelWith(userrec *other)
1686 if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
1690 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1692 /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
1693 * by replacing it with a map::find which *should* be more efficient
1695 if (i->first->HasUser(other))
1701 bool userrec::ChangeName(const char* gecos)
1703 if (!strcmp(gecos, this->fullname))
1709 FOREACH_RESULT(I_OnChangeLocalUserGECOS,OnChangeLocalUserGECOS(this,gecos));
1712 FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos));
1714 strlcpy(this->fullname,gecos,MAXGECOS+1);
1719 bool userrec::ChangeDisplayedHost(const char* host)
1721 if (!strcmp(host, this->dhost))
1727 FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(this,host));
1730 FOREACH_MOD(I_OnChangeHost,OnChangeHost(this,host));
1732 if (this->ServerInstance->Config->CycleHosts)
1733 this->WriteCommonExcept("QUIT :Changing hosts");
1735 /* Fix by Om: userrec::dhost is 65 long, this was truncating some long hosts */
1736 strlcpy(this->dhost,host,64);
1738 this->InvalidateCache();
1740 if (this->ServerInstance->Config->CycleHosts)
1742 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1744 i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
1745 std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
1747 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
1752 this->WriteServ("396 %s %s :is now your hidden host",this->nick,this->dhost);
1757 bool userrec::ChangeIdent(const char* newident)
1759 if (!strcmp(newident, this->ident))
1762 if (this->ServerInstance->Config->CycleHosts)
1763 this->WriteCommonExcept("%s","QUIT :Changing ident");
1765 strlcpy(this->ident, newident, IDENTMAX+2);
1767 this->InvalidateCache();
1769 if (this->ServerInstance->Config->CycleHosts)
1771 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1773 i->first->WriteAllExceptSender(this, false, 0, "JOIN %s", i->first->name);
1774 std::string n = this->ServerInstance->Modes->ModeString(this, i->first);
1776 i->first->WriteAllExceptSender(this, true, 0, "MODE %s +%s", i->first->name, n.c_str());
1783 void userrec::NoticeAll(char* text, ...)
1785 char textbuffer[MAXBUF];
1786 char formatbuffer[MAXBUF];
1789 va_start(argsPtr, text);
1790 vsnprintf(textbuffer, MAXBUF, text, argsPtr);
1793 snprintf(formatbuffer,MAXBUF,":%s NOTICE $* :%s", this->GetFullHost(), textbuffer);
1794 std::string fmt = formatbuffer;
1796 for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
1803 std::string userrec::ChannelList(userrec* source)
1808 for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
1810 /* If the target is the same as the sender, let them see all their channels.
1811 * If the channel is NOT private/secret OR the user shares a common channel
1812 * If the user is an oper, and the <options:operspywhois> option is set.
1814 if ((source == this) || (*source->oper && ServerInstance->Config->OperSpyWhois) || (((!i->first->modes[CM_PRIVATE]) && (!i->first->modes[CM_SECRET])) || (i->first->HasUser(source))))
1816 list.append(i->first->GetPrefixChar(this)).append(i->first->name).append(" ");
1823 ServerInstance->Log(DEBUG,"Exception in userrec::ChannelList()");
1828 void userrec::SplitChanList(userrec* dest, const std::string &cl)
1831 std::ostringstream prefix;
1832 std::string::size_type start, pos, length;
1836 prefix << this->nick << " " << dest->nick << " :";
1837 line = prefix.str();
1838 int namelen = strlen(ServerInstance->Config->ServerName) + 6;
1840 for (start = 0; (pos = cl.find(' ', start)) != std::string::npos; start = pos+1)
1842 length = (pos == std::string::npos) ? cl.length() : pos;
1844 if (line.length() + namelen + length - start > 510)
1846 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
1847 line = prefix.str();
1850 if(pos == std::string::npos)
1852 line.append(cl.substr(start, length - start));
1857 line.append(cl.substr(start, length - start + 1));
1863 ServerInstance->SendWhoisLine(this, dest, 319, "%s", line.c_str());
1869 ServerInstance->Log(DEBUG,"Exception in userrec::SplitChanList()");
1874 /* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
1875 * NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
1876 * then their ip will be taken as 'priority' anyway, so for example,
1877 * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
1879 ConnectClass* userrec::GetClass()
1881 for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
1883 if ((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str())))
1889 void userrec::PurgeEmptyChannels()
1891 std::vector<chanrec*> to_delete;
1893 // firstly decrement the count on each channel
1894 for (UCListIter f = this->chans.begin(); f != this->chans.end(); f++)
1896 f->first->RemoveAllPrefixes(this);
1897 if (f->first->DelUser(this) == 0)
1899 /* No users left in here, mark it for deletion */
1902 to_delete.push_back(f->first);
1906 ServerInstance->Log(DEBUG,"Exception in userrec::PurgeEmptyChannels to_delete.push_back()");
1911 for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
1913 chanrec* thischan = *n;
1914 chan_hash::iterator i2 = ServerInstance->chanlist->find(thischan->name);
1915 if (i2 != ServerInstance->chanlist->end())
1917 FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
1919 ServerInstance->chanlist->erase(i2);
1920 this->chans.erase(*n);
1927 void userrec::ShowMOTD()
1929 if (!ServerInstance->Config->MOTD.size())
1931 this->WriteServ("422 %s :Message of the day file is missing.",this->nick);
1934 this->WriteServ("375 %s :%s message of the day", this->nick, ServerInstance->Config->ServerName);
1936 for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
1937 this->WriteServ("372 %s :- %s",this->nick,i->c_str());
1939 this->WriteServ("376 %s :End of message of the day.", this->nick);
1942 void userrec::ShowRULES()
1944 if (!ServerInstance->Config->RULES.size())
1946 this->WriteServ("NOTICE %s :Rules file is missing.",this->nick);
1949 this->WriteServ("NOTICE %s :%s rules",this->nick,ServerInstance->Config->ServerName);
1951 for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
1952 this->WriteServ("NOTICE %s :%s",this->nick,i->c_str());
1954 this->WriteServ("NOTICE %s :End of %s rules.",this->nick,ServerInstance->Config->ServerName);
1957 void userrec::HandleEvent(EventType et, int errornum)
1959 /* WARNING: May delete this user! */
1960 int thisfd = this->GetFd();
1967 ServerInstance->ProcessUser(this);
1970 this->FlushWriteBuf();
1973 /** This should be safe, but dont DARE do anything after it -- Brain */
1974 this->SetWriteError(errornum ? strerror(errornum) : "EOF from client");
1980 ServerInstance->Log(DEBUG,"Exception in userrec::HandleEvent intercepted");
1983 /* If the user has raised an error whilst being processed, quit them now we're safe to */
1984 if ((ServerInstance->SE->GetRef(thisfd) == this))
1986 if (!WriteError.empty())
1988 userrec::QuitUser(ServerInstance, this, GetWriteError());