diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-24 18:56:24 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-24 18:56:24 +0000 |
commit | 3dfdda08a07b0e2661cec95e05de5e5310d54213 (patch) | |
tree | bbf8c7e81e122e6559ad4437d647f6890582dd79 /src | |
parent | 475f5579b5674a1b14d051bbd5d4400dd811e085 (diff) |
Finish reference counting connect class stuff. Now rehash removes unused classes (refcount == 0), and re-reads any new shit (or ones that just got removed) from the config.
Possibly todo in the future: make /rehash update classes that exist in memory, make /rehash mark classes removed from conf (but still exist as refcount > 0) as inactive.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8354 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 779c288b3..5031f6506 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -413,6 +413,13 @@ bool InitConnect(ServerConfig* conf, const char*) { conf->GetInstance()->Log(DEFAULT,"Reading connect classes..."); + for (ClassVector::iterator i = conf->Classes.begin(); i != conf->Classes.end(); i++) + { + ConnectClass *c = *i; + + conf->GetInstance()->Log(DEBUG, "Address of class is %p", c); + } + goagain: /* change this: only delete a class with refcount 0 */ for (ClassVector::iterator i = conf->Classes.begin(); i != conf->Classes.end(); i++) @@ -434,7 +441,6 @@ goagain: */ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*) { - conf->GetInstance()->Log(DEFAULT,"Adding a connect class!"); ConnectClass c; const char* allow = values[0].GetString(); /* Yeah, there are a lot of values. Live with it. */ const char* deny = values[1].GetString(); @@ -452,6 +458,22 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*) const char* parent = values[13].GetString(); int maxchans = values[14].GetInteger(); + /* + * duplicates check: Now we don't delete all connect classes on rehash, we need to ensure we don't add dupes. + * easier said than done, but for now we'll just disallow anything with a duplicate host or name. -- w00t + */ + for (ClassVector::iterator item = conf->Classes.begin(); item != conf->Classes.end(); ++item) + { + ConnectClass* c = *item; + if ((*name && (c->GetName() == name)) || (*allow && (c->GetHost() == allow)) || (*deny && (c->GetHost() == deny))) + { + conf->GetInstance()->Log(DEFAULT, "Not adding class, it already exists!"); + return true; + } + } + + conf->GetInstance()->Log(DEFAULT,"Adding a connect class!"); + if (*parent) { /* Find 'parent' and inherit a new class from it, |