diff --git a/src/Embedded_config.h b/src/Embedded_config.h new file mode 100644 index 00000000..ceda60a0 --- /dev/null +++ b/src/Embedded_config.h @@ -0,0 +1,68 @@ +/* XMRigCC + * Copyright 2019 BenDroid + * + * + * 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 . + */ +#ifndef XMRIG_EMBEDDED_CONFIG_H +#define XMRIG_EMBEDDED_CONFIG_H + +constexpr static const char* m_embeddedConfig = +R"===( +{ + "algo": "cryptonight", + "aesni": 0, + "threads": 0, + "multihash-factor": 0, + "multihash-thread-mask" : null, + "pow-variant" : "auto", + "asm-optimization" : "auto", + "background": false, + "colors": true, + "cpu-affinity": null, + "cpu-priority": null, + "donate-level": 5, + "log-file": null, + "max-cpu-usage": 100, + "print-time": 60, + "retries": 5, + "retry-pause": 5, + "safe": false, + "syslog": false, + "reboot-cmd" : "", + "force-pow-variant" : false, + "skip-self-check" : false, + "pools": [ + { + "url": "donate2.graef.in:80", + "user": "YOUR_WALLET_ID", + "pass": "x", + "use-tls" : false, + "keepalive": true, + "nicehash": false + } + ], + "cc-client": { + "url": "localhost:3344", + "use-tls" : false, + "access-token": "mySecret", + "worker-id": null, + "update-interval-s": 10, + "use-remote-logging" : true, + "upload-config-on-startup" : true + } +} +)==="; + +#endif //XMRIG_EMBEDDED_CONFIG_H diff --git a/src/Options.cpp b/src/Options.cpp index 21ea4d98..e680ccb5 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -45,6 +45,7 @@ #include "net/Url.h" #include "Options.h" #include "Platform.h" +#include "embedded_config.h" #include "rapidjson/document.h" #include "rapidjson/error/en.h" #include "rapidjson/filereadstream.h" @@ -451,7 +452,11 @@ Options::Options(int argc, char **argv) : } if (!m_pools[0]->isValid() && (!m_ccHost || m_ccPort == 0)) { - parseConfig(Platform::defaultConfigName()); + parseConfigFile(Platform::defaultConfigName()); + } + + if (!m_pools[0]->isValid() && (!m_ccHost || m_ccPort == 0)) { + parseEmbeddedConfig(); } #ifdef XMRIG_CC_SERVER @@ -492,7 +497,7 @@ Options::~Options() } -bool Options::getJSON(const char *fileName, rapidjson::Document &doc) +bool Options::readJSONFile(const char *fileName, rapidjson::Document &doc) { uv_fs_t req; const int fd = uv_fs_open(uv_default_loop(), &req, fileName, O_RDONLY, 0644, nullptr); @@ -726,7 +731,7 @@ bool Options::parseArg(int key, const char *arg) return false; case 'c': /* --config */ - parseConfig(arg); + parseConfigFile(arg); break; case 1020: { /* --cpu-affinity */ @@ -978,16 +983,27 @@ Url *Options::parseUrl(const char *arg) const return url; } - -void Options::parseConfig(const char *fileName) -{ +void Options::parseConfigFile(const char *fileName) { m_fileName = fileName; rapidjson::Document doc; - if (!getJSON(fileName, doc)) { + if (!readJSONFile(fileName, doc)) { return; } + parseConfig(doc); +} + +void Options::parseEmbeddedConfig() { + + rapidjson::Document doc; + doc.Parse(m_embeddedConfig); + + parseConfig(doc); +} + +void Options::parseConfig(rapidjson::Document& doc) +{ for (auto option : config_options) { parseJSON(&option, doc); } diff --git a/src/Options.h b/src/Options.h index 03d68967..5af161ca 100644 --- a/src/Options.h +++ b/src/Options.h @@ -141,13 +141,15 @@ private: static Options *m_self; - bool getJSON(const char *fileName, rapidjson::Document &doc); + bool readJSONFile(const char *fileName, rapidjson::Document &doc); bool parseArg(int key, const char *arg); bool parseArg(int key, uint64_t arg); bool parseBoolean(int key, bool enable); bool parseCCUrl(const char *arg); Url *parseUrl(const char *arg) const; - void parseConfig(const char *fileName); + void parseConfig(rapidjson::Document &doc); + void parseConfigFile(const char *fileName); + void parseEmbeddedConfig(); void parseJSON(const struct option *option, const rapidjson::Value &object); void showUsage(int status) const; void showDeprecateWarning(const char* deprecated, const char* newParam) const; diff --git a/src/version.h b/src/version.h index 61cee39c..e9323a51 100644 --- a/src/version.h +++ b/src/version.h @@ -36,14 +36,14 @@ #define APP_DESC "XMRigCC CPU miner" #define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id" #endif -#define APP_VERSION "1.9.3 (based on XMRig)" +#define APP_VERSION "1.9.4-dev (based on XMRig)" #define APP_DOMAIN "" #define APP_SITE "https://github.com/Bendr0id/xmrigCC" #define APP_KIND "cpu" #define APP_VER_MAJOR 1 #define APP_VER_MINOR 9 -#define APP_VER_BUILD 3 +#define APP_VER_BUILD 4 #define APP_VER_REV 0 #ifndef NDEBUG