mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-24 12:39:28 +00:00
Move shared summary to xmrig::CommonConfig.
This commit is contained in:
parent
14ac7b556e
commit
2f3939396e
4 changed files with 126 additions and 67 deletions
|
@ -37,24 +37,6 @@
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
static void print_versions(xmrig::Config *config)
|
|
||||||
{
|
|
||||||
char buf[16] = { 0 };
|
|
||||||
|
|
||||||
# if defined(__clang__)
|
|
||||||
snprintf(buf, 16, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
|
||||||
# elif defined(__GNUC__)
|
|
||||||
snprintf(buf, 16, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
|
||||||
# elif defined(_MSC_VER)
|
|
||||||
snprintf(buf, 16, " MSVC/%d", MSVC_VERSION);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" libuv/%s%s")
|
|
||||||
: " * %-13s%s/%s libuv/%s%s",
|
|
||||||
"VERSIONS", APP_NAME, APP_VERSION, uv_version_string(), buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void print_memory(xmrig::Config *config) {
|
static void print_memory(xmrig::Config *config) {
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
if (config->isColors()) {
|
if (config->isColors()) {
|
||||||
|
@ -120,44 +102,6 @@ static void print_threads(xmrig::Config *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void print_pools(xmrig::Config *config)
|
|
||||||
{
|
|
||||||
const std::vector<Pool> &pools = config->pools();
|
|
||||||
|
|
||||||
for (size_t i = 0; i < pools.size(); ++i) {
|
|
||||||
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") CYAN_BOLD("%s") " variant " WHITE_BOLD("%s")
|
|
||||||
: " * POOL #%-7d%s variant %s",
|
|
||||||
i + 1,
|
|
||||||
pools[i].url(),
|
|
||||||
pools[i].algorithm().variantName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifdef APP_DEBUG
|
|
||||||
LOG_NOTICE("POOLS --------------------------------------------------------------------");
|
|
||||||
for (const Pool &pool : pools) {
|
|
||||||
pool.print();
|
|
||||||
}
|
|
||||||
LOG_NOTICE("--------------------------------------------------------------------------");
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef XMRIG_NO_API
|
|
||||||
static void print_api(xmrig::Config *config)
|
|
||||||
{
|
|
||||||
const int port = config->apiPort();
|
|
||||||
if (port == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::i()->text(config->isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN("%s:") CYAN_BOLD("%d")
|
|
||||||
: " * %-13s%s:%d",
|
|
||||||
"API BIND", config->isApiIPv6() ? "[::]" : "0.0.0.0", port);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void print_commands(xmrig::Config *config)
|
static void print_commands(xmrig::Config *config)
|
||||||
{
|
{
|
||||||
if (config->isColors()) {
|
if (config->isColors()) {
|
||||||
|
@ -173,15 +117,12 @@ static void print_commands(xmrig::Config *config)
|
||||||
|
|
||||||
void Summary::print(xmrig::Controller *controller)
|
void Summary::print(xmrig::Controller *controller)
|
||||||
{
|
{
|
||||||
print_versions(controller->config());
|
controller->config()->printVersions();
|
||||||
print_memory(controller->config());
|
print_memory(controller->config());
|
||||||
print_cpu(controller->config());
|
print_cpu(controller->config());
|
||||||
print_threads(controller->config());
|
print_threads(controller->config());
|
||||||
print_pools(controller->config());
|
controller->config()->printPools();
|
||||||
|
controller->config()->printAPI();
|
||||||
# ifndef XMRIG_NO_API
|
|
||||||
print_api(controller->config());
|
|
||||||
# endif
|
|
||||||
|
|
||||||
print_commands(controller->config());
|
print_commands(controller->config());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,23 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_HTTPD
|
||||||
|
# include <microhttpd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_TLS
|
||||||
|
# include <openssl/opensslv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "common/config/CommonConfig.h"
|
#include "common/config/CommonConfig.h"
|
||||||
#include "common/log/Log.h"
|
#include "common/log/Log.h"
|
||||||
#include "donate.h"
|
#include "donate.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
#include "rapidjson/filewritestream.h"
|
#include "rapidjson/filewritestream.h"
|
||||||
#include "rapidjson/prettywriter.h"
|
#include "rapidjson/prettywriter.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::CommonConfig::CommonConfig() :
|
xmrig::CommonConfig::CommonConfig() :
|
||||||
|
@ -69,8 +80,100 @@ xmrig::CommonConfig::CommonConfig() :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::CommonConfig::~CommonConfig()
|
void xmrig::CommonConfig::printAPI()
|
||||||
{
|
{
|
||||||
|
# ifndef XMRIG_NO_API
|
||||||
|
if (apiPort() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::i()->text(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN("%s:") CYAN_BOLD("%d")
|
||||||
|
: " * %-13s%s:%d",
|
||||||
|
"API BIND", isApiIPv6() ? "[::]" : "0.0.0.0", apiPort());
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::CommonConfig::printPools()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < m_activePools.size(); ++i) {
|
||||||
|
if (!isColors()) {
|
||||||
|
Log::i()->text(" * POOL #%-7zu%s variant=%s, TLS=%d",
|
||||||
|
i + 1,
|
||||||
|
m_activePools[i].url(),
|
||||||
|
m_activePools[i].algorithm().variantName(),
|
||||||
|
static_cast<int>(m_activePools[i].isTLS())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") "\x1B[1;%dm%s\x1B[0m variant " WHITE_BOLD("%s"),
|
||||||
|
i + 1,
|
||||||
|
m_activePools[i].isTLS() ? 32 : 36,
|
||||||
|
m_activePools[i].url(),
|
||||||
|
m_activePools[i].algorithm().variantName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef APP_DEBUG
|
||||||
|
LOG_NOTICE("POOLS --------------------------------------------------------------------");
|
||||||
|
for (const Pool &pool : m_activePools) {
|
||||||
|
pool.print();
|
||||||
|
}
|
||||||
|
LOG_NOTICE("--------------------------------------------------------------------------");
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::CommonConfig::printVersions()
|
||||||
|
{
|
||||||
|
char buf[256] = { 0 };
|
||||||
|
|
||||||
|
# if defined(__clang__)
|
||||||
|
snprintf(buf, sizeof buf, "clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
snprintf(buf, sizeof buf, "gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
Log::i()->text(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s")
|
||||||
|
: " * %-13s%s/%s %s",
|
||||||
|
"ABOUT", APP_NAME, APP_VERSION, buf);
|
||||||
|
|
||||||
|
# if defined(XMRIG_AMD_PROJECT)
|
||||||
|
# if CL_VERSION_2_0
|
||||||
|
const char *ocl = "2.0";
|
||||||
|
# elif CL_VERSION_1_2
|
||||||
|
const char *ocl = "1.2";
|
||||||
|
# elif CL_VERSION_1_1
|
||||||
|
const char *ocl = "1.1";
|
||||||
|
# elif CL_VERSION_1_0
|
||||||
|
const char *ocl = "1.0";
|
||||||
|
# else
|
||||||
|
const char *ocl = "0.0";
|
||||||
|
# endif
|
||||||
|
int length = snprintf(buf, sizeof buf, "OpenCL/%s ", ocl);
|
||||||
|
# else
|
||||||
|
memset(buf, 0, 16);
|
||||||
|
int length = 0;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||||
|
{
|
||||||
|
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||||
|
length += snprintf(buf + length, (sizeof buf) - length, "OpenSSL/%.*s ", static_cast<int>(strchr(v, ' ') - v), v);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef XMRIG_NO_HTTPD
|
||||||
|
length += snprintf(buf + length, (sizeof buf) - length, "microhttpd/%s ", MHD_get_version());
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
Log::i()->text(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s")
|
||||||
|
: " * %-13slibuv/%s %s",
|
||||||
|
"LIBS", uv_version_string(), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __COMMONCONFIG_H__
|
#ifndef XMRIG_COMMONCONFIG_H
|
||||||
#define __COMMONCONFIG_H__
|
#define XMRIG_COMMONCONFIG_H
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -41,7 +41,6 @@ class CommonConfig : public IConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommonConfig();
|
CommonConfig();
|
||||||
~CommonConfig();
|
|
||||||
|
|
||||||
inline bool isApiIPv6() const { return m_apiIPv6; }
|
inline bool isApiIPv6() const { return m_apiIPv6; }
|
||||||
inline bool isApiRestricted() const { return m_apiRestricted; }
|
inline bool isApiRestricted() const { return m_apiRestricted; }
|
||||||
|
@ -68,6 +67,10 @@ public:
|
||||||
|
|
||||||
bool save() override;
|
bool save() override;
|
||||||
|
|
||||||
|
void printAPI();
|
||||||
|
void printPools();
|
||||||
|
void printVersions();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum State {
|
enum State {
|
||||||
NoneState,
|
NoneState,
|
||||||
|
|
|
@ -32,6 +32,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_TLS
|
||||||
|
# include <openssl/opensslv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "common/config/ConfigLoader.h"
|
#include "common/config/ConfigLoader.h"
|
||||||
#include "common/config/ConfigWatcher.h"
|
#include "common/config/ConfigWatcher.h"
|
||||||
#include "common/interfaces/IConfig.h"
|
#include "common/interfaces/IConfig.h"
|
||||||
|
@ -313,6 +318,13 @@ void xmrig::ConfigLoader::showVersion()
|
||||||
printf("\nlibuv/%s\n", uv_version_string());
|
printf("\nlibuv/%s\n", uv_version_string());
|
||||||
|
|
||||||
# ifndef XMRIG_NO_HTTPD
|
# ifndef XMRIG_NO_HTTPD
|
||||||
printf("libmicrohttpd/%s\n", MHD_get_version());
|
printf("microhttpd/%s\n", MHD_get_version());
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||||
|
{
|
||||||
|
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||||
|
printf("OpenSSL/%.*s\n", static_cast<int>(strchr(v, ' ') - v), v);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue