From 3dfdda08a07b0e2661cec95e05de5e5310d54213 Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 24 Oct 2007 18:56:24 +0000 Subject: 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 --- src/configreader.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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, -- cgit v1.2.3