]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Changed m_messageflood to use PreMessage and PreNotice, because it may kick the user
[user/henk/code/inspircd.git] / src / users.cpp
index 7da7d6b0960291d0b14f2867e8c0eea03808b741..cbf9de0cdcc8a038c0331b7ab08a9317f952e747 100644 (file)
@@ -741,7 +741,7 @@ void userrec::FlushWriteBuf()
                                {
                                        /* Fatal error, set write error and bail
                                         */
-                                       this->SetWriteError(strerror(errno));
+                                       this->SetWriteError(errno ? strerror(errno) : "EOF from client");
                                        return;
                                }
                        }
@@ -923,16 +923,12 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
                return;
        }
 
+       /*
+        * Check connect class settings and initialise settings into userrec.
+        * This will be done again after DNS resolution. -- w00t
+        */
        New->CheckClass();
 
-       New->pingmax = i->GetPingTime();
-       New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
-       New->timeout = Instance->Time() + i->GetRegTimeout();
-       New->flood = i->GetFlood();
-       New->threshold = i->GetThreshold();
-       New->sendqmax = i->GetSendqMax();
-       New->recvqmax = i->GetRecvqMax();
-
        Instance->local_users.push_back(New);
 
        if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS))
@@ -1032,6 +1028,14 @@ void userrec::CheckClass()
                ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
                return;
        }
+
+       this->pingmax = a->GetPingTime();
+       this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout;
+       this->timeout = ServerInstance->Time() + a->GetRegTimeout();
+       this->flood = a->GetFlood();
+       this->threshold = a->GetThreshold();
+       this->sendqmax = a->GetSendqMax();
+       this->recvqmax = a->GetRecvqMax();
 }
 
 void userrec::FullConnect()
@@ -1067,7 +1071,7 @@ void userrec::FullConnect()
                        if (*ServerInstance->Config->MoronBanner)
                                this->WriteServ("NOTICE %s :*** %s", this->nick, ServerInstance->Config->MoronBanner);
                        snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
-                       ServerInstance->GlobalCulls.AddItem(this, reason);
+                       userrec::QuitUser(ServerInstance, this, reason);
                        return;
                }
 
@@ -1080,7 +1084,7 @@ void userrec::FullConnect()
                        if (*ServerInstance->Config->MoronBanner)
                                this->WriteServ("NOTICE %s :*** %s", this, ServerInstance->Config->MoronBanner);
                        snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
-                       ServerInstance->GlobalCulls.AddItem(this, reason);
+                       userrec::QuitUser(ServerInstance, this, reason);
                        return;
                }
        }
@@ -1354,11 +1358,7 @@ const char* userrec::GetIPString(char* buf)
  */
 void userrec::Write(std::string text)
 {
-#ifdef WINDOWS
-       if ((this->fd < 0) || (this->m_internalFd > MAX_DESCRIPTORS))
-#else
-       if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS))
-#endif
+       if (!ServerInstance->SE->BoundsCheckFd(this))
                return;
 
        try
@@ -1631,7 +1631,7 @@ void userrec::WriteWallOps(const std::string &text)
        for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
        {
                userrec* t = *i;
-               if (t->modes[UM_WALLOPS])
+               if (t->IsModeSet('w'))
                        this->WriteTo(t,wallop);
        }
 }
@@ -1790,7 +1790,7 @@ std::string userrec::ChannelList(userrec* source)
                         * If the channel is NOT private/secret OR the user shares a common channel
                         * If the user is an oper, and the <options:operspywhois> option is set.
                         */
-                       if ((source == this) || (IS_OPER(source) && ServerInstance->Config->OperSpyWhois) || (((!i->first->modes[CM_PRIVATE]) && (!i->first->modes[CM_SECRET])) || (i->first->HasUser(source))))
+                       if ((source == this) || (IS_OPER(source) && ServerInstance->Config->OperSpyWhois) || (((!i->first->IsModeSet('p')) && (!i->first->IsModeSet('s'))) || (i->first->HasUser(source))))
                        {
                                list.append(i->first->GetPrefixChar(this)).append(i->first->name).append(" ");
                        }
@@ -1932,15 +1932,16 @@ void userrec::ShowRULES()
 {
        if (!ServerInstance->Config->RULES.size())
        {
-               this->WriteServ("NOTICE %s :Rules file is missing.",this->nick);
+               this->WriteServ("434 %s :RULES File is missing",this->nick);
                return;
        }
-       this->WriteServ("NOTICE %s :%s rules",this->nick,ServerInstance->Config->ServerName);
+
+       this->WriteServ("308 %s :- %s Server Rules -",this->nick,ServerInstance->Config->ServerName);
 
        for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
-               this->WriteServ("NOTICE %s :%s",this->nick,i->c_str());
+               this->WriteServ("232 %s :- %s",this->nick,i->c_str());
 
-       this->WriteServ("NOTICE %s :End of %s rules.",this->nick,ServerInstance->Config->ServerName);
+       this->WriteServ("309 %s :End of RULES command.",this->nick);
 }
 
 void userrec::HandleEvent(EventType et, int errornum)