Loading src/blogi.cpp +2 −0 Changes for src/blogi.cpp: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -481,6 +481,7 @@ blogi::Blogi::Blogi(std::vector<netplus::socket *> serversocket, bool debug) cban.addRule(id, "Technical Required", "This Cookie is Required for Authentication and some Basic Funtions of this Blog", true); ctx.plugins = std::make_unique<Plugin>(); ctx.plugins->setSelection(dcfg.plgEnable, dcfg.plgDisable); ctx.plgArgs->plugins = ctx.plugins.get(); for (size_t i = 0; i < dcfg.plgDirs.size(); ++i) { Loading Loading @@ -650,6 +651,7 @@ bool blogi::Blogi::reloadConfig() cban.addRule(id, "Technical Required", "This Cookie is Required for Authentication and some Basic Funtions of this Blog", true); ctx->plugins = std::make_unique<Plugin>(); ctx->plugins->setSelection(dcfg.plgEnable, dcfg.plgDisable); ctx->plgArgs->plugins = ctx->plugins.get(); for (size_t i = 0; i < dcfg.plgDirs.size(); ++i) { Loading src/conf.cpp +23 −0 Changes for src/conf.cpp: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,23 @@ static std::string normalizeLanguage(std::string v) { return ""; } // YAML-Liste (oder Einzelwert) als Vektor; fehlt der Schluessel: false static bool readList(blogi::Config &cfg, const std::string &key, std::vector<std::string> &out) { try { auto *k = cfg.getKey(key.c_str()); if (!k) return false; out.clear(); size_t n = cfg.getElements(k); for (size_t i = 0; i < n; ++i) { std::string v = cfg.getValue(k, i); if (!v.empty()) out.push_back(v); } return true; } catch (...) { return false; } } blogi::Config::Config(const std::string &path) : confplus::Config(path), _ConfigPath(path){ try { _HttpBind=getValue(getKey("/BLOGI/HTTP/BIND"),0); } catch(...) { _HttpBind="0.0.0.0"; } try { Loading Loading @@ -77,6 +94,8 @@ blogi::Config::Config(const std::string &path) : confplus::Config(path), _Config _HttpPrefix = ""; try { _Template=getValue(getKey("/BLOGI/TEMPLATE"),0); } catch(...) {} try { _StartPage=getValue(getKey("/BLOGI/STARTPAGE"),0); } catch(...) {} readList(*this, "/BLOGI/PLUGINS", _PlgEnable); readList(*this, "/BLOGI/DISABLE_PLUGINS", _PlgDisable); try { _Language=normalizeLanguage(getValue(getKey("/BLOGI/LANGUAGE"),0)); } catch(...) {} try{ Loading Loading @@ -157,6 +176,10 @@ blogi::Config::Config(const std::string &path) : confplus::Config(path), _Config } catch(...) {} try { dc.tmpDir = getValue(getKey((base + "/TMPDIR").c_str()), 0); } catch(...) { dc.tmpDir = "/tmp/blogi"; } dc.plgEnable = _PlgEnable; dc.plgDisable = _PlgDisable; readList(*this, base + "/PLUGINS", dc.plgEnable); readList(*this, base + "/DISABLE_PLUGINS", dc.plgDisable); try { auto *plgKey = getKey((base + "/PLUGINDIR").c_str()); if (plgKey) { Loading src/conf.h +7 −0 Changes for src/conf.h: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -100,6 +100,11 @@ namespace blogi { // LANGUAGE on first start; the admin setting wins afterwards. std::string language; std::vector<std::string> plgDirs; // Plugin-Auswahl (Dateiname ohne lib/.so, z.B. "gtm", oder getName()): // PLUGINS = nur diese laden (leer = alle), DISABLE_PLUGINS = diese nicht. // Pro Domain; ohne eigene Angabe gelten BLOGI/PLUGINS bzw. BLOGI/DISABLE_PLUGINS. std::vector<std::string> plgEnable; std::vector<std::string> plgDisable; std::string mediaDBUrl; // Peer verification for the mediadb connection (MEDIA_TLS_VERIFY). Defaults to off, // matching mediadb's typical same-host/self-signed deployment. Loading Loading @@ -227,6 +232,8 @@ namespace blogi { private: std::string _ConfigPath; std::vector<std::string> _PlgDir; std::vector<std::string> _PlgEnable; // BLOGI/PLUGINS std::vector<std::string> _PlgDisable; // BLOGI/DISABLE_PLUGINS std::string _DBDriver; std::string _DBConnection; std::vector<ReplicaConfig> _DBReplicas; Loading src/plugin.cpp +39 −0 Changes for src/plugin.cpp: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ *******************************************************************************/ #include <iostream> #include <cctype> #include <cstring> #include <filesystem> Loading Loading @@ -212,6 +213,36 @@ void blogi::PluginApi::setArgs(blogi::PluginArgs* args){ blogi::Plugin::Plugin(){ } static std::string lowerStr(std::string v) { for (auto &c : v) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c))); return v; } // "libgtm.so" -> "gtm", "content.dll" -> "content" static std::string pluginFileId(const std::filesystem::path &p) { std::string stem = p.stem().string(); if (stem.rfind("lib", 0) == 0 && stem.size() > 3) stem = stem.substr(3); return lowerStr(stem); } void blogi::Plugin::setSelection(const std::vector<std::string> &enable, const std::vector<std::string> &disable) { _enable.clear(); _disable.clear(); for (auto &e : enable) _enable.push_back(lowerStr(e)); for (auto &d : disable) _disable.push_back(lowerStr(d)); } bool blogi::Plugin::selected(const std::string &fileId, const std::string &name) const { const std::string n = lowerStr(name); auto in = [&](const std::vector<std::string> &list) { for (auto &x : list) if (x == fileId || (!n.empty() && x == n)) return true; return false; }; if (in(_disable)) return false; return _enable.empty() || in(_enable); } void blogi::Plugin::loadPlugins(const std::string &path, PluginArgs *args){ try { Loading Loading @@ -283,6 +314,14 @@ void blogi::Plugin::loadPlugins(const std::string &path, PluginArgs *args){ << entry.path().filename().string() << std::endl; continue; } // abgewaehlt (PLUGINS/DISABLE_PLUGINS): vor initPlugin() verwerfen, // damit es keine Tabellen, Cookie-Regeln o.ae. anlegt if (!selected(pluginFileId(entry.path()), plg->getName())) { std::cout << "plugin disabled by config: " << entry.path().filename().string() << std::endl; PluginApiDeleter(destroy_plugin, ldplg->pldata)(plg); ldplg->pldata = nullptr; continue; } plg->setArgs(args); plg->initPlugin(); ldplg->ins=std::unique_ptr<PluginApi, PluginApiDeleter>(plg, PluginApiDeleter(destroy_plugin,ldplg->pldata)); Loading src/plugin.h +6 −0 Changes for src/plugin.h: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -240,6 +240,10 @@ namespace blogi { ~Plugin(); void loadPlugins(const std::string &path,PluginArgs *args); // Plugin-Auswahl fuer folgende loadPlugins()-Aufrufe. Eintraege sind // Dateinamen ohne "lib"/Endung ("gtm") oder PluginApi::getName(). // enable leer = alle erlaubt; disable hat Vorrang. void setSelection(const std::vector<std::string> &enable, const std::vector<std::string> &disable); class PluginData{ private: Loading @@ -263,6 +267,8 @@ namespace blogi { private: std::unique_ptr<PluginData> _firstPlugin = nullptr; PluginData *_lastPlugin = nullptr; std::vector<std::string> _enable, _disable; bool selected(const std::string &fileId, const std::string &name) const; }; namespace webedit { Loading Loading
src/blogi.cpp +2 −0 Changes for src/blogi.cpp: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -481,6 +481,7 @@ blogi::Blogi::Blogi(std::vector<netplus::socket *> serversocket, bool debug) cban.addRule(id, "Technical Required", "This Cookie is Required for Authentication and some Basic Funtions of this Blog", true); ctx.plugins = std::make_unique<Plugin>(); ctx.plugins->setSelection(dcfg.plgEnable, dcfg.plgDisable); ctx.plgArgs->plugins = ctx.plugins.get(); for (size_t i = 0; i < dcfg.plgDirs.size(); ++i) { Loading Loading @@ -650,6 +651,7 @@ bool blogi::Blogi::reloadConfig() cban.addRule(id, "Technical Required", "This Cookie is Required for Authentication and some Basic Funtions of this Blog", true); ctx->plugins = std::make_unique<Plugin>(); ctx->plugins->setSelection(dcfg.plgEnable, dcfg.plgDisable); ctx->plgArgs->plugins = ctx->plugins.get(); for (size_t i = 0; i < dcfg.plgDirs.size(); ++i) { Loading
src/conf.cpp +23 −0 Changes for src/conf.cpp: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,23 @@ static std::string normalizeLanguage(std::string v) { return ""; } // YAML-Liste (oder Einzelwert) als Vektor; fehlt der Schluessel: false static bool readList(blogi::Config &cfg, const std::string &key, std::vector<std::string> &out) { try { auto *k = cfg.getKey(key.c_str()); if (!k) return false; out.clear(); size_t n = cfg.getElements(k); for (size_t i = 0; i < n; ++i) { std::string v = cfg.getValue(k, i); if (!v.empty()) out.push_back(v); } return true; } catch (...) { return false; } } blogi::Config::Config(const std::string &path) : confplus::Config(path), _ConfigPath(path){ try { _HttpBind=getValue(getKey("/BLOGI/HTTP/BIND"),0); } catch(...) { _HttpBind="0.0.0.0"; } try { Loading Loading @@ -77,6 +94,8 @@ blogi::Config::Config(const std::string &path) : confplus::Config(path), _Config _HttpPrefix = ""; try { _Template=getValue(getKey("/BLOGI/TEMPLATE"),0); } catch(...) {} try { _StartPage=getValue(getKey("/BLOGI/STARTPAGE"),0); } catch(...) {} readList(*this, "/BLOGI/PLUGINS", _PlgEnable); readList(*this, "/BLOGI/DISABLE_PLUGINS", _PlgDisable); try { _Language=normalizeLanguage(getValue(getKey("/BLOGI/LANGUAGE"),0)); } catch(...) {} try{ Loading Loading @@ -157,6 +176,10 @@ blogi::Config::Config(const std::string &path) : confplus::Config(path), _Config } catch(...) {} try { dc.tmpDir = getValue(getKey((base + "/TMPDIR").c_str()), 0); } catch(...) { dc.tmpDir = "/tmp/blogi"; } dc.plgEnable = _PlgEnable; dc.plgDisable = _PlgDisable; readList(*this, base + "/PLUGINS", dc.plgEnable); readList(*this, base + "/DISABLE_PLUGINS", dc.plgDisable); try { auto *plgKey = getKey((base + "/PLUGINDIR").c_str()); if (plgKey) { Loading
src/conf.h +7 −0 Changes for src/conf.h: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -100,6 +100,11 @@ namespace blogi { // LANGUAGE on first start; the admin setting wins afterwards. std::string language; std::vector<std::string> plgDirs; // Plugin-Auswahl (Dateiname ohne lib/.so, z.B. "gtm", oder getName()): // PLUGINS = nur diese laden (leer = alle), DISABLE_PLUGINS = diese nicht. // Pro Domain; ohne eigene Angabe gelten BLOGI/PLUGINS bzw. BLOGI/DISABLE_PLUGINS. std::vector<std::string> plgEnable; std::vector<std::string> plgDisable; std::string mediaDBUrl; // Peer verification for the mediadb connection (MEDIA_TLS_VERIFY). Defaults to off, // matching mediadb's typical same-host/self-signed deployment. Loading Loading @@ -227,6 +232,8 @@ namespace blogi { private: std::string _ConfigPath; std::vector<std::string> _PlgDir; std::vector<std::string> _PlgEnable; // BLOGI/PLUGINS std::vector<std::string> _PlgDisable; // BLOGI/DISABLE_PLUGINS std::string _DBDriver; std::string _DBConnection; std::vector<ReplicaConfig> _DBReplicas; Loading
src/plugin.cpp +39 −0 Changes for src/plugin.cpp: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ *******************************************************************************/ #include <iostream> #include <cctype> #include <cstring> #include <filesystem> Loading Loading @@ -212,6 +213,36 @@ void blogi::PluginApi::setArgs(blogi::PluginArgs* args){ blogi::Plugin::Plugin(){ } static std::string lowerStr(std::string v) { for (auto &c : v) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c))); return v; } // "libgtm.so" -> "gtm", "content.dll" -> "content" static std::string pluginFileId(const std::filesystem::path &p) { std::string stem = p.stem().string(); if (stem.rfind("lib", 0) == 0 && stem.size() > 3) stem = stem.substr(3); return lowerStr(stem); } void blogi::Plugin::setSelection(const std::vector<std::string> &enable, const std::vector<std::string> &disable) { _enable.clear(); _disable.clear(); for (auto &e : enable) _enable.push_back(lowerStr(e)); for (auto &d : disable) _disable.push_back(lowerStr(d)); } bool blogi::Plugin::selected(const std::string &fileId, const std::string &name) const { const std::string n = lowerStr(name); auto in = [&](const std::vector<std::string> &list) { for (auto &x : list) if (x == fileId || (!n.empty() && x == n)) return true; return false; }; if (in(_disable)) return false; return _enable.empty() || in(_enable); } void blogi::Plugin::loadPlugins(const std::string &path, PluginArgs *args){ try { Loading Loading @@ -283,6 +314,14 @@ void blogi::Plugin::loadPlugins(const std::string &path, PluginArgs *args){ << entry.path().filename().string() << std::endl; continue; } // abgewaehlt (PLUGINS/DISABLE_PLUGINS): vor initPlugin() verwerfen, // damit es keine Tabellen, Cookie-Regeln o.ae. anlegt if (!selected(pluginFileId(entry.path()), plg->getName())) { std::cout << "plugin disabled by config: " << entry.path().filename().string() << std::endl; PluginApiDeleter(destroy_plugin, ldplg->pldata)(plg); ldplg->pldata = nullptr; continue; } plg->setArgs(args); plg->initPlugin(); ldplg->ins=std::unique_ptr<PluginApi, PluginApiDeleter>(plg, PluginApiDeleter(destroy_plugin,ldplg->pldata)); Loading
src/plugin.h +6 −0 Changes for src/plugin.h: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -240,6 +240,10 @@ namespace blogi { ~Plugin(); void loadPlugins(const std::string &path,PluginArgs *args); // Plugin-Auswahl fuer folgende loadPlugins()-Aufrufe. Eintraege sind // Dateinamen ohne "lib"/Endung ("gtm") oder PluginApi::getName(). // enable leer = alle erlaubt; disable hat Vorrang. void setSelection(const std::vector<std::string> &enable, const std::vector<std::string> &disable); class PluginData{ private: Loading @@ -263,6 +267,8 @@ namespace blogi { private: std::unique_ptr<PluginData> _firstPlugin = nullptr; PluginData *_lastPlugin = nullptr; std::vector<std::string> _enable, _disable; bool selected(const std::string &fileId, const std::string &name) const; }; namespace webedit { Loading