]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Inherit non-core connect class settings properly.
authorPeter Powell <petpow@saberuk.com>
Sat, 21 Oct 2017 21:48:29 +0000 (22:48 +0100)
committerPeter Powell <petpow@saberuk.com>
Mon, 20 Nov 2017 12:14:45 +0000 (12:14 +0000)
Based partially on a patch by Attila.

src/users.cpp

index c2ff9c5be0f97444d3b57e5b7ae8502d662cdac0..ead862b7d7fbad402a1995203e4d7c57a18b67a6 100644 (file)
@@ -1188,7 +1188,32 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
        Update(&parent);
        name = "unnamed";
        type = t;
        Update(&parent);
        name = "unnamed";
        type = t;
-       config = tag;
+       host = mask;
+
+       // Connect classes can inherit from each other but this is problematic for modules which can't use
+       // ConnectClass::Update so we build a hybrid tag containing all of the values set on this class as
+       // well as the parent class.
+       ConfigItems* items = NULL;
+       config = ConfigTag::create(tag->tag, tag->src_name, tag->src_line, items);
+
+       const ConfigItems& parentkeys = parent.config->getItems();
+       for (ConfigItems::const_iterator piter = parentkeys.begin(); piter != parentkeys.end(); ++piter)
+       {
+               // The class name and parent name are not inherited
+               if (piter->first == "name" || piter->first == "parent")
+                       continue;
+
+               // Store the item in the config tag. If this item also
+               // exists in the child it will be overwritten.
+               (*items)[piter->first] = piter->second;
+       }
+
+       const ConfigItems& childkeys = tag->getItems();
+       for (ConfigItems::const_iterator citer = childkeys.begin(); citer != childkeys.end(); ++citer)
+       {
+               // This will overwrite the parent value if present.
+               (*items)[citer->first] = citer->second;
+       }
 }
 
 void ConnectClass::Update(const ConnectClass* src)
 }
 
 void ConnectClass::Update(const ConnectClass* src)