]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix for bug #376 - FEATURE - (sorry w00t) - not backporting to stable.
[user/henk/code/inspircd.git] / src / users.cpp
index bc8dc51e436d7a03fc41cdfa071ebe8afde66d4d..ccf506697142040fd0d4199e0796e12abe57bd5c 100644 (file)
@@ -436,8 +436,8 @@ char* userrec::MakeHostIP()
 
 void userrec::CloseSocket()
 {
-       shutdown(this->fd,2);
-       close(this->fd);
+       ServerInstance->SE->Shutdown(this, 2);
+       ServerInstance->SE->Close(this);
 }
 
 char* userrec::GetFullHost()
@@ -727,11 +727,8 @@ void userrec::FlushWriteBuf()
                if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
                {
                        int old_sendq_length = sendq.length();
-#ifndef WIN32
-               int n_sent = write(this->fd, this->sendq.data(), this->sendq.length());
-#else
-               int n_sent = send(this->fd, (const char*)this->sendq.data(), this->sendq.length(), 0);
-#endif
+                       int n_sent = ServerInstance->SE->Send(this, this->sendq.data(), this->sendq.length(), 0);
+
                        if (n_sent == -1)
                        {
                                if (errno == EAGAIN)
@@ -1011,9 +1008,9 @@ unsigned long userrec::LocalCloneCount()
 /*
  * Check class restrictions
  */
-void userrec::CheckClass()
+void userrec::CheckClass(const std::string &explicit_class)
 {
-       ConnectClass* a = this->GetClass();
+       ConnectClass* a = this->GetClass(explicit_class);
 
        if ((!a) || (a->GetType() == CC_DENY))
        {
@@ -1040,6 +1037,7 @@ void userrec::CheckClass()
        this->threshold = a->GetThreshold();
        this->sendqmax = a->GetSendqMax();
        this->recvqmax = a->GetRecvqMax();
+       this->MaxChans = a->GetMaxChans();
 }
 
 void userrec::FullConnect()
@@ -1853,27 +1851,42 @@ void userrec::SplitChanList(userrec* dest, const std::string &cl)
        }
 }
 
+unsigned int userrec::GetMaxChans()
+{
+       return this->MaxChans;
+}
 
 /* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
  * NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
  * then their ip will be taken as 'priority' anyway, so for example,
  * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
  */
-ConnectClass* userrec::GetClass()
+ConnectClass* userrec::GetClass(const std::string &explicit_name)
 {
-       for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+       if (!explicit_name.empty())
+       {
+               for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+               {
+                       if (explicit_name == i->GetName())
+                               return &(*i);
+               }
+       }
+       else
        {
-               if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
+               for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
                {
-                       if (i->GetPort())
+                       if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
                        {
-                               if (this->GetPort() == i->GetPort())
-                                       return &(*i);
+                               if (i->GetPort())
+                               {
+                                       if (this->GetPort() == i->GetPort())
+                                               return &(*i);
+                                       else
+                                               continue;
+                               }
                                else
-                                       continue;
+                                       return &(*i);
                        }
-                       else
-                               return &(*i);
                }
        }
        return NULL;