]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix weird typemask logic in the connect class reader.
authorSadie Powell <sadie@witchery.services>
Fri, 5 Mar 2021 02:59:24 +0000 (02:59 +0000)
committerSadie Powell <sadie@witchery.services>
Fri, 5 Mar 2021 03:07:49 +0000 (03:07 +0000)
src/configreader.cpp

index 596d52ef76e2602a96f87048fc6c3dc2222e138c..2cd17e844bcd0b62e7f42281395ac1fd1f0d8461 100644 (file)
@@ -175,22 +175,23 @@ void ServerConfig::CrossCheckOperClassType()
 
 void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
 {
-       typedef std::map<std::string, ConnectClass*> ClassMap;
+       typedef std::map<std::pair<std::string, char>, ConnectClass*> ClassMap;
        ClassMap oldBlocksByMask;
        if (current)
        {
                for(ClassVector::iterator i = current->Classes.begin(); i != current->Classes.end(); ++i)
                {
                        ConnectClass* c = *i;
-                       if (c->name.compare(0, 8, "unnamed-", 8))
+                       switch (c->type)
                        {
-                               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;
+                               case CC_ALLOW:
+                               case CC_DENY:
+                                       oldBlocksByMask[std::make_pair(c->host, c->type)] = c;
+                                       break;
+
+                               case CC_NAMED:
+                                       oldBlocksByMask[std::make_pair(c->name, c->type)] = c;
+                                       break;
                        }
                }
        }
@@ -238,24 +239,17 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                        }
 
                        std::string name = tag->getString("name");
-                       std::string mask, typeMask;
+                       std::string mask;
                        char type;
 
                        if (tag->readString("allow", mask, false))
-                       {
                                type = CC_ALLOW;
-                               typeMask = 'a' + mask;
-                       }
                        else if (tag->readString("deny", mask, false))
-                       {
                                type = CC_DENY;
-                               typeMask = 'd' + mask;
-                       }
                        else if (!name.empty())
                        {
                                type = CC_NAMED;
                                mask = name;
-                               typeMask = 'n' + mask;
                        }
                        else
                        {
@@ -263,13 +257,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                        }
 
                        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!");
@@ -323,7 +311,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                                        me->ports.insert(port);
                        }
 
-                       ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
+                       ClassMap::iterator oldMask = oldBlocksByMask.find(std::make_pair(me->name, me->type));
                        if (oldMask != oldBlocksByMask.end())
                        {
                                ConnectClass* old = oldMask->second;