summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-24 22:52:51 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-24 22:52:51 +0000
commit7b3105e5d4ea1877f8c30daaf069839ea890752d (patch)
treef797652ab543040b3a8b14bbc12476e8ca8a09c9 /src
parentf2d6214247c75342e872c519630f0d5553190ece (diff)
Implement <connect:limit> - limits how many clients can sit inside a <connect> tag. Brain, we have a problem here in that if we User::QuitUser() a user with a NULL MyClass member (connect class), then things break (like sendq et al). What should we do with this, create a generic catchall class or something just in case? (to replicate, set up a single connect class with a low limit, and connect too many clients. Crash is the result)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8357 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp10
-rw-r--r--src/users.cpp7
2 files changed, 13 insertions, 4 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 6317bca95..4de90cd78 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -459,6 +459,7 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*)
const char* name = values[12].GetString();
const char* parent = values[13].GetString();
int maxchans = values[14].GetInteger();
+ unsigned long limit = values[15].GetInteger();
/*
* duplicates check: Now we don't delete all connect classes on rehash, we need to ensure we don't add dupes.
@@ -489,7 +490,7 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*)
if (c->GetName() == parent)
{
ConnectClass* c = new ConnectClass(name, c);
- c->Update(timeout, flood, *allow ? allow : deny, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans, port);
+ c->Update(timeout, flood, *allow ? allow : deny, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans, port, limit);
conf->Classes.push_back(c);
}
}
@@ -500,6 +501,7 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*)
if (*allow)
{
ConnectClass* c = new ConnectClass(name, timeout, flood, allow, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans);
+ c->limit = limit;
c->SetPort(port);
conf->Classes.push_back(c);
}
@@ -746,15 +748,15 @@ void ServerConfig::Read(bool bail, User* user)
{"connect",
{"allow", "deny", "password", "timeout", "pingfreq", "flood",
"threshold", "sendq", "recvq", "localmax", "globalmax", "port",
- "name", "parent", "maxchans",
+ "name", "parent", "maxchans", "limit",
NULL},
{"", "", "", "", "120", "",
"", "", "", "3", "3", "0",
- "", "", "0",
+ "", "", "0", "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_CHARPTR, DT_CHARPTR, DT_INTEGER},
+ DT_CHARPTR, DT_CHARPTR, DT_INTEGER, DT_INTEGER},
InitConnect, DoConnect, DoneConnect},
{"uline",
diff --git a/src/users.cpp b/src/users.cpp
index 381806e50..1affa67db 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1762,6 +1762,13 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
/* ensure we don't fuck things up refcount wise, only remove them from a class if we find a new one :P */
if (found)
{
+ /* deny change if change will take class over the limit */
+ if (found->RefCount + 1 >= found->limit)
+ {
+ ServerInstance->Log(DEBUG, "OOPS: Connect class limit (%u) hit, denying", found->limit);
+ return this->MyClass;
+ }
+
/* should always be valid, but just in case .. */
if (this->MyClass)
{