diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-31 19:54:18 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-31 19:54:18 +0000 |
commit | 7fdd55570ea6269c096e6a3c8eae30c1a1587533 (patch) | |
tree | a1da62bdcb175e043493d39003f4fab1dae95f7b /src/configreader.cpp | |
parent | 1cda046fed93adef23eee9e2c21abfdf7c863e34 (diff) |
Update connect block matching on rehash to prefer names, show more useful information in /STATS i
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12337 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r-- | src/configreader.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index bbf3adf59..109137787 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -261,9 +261,16 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i) { ConnectClass* c = *i; - std::string typeMask = (c->type == CC_ALLOW) ? "a" : (c->type == CC_DENY) ? "d" : "n"; - typeMask += c->host; - oldBlocksByMask[typeMask] = c; + if (c->name.substr(0, 8) != "unnamed-") + { + oldBlocksByMask["n" + c->name] = c; + } + else if (c->type == CC_ALLOW || c->type == CC_DENY) + { + std::string typeMask = (c->type == CC_ALLOW) ? "a" : "d"; + typeMask += c->host; + oldBlocksByMask[typeMask] = c; + } } } @@ -278,7 +285,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) blk_count = 1; } - ClassMap newBlocksByMask; Classes.resize(blk_count); std::map<std::string, int> names; @@ -304,22 +310,13 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) try_again = true; // couldn't find parent this time. If it's the last time, we'll never find it. if (tries >= blk_count) - throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block " + ConvToStr(i)); + throw CoreException("Could not find parent connect class \"" + parentName + "\" for connect block at " + tag->getTagLocation()); continue; } parent = Classes[parentIter->second]; } std::string name = tag->getString("name"); - if (name.empty()) - { - name = "unnamed-" + ConvToStr(i); - } - - if (names.find(name) != names.end()) - throw CoreException("Two connect classes with name \"" + name + "\" defined!"); - names[name] = i; - std::string mask, typeMask; char type; @@ -333,15 +330,29 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) type = CC_DENY; typeMask = 'd' + mask; } - else + else if (!name.empty()) { type = CC_NAMED; mask = name; typeMask = 'n' + mask; } - ClassMap::iterator dupMask = newBlocksByMask.find(typeMask); - if (dupMask != newBlocksByMask.end()) - throw CoreException("Two connect classes cannot have the same mask (" + mask + ")"); + else + { + throw CoreException("Connect class must have allow, deny, or name specified at " + tag->getTagLocation()); + } + + if (name.empty()) + { + name = "unnamed-" + ConvToStr(i); + } + else + { + typeMask = 'n' + name; + } + + if (names.find(name) != names.end()) + throw CoreException("Two connect classes with name \"" + name + "\" defined!"); + names[name] = i; ConnectClass* me = parent ? new ConnectClass(tag, type, mask, *parent) : @@ -385,7 +396,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) delete me; me = old; } - newBlocksByMask[typeMask] = me; Classes[i] = me; } } |