mirror of https://notabug.org/acetone/ircabot.git
base urls
parent
549d68b10a
commit
7c53f9c849
|
@ -34,6 +34,7 @@ constexpr const char CFG_LOG_FILE_DATE_FORMAT[] = "logFileDateFormat";
|
|||
constexpr const char CFG_WORKING_DIRECTORY[] = "workingDirectory";
|
||||
|
||||
constexpr const char CFG_WEBUI[] = "webUI";
|
||||
constexpr const char CFG_WEBUI_BASE_URL[] = "baseUrl";
|
||||
constexpr const char CFG_WEBUI_ADDRESS[] = "address";
|
||||
constexpr const char CFG_WEBUI_PORT[] = "port";
|
||||
constexpr const char CFG_WEBUI_THREADS[] = "threads";
|
||||
|
@ -59,6 +60,7 @@ QString Config::m_logFileDateFormat = "yyyy-MM-dd hh:mm:ss";
|
|||
|
||||
QString Config::m_workingDirectory = "";
|
||||
|
||||
QStringList Config::m_webUiBaseUrls;
|
||||
QString Config::m_webUiAddress;
|
||||
quint16 Config::m_webUiPort;
|
||||
uint Config::m_webUiThreads;
|
||||
|
@ -104,9 +106,28 @@ bool Config::initFromJson(const QJsonObject &config, QString* errorString)
|
|||
}
|
||||
|
||||
QJsonObject webUi = config.value(CFG_WEBUI).toObject();
|
||||
m_webUiAddress = webUi.value(CFG_WEBUI_ADDRESS).toString("127.0.0.1");
|
||||
m_webUiPort = webUi.value(CFG_WEBUI_PORT) .toInt(7666);
|
||||
m_webUiThreads = webUi.value(CFG_WEBUI_THREADS).toInt(0); // if <1, then system number
|
||||
m_webUiAddress = webUi.value(CFG_WEBUI_ADDRESS) .toString("127.0.0.1");
|
||||
m_webUiPort = webUi.value(CFG_WEBUI_PORT) .toInt(7666);
|
||||
m_webUiThreads = webUi.value(CFG_WEBUI_THREADS) .toInt(0); // if <1, then system number
|
||||
|
||||
m_webUiBaseUrls.clear();
|
||||
QJsonArray baseUrls = webUi.value(CFG_WEBUI_BASE_URL).toArray();
|
||||
for (const auto& jurl: baseUrls)
|
||||
{
|
||||
auto url = jurl.toString();
|
||||
if (not url.startsWith("http"))
|
||||
{
|
||||
qCritical() << "Base url" << url << "not starts with HTTP prefix";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_webUiBaseUrls.push_back(url.remove(' ').remove('\r').remove('\n'));
|
||||
}
|
||||
}
|
||||
if (m_webUiBaseUrls.isEmpty())
|
||||
{
|
||||
m_webUiBaseUrls.push_back("http://"+m_webUiAddress);
|
||||
}
|
||||
|
||||
QJsonArray jnetworks = config.value(CFG_NETWORKS).toArray();
|
||||
if (jnetworks.isEmpty())
|
||||
|
@ -187,6 +208,14 @@ bool Config::updateConfigWithCurrentData(QString *errorString)
|
|||
webui.insert(CFG_WEBUI_ADDRESS, webUiAddress());
|
||||
webui.insert(CFG_WEBUI_PORT, static_cast<int>(webUiPort()));
|
||||
webui.insert(CFG_WEBUI_THREADS, webUiThreads());
|
||||
QJsonArray baseUrls;
|
||||
QStringListIterator baseUrlsIter(m_webUiBaseUrls);
|
||||
while(baseUrlsIter.hasNext())
|
||||
{
|
||||
const auto url = baseUrlsIter.next();
|
||||
baseUrls.push_back(url);
|
||||
}
|
||||
webui.insert(CFG_WEBUI_BASE_URL, baseUrls);
|
||||
|
||||
config.insert(CFG_WEBUI, webui);
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
static const QString& webUiAddress() { return m_webUiAddress; }
|
||||
static quint16 webUiPort() { return m_webUiPort; }
|
||||
static int webUiThreads() { return m_webUiThreads; }
|
||||
static QStringList webUiBaseUrls() { return m_webUiBaseUrls; }
|
||||
|
||||
static const QString& workingDirectory() { return m_workingDirectory; }
|
||||
|
||||
|
@ -73,6 +74,7 @@ private:
|
|||
static QString m_logFileDateFormat;
|
||||
static QString m_workingDirectory;
|
||||
|
||||
static QStringList m_webUiBaseUrls;
|
||||
static QString m_webUiAddress;
|
||||
static quint16 m_webUiPort;
|
||||
static uint m_webUiThreads;
|
||||
|
|
Loading…
Reference in New Issue