Commit c5e76ba2 authored by jan.koester's avatar jan.koester
Browse files

test

parent 0e0bc138
Loading
Loading
Loading
Loading
+0 −37
Changes for src/conf.cpp: 0 added lines, 37 removed lines.
Original line number Diff line number Diff line
@@ -30,43 +30,6 @@
#include "conf.h"

blogi::Config::Config(const std::string &path) : confplus::Config(path), _ConfigPath(path){
    // Parse multi-domain AUTHDB sources.
    // Preferred form is an indexed sequence: /BLOGI/AUTHDB/<i>/URL ... .
    // A legacy single-mapping form (/BLOGI/AUTHDB/URL) is still supported.
    try {
        bool indexed = false;
        for (size_t i = 0; ; ++i) {
            std::string base = "/BLOGI/AUTHDB/" + std::to_string(i);
            auto *node = getKey(base.c_str());
            if (!node) break;
            indexed = true;
            AuthSource src;
            try { src.url = getValue(getKey((base + "/URL").c_str()), 0); } catch(...) { continue; }
            try { src.clientName = getValue(getKey((base + "/CLIENTNAME").c_str()), 0); } catch(...) {}
            try { src.clientSecret = getValue(getKey((base + "/CLIENTSECRET").c_str()), 0); } catch(...) {}
            try { src.domain = getValue(getKey((base + "/DOMAIN").c_str()), 0); } catch(...) { src.domain = ""; }
            _AuthSources.push_back(std::move(src));
        }
        if (!indexed && !_AuthUrl.empty()) {
            // Legacy single mapping
            AuthSource src;
            src.url = _AuthUrl;
            src.clientName = _ClientName;
            src.clientSecret = _ClientSecret;
            try { src.domain = getValue(getKey("/BLOGI/AUTHDB/DOMAIN"), 0); } catch(...) { src.domain = ""; }
            _AuthSources.push_back(std::move(src));
        }
    } catch (...) {
        // If multi-domain parsing fails, create a single source from legacy fields
        if (_AuthSources.empty() && !_AuthUrl.empty()) {
            AuthSource src;
            src.url = _AuthUrl;
            src.clientName = _ClientName;
            src.clientSecret = _ClientSecret;
            src.domain = "";
            _AuthSources.push_back(std::move(src));
        }
    }
    try { _HttpBind=getValue(getKey("/BLOGI/HTTP/BIND"),0); } catch(...) { _HttpBind="0.0.0.0"; }
    try {
        _HttpPort = getIntValue(getKey("/BLOGI/HTTP/PORT"), 0);