]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Feature request outlined in bug #257, allow connect/allow lines by port
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 15 Apr 2007 11:42:42 +0000 (11:42 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 15 Apr 2007 11:42:42 +0000 (11:42 +0000)
Needs QA test

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6798 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
include/users.h
src/configreader.cpp
src/users.cpp

index 499761449ac7f1799e99ffba21eef5ff9e3a8457..514e5e9b3834a9a8bd4d58ef80d429f6009d33e6 100644 (file)
@@ -151,9 +151,9 @@ struct InitialConfig
 struct MultiConfig
 {
        const char*     tag;
-       char*           items[12];
-       char*           items_default[12];
-       int             datatype[12];
+       char*           items[13];
+       char*           items_default[13];
+       int             datatype[13];
        MultiNotify     init_function;
        MultiValidator  validation_function;
        MultiNotify     finish_function;
index d9a5168cca3ef92fb5daa5eb343bbcc292ff286e..80d9fb00cfdf046ccafba4f31deaa03c0770b92c 100644 (file)
@@ -116,6 +116,9 @@ class ConnectClass : public classbase
        /** Global max when connecting by this connection class
         */
        unsigned long maxglobal;
+       /** Port number this connect class applies to
+        */
+       int port;
 
 public:
 
@@ -138,15 +141,15 @@ public:
         */
        ConnectClass(unsigned int timeout, unsigned int fld, const std::string &hst, unsigned int ping,
                        const std::string &pas, unsigned int thres, unsigned long sendq, unsigned long recvq,
-                       unsigned long maxl, unsigned long maxg) :
+                       unsigned long maxl, unsigned long maxg, int p = 0) :
                        type(CC_ALLOW), registration_timeout(timeout), flood(fld), host(hst), pingtime(ping), pass(pas),
-                       threshold(thres), sendqmax(sendq), recvqmax(recvq), maxlocal(maxl), maxglobal(maxg) { }
+                       threshold(thres), sendqmax(sendq), recvqmax(recvq), maxlocal(maxl), maxglobal(maxg), port(p) { }
 
        /** Create a new connect class to DENY  connections
         * @param hst The IP mask to deny
         */
        ConnectClass(const std::string &hst) : type(CC_DENY), registration_timeout(0), flood(0), host(hst), pingtime(0),
-                       pass(""), threshold(0), sendqmax(0), recvqmax(0), maxlocal(0), maxglobal(0) { }
+                       pass(""), threshold(0), sendqmax(0), recvqmax(0), maxlocal(0), maxglobal(0), port(0) { }
 
        /** Returns the type, CC_ALLOW or CC_DENY
         */
@@ -176,6 +179,11 @@ public:
                return host;
        }
 
+       int GetPort()
+       {
+               return port;
+       }
+
        /** Returns the ping frequency
         */
        unsigned int GetPingTime()
index bdc84de0bd8c5cf6ce52013eedfc875f611a74a3..56ea492893c117340d68d39b25695cd8f9c57423 100644 (file)
@@ -612,11 +612,13 @@ void ServerConfig::Read(bool bail, userrec* user)
 
                {"connect",
                                {"allow",       "deny",         "password",     "timeout",      "pingfreq",     "flood",
-                               "threshold",    "sendq",        "recvq",        "localmax",     "globalmax",    NULL},
+                               "threshold",    "sendq",        "recvq",        "localmax",     "globalmax",    "port",
+                               NULL},
                                {"",            "",             "",             "",             "120",          "",
-                                "",            "",             "",             "3",            "3",            NULL},
+                                "",            "",             "",             "3",            "3",            "0",
+                                NULL},
                                {DT_CHARPTR,    DT_CHARPTR,     DT_CHARPTR,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER,
-                                DT_INTEGER,    DT_INTEGER,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER},
+                                DT_INTEGER,    DT_INTEGER,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER,     DT_INTEGER},
                                InitConnect, DoConnect, DoneConnect},
 
                {"uline",
index 1f8a62eece621d8ee253e8081a075dc0381b993f..43ca8ec9ff43346c4ccdb8f5e306c4b472ce8f30 100644 (file)
@@ -1811,8 +1811,18 @@ ConnectClass* userrec::GetClass()
 {
        for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
        {
-               if ((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str())))
-                       return &(*i);
+               if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
+               {
+                       if (i->GetPort())
+                       {
+                               if (this->GetPort() == i->GetPort())
+                                       return &(*i);
+                               else
+                                       return NULL;
+                       }
+                       else
+                               return &(*i);
+               }
        }
        return NULL;
 }