summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-12 18:03:52 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-12 18:03:52 +0000
commit0036e3a70cabea02e9ec2103ed1dfdf5c799289f (patch)
tree649d2ea45cd483fc83a293b2c2542212cffa051e /src/users.cpp
parentb33f836f1b863207a430bfa9cd1dffeaa406524d (diff)
Fixes for config reader
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11504 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 26a790dfa..cbc59a49c 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -245,6 +245,8 @@ User::~User()
{
this->MyClass->RefCount--;
ServerInstance->Logs->Log("USERS", DEBUG, "User destructor -- connect refcount now: %lu", this->MyClass->RefCount);
+ if (MyClass->RefCount == 0)
+ delete MyClass;
}
if (this->AllowedOperCommands)
@@ -901,7 +903,7 @@ void User::CheckClass()
{
ConnectClass* a = this->MyClass;
- if ((!a) || (a->GetType() == CC_DENY))
+ if ((!a) || (a->type == CC_DENY))
{
ServerInstance->Users->QuitUser(this, "Unauthorised connection");
return;
@@ -1839,10 +1841,7 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
{
ConnectClass* c = *i;
- if (c->GetDisabled())
- continue; // can't possibly match, removed from conf
-
- if (explicit_name == c->GetName())
+ if (explicit_name == c->name)
{
ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Explicitly set to %s", explicit_name.c_str());
found = c;
@@ -1855,22 +1854,15 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
{
ConnectClass* c = *i;
- if (c->GetType() == CC_ALLOW)
+ if (c->type == CC_ALLOW)
{
- ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "ALLOW %s %d %s", c->GetHost().c_str(), c->GetPort(), c->GetName().c_str());
+ ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "ALLOW %s %d %s", c->host.c_str(), c->GetPort(), c->GetName().c_str());
}
else
{
ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "DENY %s %d %s", c->GetHost().c_str(), c->GetPort(), c->GetName().c_str());
}
- /* if it's disabled, we can't match this one. */
- if (c->GetDisabled())
- {
- ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Class disabled");
- continue;
- }
-
/* check if host matches.. */
if (c->GetHost().length() && !InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&
!InspIRCd::MatchCIDR(this->host, c->GetHost(), NULL))
@@ -1883,7 +1875,7 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
* deny change if change will take class over the limit check it HERE, not after we found a matching class,
* because we should attempt to find another class if this one doesn't match us. -- w00t
*/
- if (c->limit && (c->RefCount + 1 >= c->limit))
+ if (c->limit && (c->RefCount >= c->limit))
{
ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "OOPS: Connect class limit (%lu) hit, denying", c->limit);
continue;
@@ -1920,6 +1912,8 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
return this->MyClass;
this->MyClass->RefCount--;
ServerInstance->Logs->Log("USERS", DEBUG, "Untying user from connect class -- refcount: %lu", this->MyClass->RefCount);
+ if (MyClass->RefCount == 0)
+ delete MyClass;
}
this->MyClass = found;
@@ -2084,3 +2078,29 @@ bool VisData::VisibleTo(User* user)
{
return true;
}
+
+
+ConnectClass::ConnectClass(char t, const std::string& mask)
+ : type(t), name("unnamed"), registration_timeout(0), host(mask), pingtime(0), pass(""), hash(""), sendqmax(0), recvqmax(0), maxlocal(0), maxglobal(0), limit(0), RefCount(1)
+{
+}
+
+ConnectClass::ConnectClass(char t, const std::string& mask, const ConnectClass& parent)
+ : type(t), name("unnamed"), registration_timeout(parent.registration_timeout), host(mask), pingtime(parent.pingtime), pass(parent.pass), hash(parent.hash), sendqmax(parent.sendqmax), recvqmax(parent.recvqmax), maxlocal(parent.maxlocal), maxglobal(parent.maxglobal), limit(parent.limit), RefCount(1)
+{
+}
+
+void ConnectClass::Update(const ConnectClass* src)
+{
+ name = src->name;
+ registration_timeout = src->registration_timeout;
+ host = src->host;
+ pingtime = src->pingtime;
+ pass = src->pass;
+ hash = src->hash;
+ sendqmax = src->sendqmax;
+ recvqmax = src->recvqmax;
+ maxlocal = src->maxlocal;
+ maxglobal = src->maxglobal;
+ limit = src->limit;
+}