diff options
-rw-r--r-- | include/users.h | 44 | ||||
-rw-r--r-- | src/configreader.cpp | 18 |
2 files changed, 60 insertions, 2 deletions
diff --git a/include/users.h b/include/users.h index dfe4328ce..d59e540b4 100644 --- a/include/users.h +++ b/include/users.h @@ -212,6 +212,36 @@ public: { } + /* Update an existing entry with new values + */ + void Update(unsigned int timeout, unsigned int fld, const std::string &hst, unsigned int ping, + const std::string &pas, unsigned int thres, unsigned long sendq, unsigned long recvq, + unsigned long maxl, unsigned long maxg, int p) + { + if (timeout) + registration_timeout = timeout; + if (fld) + flood = fld; + if (!hst.empty()) + host = hst; + if (ping) + pingtime = ping; + if (!pas.empty()) + pass = pas; + if (thres) + threshold = thres; + if (sendq) + sendqmax = sendq; + if (recvq) + recvqmax = recvq; + if (maxl) + maxlocal = maxl; + if (maxg) + maxglobal = maxg; + if (p) + port = p; + } + /** Returns the type, CC_ALLOW or CC_DENY */ char GetType() @@ -245,11 +275,20 @@ public: return host; } + /** Get port number + */ int GetPort() { return port; } + /** Set port number + */ + void SetPort(int p) + { + port = p; + } + /** Returns the ping frequency */ unsigned int GetPingTime() @@ -298,6 +337,11 @@ public: { return maxglobal; } + + bool operator= (ConnectClass &other) + { + return (other.GetName() == name); + } }; /** Holds a complete list of all channels to which a user has been invited and has not yet joined. diff --git a/src/configreader.cpp b/src/configreader.cpp index ac483229a..c1ccc4ee9 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -404,25 +404,39 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, ValueList &v int recvq = values[8].GetInteger(); int localmax = values[9].GetInteger(); int globalmax = values[10].GetInteger(); - const char* name = values[11].GetString(); - const char* parent = values[12].GetString(); + int port = values[11].GetInteger(); + const char* name = values[12].GetString(); + const char* parent = values[13].GetString(); if (*parent) { /* Find 'parent' and inherit a new class from it, * then overwrite any values that are set here */ + for (std::vector<ConnectClass>::iterator item = conf->Classes.begin(); item != conf->Classes.end(); ++item) + { + if (item->GetName() == name) + { + ConnectClass c(name, *item); + c.Update(timeout, flood, std::string(*allow ? allow : deny), pingfreq, password, threshold, sendq, recvq, localmax, globalmax, 0); + c.SetPort(port); + conf->Classes.push_back(c); + } + } + throw CoreException("Class name '" + std::string(name) + "' is configured to inherit from class '" + std::string(name) + "' which cannot be found."); } else { if (*allow) { ConnectClass c(name, timeout, flood, allow, pingfreq, password, threshold, sendq, recvq, localmax, globalmax); + c.SetPort(port); conf->Classes.push_back(c); } else { ConnectClass c(name, deny); + c.SetPort(port); conf->Classes.push_back(c); } } |