This commit is contained in:
MoneroOcean 2020-06-10 18:14:06 -07:00
commit 0ada4ca4ac
150 changed files with 12300 additions and 8764 deletions

View file

@ -27,6 +27,7 @@
#include "3rdparty/rapidjson/document.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/kernel/interfaces/IJsonReader.h"
#include "version.h"
@ -62,6 +63,7 @@ const char *BaseConfig::kHttp = "http";
const char *BaseConfig::kLogFile = "log-file";
const char *BaseConfig::kPrintTime = "print-time";
const char *BaseConfig::kSyslog = "syslog";
const char *BaseConfig::kTitle = "title";
const char *BaseConfig::kUserAgent = "user-agent";
const char *BaseConfig::kVerbose = "verbose";
const char *BaseConfig::kWatch = "watch";
@ -91,6 +93,7 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
m_logFile = reader.getString(kLogFile);
m_userAgent = reader.getString(kUserAgent);
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
m_title = reader.getValue(kTitle);
m_rebenchAlgo = reader.getBool("rebench-algo", m_rebenchAlgo);
m_benchAlgoTime = reader.getInt("bench-algo-time", m_benchAlgoTime);
@ -125,7 +128,7 @@ bool xmrig::BaseConfig::save()
getJSON(doc);
if (Json::save(m_fileName, doc)) {
LOG_NOTICE("configuration saved to: \"%s\"", m_fileName.data());
LOG_NOTICE("%s " WHITE_BOLD("configuration saved to: \"%s\""), Tags::config(), m_fileName.data());
return true;
}

View file

@ -26,6 +26,7 @@
#define XMRIG_BASECONFIG_H
#include "base/kernel/config/Title.h"
#include "base/kernel/interfaces/IConfig.h"
#include "base/net/http/Http.h"
#include "base/net/stratum/Pools.h"
@ -56,6 +57,7 @@ public:
static const char *kLogFile;
static const char *kPrintTime;
static const char *kSyslog;
static const char *kTitle;
static const char *kUserAgent;
static const char *kVerbose;
static const char *kWatch;
@ -76,6 +78,7 @@ public:
inline const Pools &pools() const { return m_pools; }
inline const String &apiId() const { return m_apiId; }
inline const String &apiWorkerId() const { return m_apiWorkerId; }
inline const Title &title() const { return m_title; }
inline uint32_t printTime() const { return m_printTime; }
inline bool isRebenchAlgo() const { return m_rebenchAlgo; }
@ -108,6 +111,7 @@ protected:
String m_fileName;
String m_logFile;
String m_userAgent;
Title m_title;
uint32_t m_printTime = 60;
bool m_rebenchAlgo = false;

View file

@ -204,6 +204,9 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
case IConfig::UserAgentKey: /* --user-agent */
return set(doc, BaseConfig::kUserAgent, arg);
case IConfig::TitleKey: /* --title */
return set(doc, BaseConfig::kTitle, arg);
# ifdef XMRIG_FEATURE_TLS
case IConfig::TlsCertKey: /* --tls-cert */
return set(doc, BaseConfig::kTls, TlsConfig::kCert, arg);
@ -250,6 +253,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
case IConfig::ColorKey: /* --no-color */
case IConfig::HttpRestrictedKey: /* --http-no-restricted */
case IConfig::NoTitleKey: /* --no-title */
return transformBoolean(doc, key, false);
default:
@ -303,6 +307,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
case IConfig::VerboseKey: /* --verbose */
return set(doc, BaseConfig::kVerbose, enable);
case IConfig::NoTitleKey: /* --no-title */
return set(doc, BaseConfig::kTitle, enable);
default:
break;
}

View file

@ -0,0 +1,58 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base/kernel/config/Title.h"
#include "3rdparty/rapidjson/document.h"
#include "base/io/Env.h"
#include "version.h"
xmrig::Title::Title(const rapidjson::Value &value)
{
if (value.IsBool()) {
m_enabled = value.GetBool();
}
else if (value.IsString()) {
m_value = value.GetString();
}
}
rapidjson::Value xmrig::Title::toJSON() const
{
if (isEnabled() && !m_value.isNull()) {
return m_value.toJSON();
}
return rapidjson::Value(m_enabled);
}
xmrig::String xmrig::Title::value() const
{
if (!isEnabled()) {
return {};
}
if (m_value.isNull()) {
return APP_NAME " " APP_VERSION;
}
return Env::expand(m_value);
}

View file

@ -0,0 +1,50 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_TITLE_H
#define XMRIG_TITLE_H
#include "3rdparty/rapidjson/fwd.h"
#include "base/tools/String.h"
namespace xmrig {
class Title
{
public:
Title() = default;
Title(const rapidjson::Value &value);
inline bool isEnabled() const { return m_enabled; }
rapidjson::Value toJSON() const;
String value() const;
private:
bool m_enabled = true;
String m_value;
};
} // namespace xmrig
#endif /* XMRIG_TITLE_H */