summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/configreader.h6
-rw-r--r--include/users.h14
-rw-r--r--src/configreader.cpp8
-rw-r--r--src/users.cpp14
4 files changed, 31 insertions, 11 deletions
diff --git a/include/configreader.h b/include/configreader.h
index 499761449..514e5e9b3 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -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;
diff --git a/include/users.h b/include/users.h
index d9a5168cc..80d9fb00c 100644
--- a/include/users.h
+++ b/include/users.h
@@ -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()
diff --git a/src/configreader.cpp b/src/configreader.cpp
index bdc84de0b..56ea49289 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -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",
diff --git a/src/users.cpp b/src/users.cpp
index 1f8a62eec..43ca8ec9f 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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;
}