diff options
-rw-r--r-- | include/users.h | 56 | ||||
-rw-r--r-- | src/configreader.cpp | 17 | ||||
-rw-r--r-- | src/users.cpp | 18 |
3 files changed, 48 insertions, 43 deletions
diff --git a/include/users.h b/include/users.h index c35680dac..1137a79cc 100644 --- a/include/users.h +++ b/include/users.h @@ -177,11 +177,11 @@ public: /** Create a new connect class based on an existing connect class. This is required for std::vector (at least under windows). */ - ConnectClass(const ConnectClass& source) : classbase(), type(source.type), name(source.name), - registration_timeout(source.registration_timeout), flood(source.flood), host(source.host), - pingtime(source.pingtime), pass(source.pass), threshold(source.threshold), sendqmax(source.sendqmax), - recvqmax(source.recvqmax), maxlocal(source.maxlocal), maxglobal(source.maxglobal), maxchans(source.maxchans), - port(source.port) + ConnectClass(const ConnectClass* source) : classbase(), type(source->type), name(source->name), + registration_timeout(source->registration_timeout), flood(source->flood), host(source->host), + pingtime(source->pingtime), pass(source->pass), threshold(source->threshold), sendqmax(source->sendqmax), + recvqmax(source->recvqmax), maxlocal(source->maxlocal), maxglobal(source->maxglobal), maxchans(source->maxchans), + port(source->port) { this->RefCount = 0; } @@ -227,11 +227,11 @@ public: * @param thename The name of the connect class * @param source Another connect class to inherit all but the name from */ - ConnectClass(const std::string &thename, const ConnectClass &source) : type(source.type), name(thename), - registration_timeout(source.registration_timeout), flood(source.flood), host(source.host), - pingtime(source.pingtime), pass(source.pass), threshold(source.threshold), sendqmax(source.sendqmax), - recvqmax(source.recvqmax), maxlocal(source.maxlocal), maxglobal(source.maxglobal), maxchans(source.maxchans), - port(source.port) + ConnectClass(const std::string &thename, const ConnectClass* source) : type(source->type), name(thename), + registration_timeout(source->registration_timeout), flood(source->flood), host(source->host), + pingtime(source->pingtime), pass(source->pass), threshold(source->threshold), sendqmax(source->sendqmax), + recvqmax(source->recvqmax), maxlocal(source->maxlocal), maxglobal(source->maxglobal), maxchans(source->maxchans), + port(source->port) { this->RefCount = 0; } @@ -375,27 +375,27 @@ public: return maxglobal; } - bool operator== (ConnectClass &other) + bool operator== (ConnectClass* other) { - return (other.GetName() == name); + return (other->GetName() == name); } - void operator=(const ConnectClass & other) + void operator=(const ConnectClass* other) { - type = other.type; - name = other.name; - registration_timeout = other.registration_timeout; - flood = other.flood; - host = other.host; - pingtime = other.pingtime; - pass = other.pass; - threshold = other.threshold; - sendqmax = other.sendqmax; - recvqmax = other.recvqmax; - maxlocal = other.maxlocal; - maxglobal = other.maxglobal; - maxchans = other.maxchans; - port = other.port; + type = other->type; + name = other->name; + registration_timeout = other->registration_timeout; + flood = other->flood; + host = other->host; + pingtime = other->pingtime; + pass = other->pass; + threshold = other->threshold; + sendqmax = other->sendqmax; + recvqmax = other->recvqmax; + maxlocal = other->maxlocal; + maxglobal = other->maxglobal; + maxchans = other->maxchans; + port = other->port; } }; @@ -405,7 +405,7 @@ typedef std::vector<irc::string> InvitedList; /** Holds a complete list of all allow and deny tags from the configuration file (connection classes) */ -typedef std::vector<ConnectClass> ClassVector; +typedef std::vector<ConnectClass*> ClassVector; /** Typedef for the list of user-channel records for a user */ diff --git a/src/configreader.cpp b/src/configreader.cpp index 28c82ef77..779c288b3 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -417,7 +417,7 @@ goagain: /* change this: only delete a class with refcount 0 */ for (ClassVector::iterator i = conf->Classes.begin(); i != conf->Classes.end(); i++) { - ConnectClass *c = &(*i); + ConnectClass *c = *i; if (c->RefCount == 0) { @@ -459,10 +459,11 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*) */ for (ClassVector::iterator item = conf->Classes.begin(); item != conf->Classes.end(); ++item) { - if (item->GetName() == parent) + ConnectClass* c = *item; + if (c->GetName() == parent) { - ConnectClass c(name, *item); - c.Update(timeout, flood, *allow ? allow : deny, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans, port); + ConnectClass* c = new ConnectClass(name, c); + c->Update(timeout, flood, *allow ? allow : deny, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans, port); conf->Classes.push_back(c); } } @@ -472,14 +473,14 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*) { if (*allow) { - ConnectClass c(name, timeout, flood, allow, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans); - c.SetPort(port); + ConnectClass* c = new ConnectClass(name, timeout, flood, allow, pingfreq, password, threshold, sendq, recvq, localmax, globalmax, maxchans); + c->SetPort(port); conf->Classes.push_back(c); } else { - ConnectClass c(name, deny); - c.SetPort(port); + ConnectClass* c = new ConnectClass(name, deny); + c->SetPort(port); conf->Classes.push_back(c); } } diff --git a/src/users.cpp b/src/users.cpp index 0e08a8848..08e38f36d 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1725,9 +1725,11 @@ ConnectClass* User::SetClass(const std::string &explicit_name) { for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++) { - if (explicit_name == i->GetName()) + ConnectClass* c = *i; + + if (explicit_name == c->GetName()) { - found = &(*i); + found = c; } } } @@ -1735,20 +1737,22 @@ ConnectClass* User::SetClass(const std::string &explicit_name) { 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())))) + ConnectClass* c = *i; + + if (((match(this->GetIPString(),c->GetHost().c_str(),true)) || (match(this->host,c->GetHost().c_str())))) { - if (i->GetPort()) + if (c->GetPort()) { - if (this->GetPort() == i->GetPort()) + if (this->GetPort() == c->GetPort()) { - found = &(*i); + found = c; } else continue; } else { - found = &(*i); + found = c; } } } |