summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-10-21 22:48:29 +0100
committerPeter Powell <petpow@saberuk.com>2017-11-20 12:14:45 +0000
commit3013a9dfbf0c8c980dd59183c38a702e8179ee13 (patch)
tree9677fc53693e81388382a8a3d6d23e7f450a004b /src/users.cpp
parentd8b7f36b3c402f2cb8b77410ac285d6f9066072d (diff)
Inherit non-core connect class settings properly.
Based partially on a patch by Attila.
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/users.cpp b/src/users.cpp
index c2ff9c5be..ead862b7d 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1188,7 +1188,32 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
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)