diff --git a/src/base/api/requests/ApiRequest.cpp b/src/base/api/requests/ApiRequest.cpp index 4f0bd0443..841cd6a3b 100644 --- a/src/base/api/requests/ApiRequest.cpp +++ b/src/base/api/requests/ApiRequest.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/api/requests/ApiRequest.h" diff --git a/src/base/api/requests/ApiRequest.h b/src/base/api/requests/ApiRequest.h index c87e822c0..92f357b3a 100644 --- a/src/base/api/requests/ApiRequest.h +++ b/src/base/api/requests/ApiRequest.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_APIREQUEST_H #define XMRIG_APIREQUEST_H diff --git a/src/base/api/requests/HttpApiRequest.cpp b/src/base/api/requests/HttpApiRequest.cpp index de43f752e..c01387802 100644 --- a/src/base/api/requests/HttpApiRequest.cpp +++ b/src/base/api/requests/HttpApiRequest.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/api/requests/HttpApiRequest.h" #include "3rdparty/llhttp/llhttp.h" #include "3rdparty/rapidjson/error/en.h" diff --git a/src/base/api/requests/HttpApiRequest.h b/src/base/api/requests/HttpApiRequest.h index cb159757c..a1de5d861 100644 --- a/src/base/api/requests/HttpApiRequest.h +++ b/src/base/api/requests/HttpApiRequest.h @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPAPIREQUEST_H #define XMRIG_HTTPAPIREQUEST_H diff --git a/src/base/crypto/keccak.cpp b/src/base/crypto/keccak.cpp index aa60275cb..5c2176dd5 100644 --- a/src/base/crypto/keccak.cpp +++ b/src/base/crypto/keccak.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2011 Markku-Juhani O. Saarinen - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2011 Markku-Juhani O. Saarinen + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -23,7 +17,6 @@ * along with this program. If not, see . */ - #include diff --git a/src/base/crypto/keccak.h b/src/base/crypto/keccak.h index 2b039c909..ace23e11a 100644 --- a/src/base/crypto/keccak.h +++ b/src/base/crypto/keccak.h @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2011 Markku-Juhani O. Saarinen - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2011 Markku-Juhani O. Saarinen + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/io/Async.cpp b/src/base/io/Async.cpp index 255be8c0f..c50cdf6ea 100644 --- a/src/base/io/Async.cpp +++ b/src/base/io/Async.cpp @@ -1,8 +1,8 @@ /* XMRig * Copyright (c) 2015-2020 libuv project contributors. * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/io/Async.h b/src/base/io/Async.h index 19491082b..823eea1dd 100644 --- a/src/base/io/Async.h +++ b/src/base/io/Async.h @@ -1,8 +1,8 @@ /* XMRig * Copyright (c) 2015-2020 libuv project contributors. * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/io/json/Json_win.cpp b/src/base/io/json/Json_win.cpp index 499ae1298..3d24cd4a7 100644 --- a/src/base/io/json/Json_win.cpp +++ b/src/base/io/json/Json_win.cpp @@ -34,37 +34,21 @@ #include "3rdparty/rapidjson/istreamwrapper.h" #include "3rdparty/rapidjson/ostreamwrapper.h" #include "3rdparty/rapidjson/prettywriter.h" +#include "base/tools/Cvt.h" namespace xmrig { -#if defined(_MSC_VER) || defined (__GNUC__) -static std::wstring toUtf16(const char *str) -{ - const int size = static_cast(strlen(str)); - std::wstring ret; - - int len = MultiByteToWideChar(CP_UTF8, 0, str, size, nullptr, 0); - if (len > 0) { - ret.resize(static_cast(len)); - MultiByteToWideChar(CP_UTF8, 0, str, size, &ret[0], len); - } - - return ret; -} -#endif - - #if defined(_MSC_VER) # define OPEN_IFS(name) \ - std::ifstream ifs(toUtf16(name), std::ios_base::in | std::ios_base::binary); \ + std::ifstream ifs(Cvt::toUtf16(name), std::ios_base::in | std::ios_base::binary); \ if (!ifs.is_open()) { \ return false; \ } #elif defined(__GNUC__) # define OPEN_IFS(name) \ - const int fd = _wopen(toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \ + const int fd = _wopen(Cvt::toUtf16(name).c_str(), _O_RDONLY | _O_BINARY); \ if (fd == -1) { \ return false; \ } \ @@ -99,12 +83,12 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc) constexpr const std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary | std::ios_base::trunc; # if defined(_MSC_VER) - std::ofstream ofs(toUtf16(fileName), mode); + std::ofstream ofs(Cvt::toUtf16(fileName), mode); if (!ofs.is_open()) { return false; } # elif defined(__GNUC__) - const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); + const int fd = _wopen(Cvt::toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); if (fd == -1) { return false; } diff --git a/src/base/io/log/FileLogWriter.cpp b/src/base/io/log/FileLogWriter.cpp index b41f7f395..132b15b79 100644 --- a/src/base/io/log/FileLogWriter.cpp +++ b/src/base/io/log/FileLogWriter.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/io/log/FileLogWriter.h" #include "base/io/Env.h" diff --git a/src/base/io/log/backends/FileLog.cpp b/src/base/io/log/backends/FileLog.cpp index 51e5b1f73..c7df90951 100644 --- a/src/base/io/log/backends/FileLog.cpp +++ b/src/base/io/log/backends/FileLog.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/io/log/backends/FileLog.h" diff --git a/src/base/io/log/backends/FileLog.h b/src/base/io/log/backends/FileLog.h index c52cefd96..8919ce4c4 100644 --- a/src/base/io/log/backends/FileLog.h +++ b/src/base/io/log/backends/FileLog.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/io/log/backends/SysLog.cpp b/src/base/io/log/backends/SysLog.cpp index bd3339088..d93bd4837 100644 --- a/src/base/io/log/backends/SysLog.cpp +++ b/src/base/io/log/backends/SysLog.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -17,7 +17,7 @@ * along with this program. If not, see . */ - +#include #include @@ -43,5 +43,5 @@ void xmrig::SysLog::print(uint64_t, int level, const char *line, size_t offset, return; } - syslog(level == -1 ? LOG_INFO : level, "%s", line + offset); + syslog(level == -1 ? LOG_INFO : std::min(level, LOG_DEBUG), "%s", line + offset); } diff --git a/src/base/io/log/backends/SysLog.h b/src/base/io/log/backends/SysLog.h index 447ad0069..8bab49575 100644 --- a/src/base/io/log/backends/SysLog.h +++ b/src/base/io/log/backends/SysLog.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/Process_unix.cpp b/src/base/kernel/Process_unix.cpp index 3f1fdeb26..6bbf557fc 100644 --- a/src/base/kernel/Process_unix.cpp +++ b/src/base/kernel/Process_unix.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include #include diff --git a/src/base/kernel/Process_win.cpp b/src/base/kernel/Process_win.cpp index a8d5d2d46..1bcfaa583 100644 --- a/src/base/kernel/Process_win.cpp +++ b/src/base/kernel/Process_win.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include diff --git a/src/base/kernel/interfaces/IAsyncListener.h b/src/base/kernel/interfaces/IAsyncListener.h index 868646feb..d5a19d4d9 100644 --- a/src/base/kernel/interfaces/IAsyncListener.h +++ b/src/base/kernel/interfaces/IAsyncListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/IClientListener.h b/src/base/kernel/interfaces/IClientListener.h index 4f2be302c..5165d02fa 100644 --- a/src/base/kernel/interfaces/IClientListener.h +++ b/src/base/kernel/interfaces/IClientListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -30,6 +24,7 @@ #include "3rdparty/rapidjson/fwd.h" +#include "base/tools/Object.h" namespace xmrig { @@ -44,7 +39,10 @@ class SubmitResult; class IClientListener { public: - virtual ~IClientListener() = default; + XMRIG_DISABLE_COPY_MOVE(IClientListener) + + IClientListener() = default; + virtual ~IClientListener() = default; virtual void onClose(IClient *client, int failures) = 0; virtual void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) = 0; diff --git a/src/base/kernel/interfaces/IConfigTransform.h b/src/base/kernel/interfaces/IConfigTransform.h index c8ada0b8b..2f022925b 100644 --- a/src/base/kernel/interfaces/IConfigTransform.h +++ b/src/base/kernel/interfaces/IConfigTransform.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -27,6 +21,7 @@ #include "3rdparty/rapidjson/fwd.h" +#include "base/tools/Object.h" namespace xmrig { @@ -39,6 +34,9 @@ class String; class IConfigTransform { public: + XMRIG_DISABLE_COPY_MOVE(IConfigTransform) + + IConfigTransform() = default; virtual ~IConfigTransform() = default; virtual void finalize(rapidjson::Document &doc) = 0; diff --git a/src/base/kernel/interfaces/IConsoleListener.h b/src/base/kernel/interfaces/IConsoleListener.h index 694332108..194bc72f9 100644 --- a/src/base/kernel/interfaces/IConsoleListener.h +++ b/src/base/kernel/interfaces/IConsoleListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/IHttpListener.h b/src/base/kernel/interfaces/IHttpListener.h index 931d1933b..0588412e9 100644 --- a/src/base/kernel/interfaces/IHttpListener.h +++ b/src/base/kernel/interfaces/IHttpListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/ILineListener.h b/src/base/kernel/interfaces/ILineListener.h index a7d349012..bd8fb10db 100644 --- a/src/base/kernel/interfaces/ILineListener.h +++ b/src/base/kernel/interfaces/ILineListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/IStrategy.h b/src/base/kernel/interfaces/IStrategy.h index fc34521d6..690cf5431 100644 --- a/src/base/kernel/interfaces/IStrategy.h +++ b/src/base/kernel/interfaces/IStrategy.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -29,6 +23,9 @@ #include +#include "base/tools/Object.h" + + namespace xmrig { @@ -41,7 +38,10 @@ class ProxyUrl; class IStrategy { public: - virtual ~IStrategy() = default; + XMRIG_DISABLE_COPY_MOVE(IStrategy) + + IStrategy() = default; + virtual ~IStrategy() = default; virtual bool isActive() const = 0; virtual IClient *client() const = 0; diff --git a/src/base/kernel/interfaces/IStrategyListener.h b/src/base/kernel/interfaces/IStrategyListener.h index 605d15a98..60d54d74d 100644 --- a/src/base/kernel/interfaces/IStrategyListener.h +++ b/src/base/kernel/interfaces/IStrategyListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/ITcpServerListener.h b/src/base/kernel/interfaces/ITcpServerListener.h index 3cb1576e9..28b747a6d 100644 --- a/src/base/kernel/interfaces/ITcpServerListener.h +++ b/src/base/kernel/interfaces/ITcpServerListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -26,10 +20,13 @@ #define XMRIG_ITCPSERVERLISTENER_H -#include +#include -typedef struct uv_stream_s uv_stream_t; +#include "base/tools/Object.h" + + +using uv_stream_t = struct uv_stream_s; namespace xmrig { @@ -41,7 +38,10 @@ class String; class ITcpServerListener { public: - virtual ~ITcpServerListener() = default; + XMRIG_DISABLE_COPY_MOVE(ITcpServerListener) + + ITcpServerListener() = default; + virtual ~ITcpServerListener() = default; virtual void onConnection(uv_stream_t *stream, uint16_t port) = 0; }; diff --git a/src/base/kernel/interfaces/ITimerListener.h b/src/base/kernel/interfaces/ITimerListener.h index d169b12eb..5122923a1 100644 --- a/src/base/kernel/interfaces/ITimerListener.h +++ b/src/base/kernel/interfaces/ITimerListener.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/IWatcherListener.h b/src/base/kernel/interfaces/IWatcherListener.h index a62b4b533..110e67db2 100644 --- a/src/base/kernel/interfaces/IWatcherListener.h +++ b/src/base/kernel/interfaces/IWatcherListener.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -26,6 +20,9 @@ #define XMRIG_IWATCHERLISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { @@ -35,6 +32,9 @@ class String; class IWatcherListener { public: + XMRIG_DISABLE_COPY_MOVE(IWatcherListener) + + IWatcherListener() = default; virtual ~IWatcherListener() = default; virtual void onFileChanged(const String &fileName) = 0; diff --git a/src/base/net/dns/DnsRecord.cpp b/src/base/net/dns/DnsRecord.cpp index bfa84613a..4ff1acf82 100644 --- a/src/base/net/dns/DnsRecord.cpp +++ b/src/base/net/dns/DnsRecord.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include diff --git a/src/base/net/dns/DnsRecord.h b/src/base/net/dns/DnsRecord.h index 7a68ea2f7..b4b50d044 100644 --- a/src/base/net/dns/DnsRecord.h +++ b/src/base/net/dns/DnsRecord.h @@ -54,7 +54,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSRECORD_H */ +#endif // XMRIG_DNSRECORD_H diff --git a/src/base/net/dns/DnsRecords.h b/src/base/net/dns/DnsRecords.h index cfa192179..4d9248b66 100644 --- a/src/base/net/dns/DnsRecords.h +++ b/src/base/net/dns/DnsRecords.h @@ -42,7 +42,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSRECORDS_H */ +#endif // XMRIG_DNSRECORDS_H diff --git a/src/base/net/dns/DnsRequest.h b/src/base/net/dns/DnsRequest.h index 036eaa34f..4ee54fd02 100644 --- a/src/base/net/dns/DnsRequest.h +++ b/src/base/net/dns/DnsRequest.h @@ -23,9 +23,6 @@ #include "base/tools/Object.h" -#include - - namespace xmrig { @@ -44,7 +41,7 @@ public: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSREQUEST_H */ +#endif // XMRIG_DNSREQUEST_H diff --git a/src/base/net/dns/DnsUvBackend.cpp b/src/base/net/dns/DnsUvBackend.cpp index 8de95df54..a300fdf24 100644 --- a/src/base/net/dns/DnsUvBackend.cpp +++ b/src/base/net/dns/DnsUvBackend.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include @@ -28,17 +27,17 @@ namespace xmrig { -static Storage* storage = nullptr; + +static Storage *storage = nullptr; + Storage& DnsUvBackend::getStorage() { - if (storage == nullptr) storage = new Storage(); - return *storage; -} + if (!storage) { + storage = new Storage(); + } -void DnsUvBackend::releaseStorage() -{ - delete storage; + return *storage; } static addrinfo hints{}; @@ -62,7 +61,9 @@ xmrig::DnsUvBackend::DnsUvBackend() xmrig::DnsUvBackend::~DnsUvBackend() { getStorage().release(m_key); - releaseStorage(); + + delete storage; + storage = nullptr; } diff --git a/src/base/net/dns/DnsUvBackend.h b/src/base/net/dns/DnsUvBackend.h index 3c2436c7e..4f5cba6f5 100644 --- a/src/base/net/dns/DnsUvBackend.h +++ b/src/base/net/dns/DnsUvBackend.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 @@ -62,11 +62,10 @@ private: uintptr_t m_key; static Storage& getStorage(); - void releaseStorage(); }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_DNSUVBACKEND_H */ +#endif // XMRIG_DNSUVBACKEND_H diff --git a/src/base/net/http/Fetch.h b/src/base/net/http/Fetch.h index 6c02e3482..99d48a4f9 100644 --- a/src/base/net/http/Fetch.h +++ b/src/base/net/http/Fetch.h @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_FETCH_H #define XMRIG_FETCH_H diff --git a/src/base/net/http/HttpApiResponse.cpp b/src/base/net/http/HttpApiResponse.cpp index e6758df9a..3d48fb47d 100644 --- a/src/base/net/http/HttpApiResponse.cpp +++ b/src/base/net/http/HttpApiResponse.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpApiResponse.h" #include "3rdparty/rapidjson/prettywriter.h" #include "3rdparty/rapidjson/stringbuffer.h" diff --git a/src/base/net/http/HttpClient.h b/src/base/net/http/HttpClient.h index ccda2e567..1520936bc 100644 --- a/src/base/net/http/HttpClient.h +++ b/src/base/net/http/HttpClient.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPCLIENT_H #define XMRIG_HTTPCLIENT_H diff --git a/src/base/net/http/HttpContext.cpp b/src/base/net/http/HttpContext.cpp index 948873c9a..1a1b7e1dd 100644 --- a/src/base/net/http/HttpContext.cpp +++ b/src/base/net/http/HttpContext.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpContext.h" #include "3rdparty/llhttp/llhttp.h" #include "base/kernel/interfaces/IHttpListener.h" diff --git a/src/base/net/http/HttpContext.h b/src/base/net/http/HttpContext.h index 9178cf7c3..af1801725 100644 --- a/src/base/net/http/HttpContext.h +++ b/src/base/net/http/HttpContext.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPCONTEXT_H #define XMRIG_HTTPCONTEXT_H diff --git a/src/base/net/http/HttpData.cpp b/src/base/net/http/HttpData.cpp index b243118ca..50e440430 100644 --- a/src/base/net/http/HttpData.cpp +++ b/src/base/net/http/HttpData.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpData.h" #include "3rdparty/llhttp/llhttp.h" #include "3rdparty/rapidjson/document.h" diff --git a/src/base/net/http/HttpData.h b/src/base/net/http/HttpData.h index 3337999a5..19b85f648 100644 --- a/src/base/net/http/HttpData.h +++ b/src/base/net/http/HttpData.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPDATA_H #define XMRIG_HTTPDATA_H diff --git a/src/base/net/http/HttpListener.cpp b/src/base/net/http/HttpListener.cpp index 695e0f821..93b26ffef 100644 --- a/src/base/net/http/HttpListener.cpp +++ b/src/base/net/http/HttpListener.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpListener.h" #include "3rdparty/llhttp/llhttp.h" #include "base/io/log/Log.h" diff --git a/src/base/net/http/HttpResponse.cpp b/src/base/net/http/HttpResponse.cpp index 216e3e511..15820f187 100644 --- a/src/base/net/http/HttpResponse.cpp +++ b/src/base/net/http/HttpResponse.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/http/HttpResponse.h" #include "3rdparty/llhttp/llhttp.h" #include "base/io/log/Log.h" diff --git a/src/base/net/http/HttpServer.cpp b/src/base/net/http/HttpServer.cpp index aab750039..b440731cb 100644 --- a/src/base/net/http/HttpServer.cpp +++ b/src/base/net/http/HttpServer.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include #include diff --git a/src/base/net/https/HttpsClient.cpp b/src/base/net/https/HttpsClient.cpp index e901b1e0c..9d389671e 100644 --- a/src/base/net/https/HttpsClient.cpp +++ b/src/base/net/https/HttpsClient.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2014-2019 heapwolf - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include #include #include diff --git a/src/base/net/https/HttpsClient.h b/src/base/net/https/HttpsClient.h index bd0c65ffd..aa32cb992 100644 --- a/src/base/net/https/HttpsClient.h +++ b/src/base/net/https/HttpsClient.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2014-2019 heapwolf - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPSCLIENT_H #define XMRIG_HTTPSCLIENT_H diff --git a/src/base/net/https/HttpsContext.h b/src/base/net/https/HttpsContext.h index ff060f022..b5d5175ad 100644 --- a/src/base/net/https/HttpsContext.h +++ b/src/base/net/https/HttpsContext.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_HTTPSCONTEXT_H #define XMRIG_HTTPSCONTEXT_H diff --git a/src/base/net/https/HttpsServer.h b/src/base/net/https/HttpsServer.h index ad21162f3..21f3d6cf7 100644 --- a/src/base/net/https/HttpsServer.h +++ b/src/base/net/https/HttpsServer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 056c7225d..23a581cf2 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -23,7 +17,6 @@ * along with this program. If not, see . */ - #include @@ -64,9 +57,9 @@ namespace xmrig { Storage DaemonClient::m_storage; -static const char* kBlocktemplateBlob = "blocktemplate_blob"; -static const char* kBlockhashingBlob = "blockhashing_blob"; -static const char* kLastError = "lasterror"; +static const char *kBlocktemplateBlob = "blocktemplate_blob"; +static const char *kBlockhashingBlob = "blockhashing_blob"; +static const char *kLastError = "lasterror"; static const char *kGetHeight = "/getheight"; static const char *kGetInfo = "/getinfo"; static const char *kHash = "hash"; @@ -105,6 +98,7 @@ xmrig::DaemonClient::~DaemonClient() { delete m_timer; delete m_ZMQSocket; + # ifdef XMRIG_FEATURE_TLS delete m_wss.m_socket; # endif diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index fd002d0e3..d6c917016 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -1,14 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2019 Howard Chu - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018 Lee Clagett + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -24,7 +18,6 @@ * along with this program. If not, see . */ - #include #include @@ -176,6 +169,7 @@ int32_t xmrig::Job::nonceOffset() const return 39; } + uint32_t xmrig::Job::getNumTransactions() const { if (!(m_algorithm.isCN() || m_algorithm.family() == Algorithm::RANDOM_X)) { diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 3fb31baa5..56fdf92c7 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -1,14 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2019 Howard Chu - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018 Lee Clagett + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/Pools.cpp b/src/base/net/stratum/Pools.cpp index a2374b9dd..3211c6611 100644 --- a/src/base/net/stratum/Pools.cpp +++ b/src/base/net/stratum/Pools.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/stratum/Pools.h" #include "3rdparty/rapidjson/document.h" #include "base/io/log/Log.h" @@ -171,7 +164,7 @@ uint32_t xmrig::Pools::benchSize() const return m_benchmark ? m_benchmark->size() : 0; # else return 0; -# endif +# endif } diff --git a/src/base/net/stratum/Pools.h b/src/base/net/stratum/Pools.h index b3f6b0815..42f37e815 100644 --- a/src/base/net/stratum/Pools.h +++ b/src/base/net/stratum/Pools.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/ProxyUrl.cpp b/src/base/net/stratum/ProxyUrl.cpp index ad4542bc6..48d804143 100644 --- a/src/base/net/stratum/ProxyUrl.cpp +++ b/src/base/net/stratum/ProxyUrl.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/stratum/ProxyUrl.h" #include "3rdparty/rapidjson/document.h" diff --git a/src/base/net/stratum/ProxyUrl.h b/src/base/net/stratum/ProxyUrl.h index 0604dd9dd..f4ab2edb8 100644 --- a/src/base/net/stratum/ProxyUrl.h +++ b/src/base/net/stratum/ProxyUrl.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/Socks5.cpp b/src/base/net/stratum/Socks5.cpp index d61aa3292..a89087a0f 100644 --- a/src/base/net/stratum/Socks5.cpp +++ b/src/base/net/stratum/Socks5.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/stratum/Socks5.h" diff --git a/src/base/net/stratum/Socks5.h b/src/base/net/stratum/Socks5.h index 286ae1832..36707ce0a 100644 --- a/src/base/net/stratum/Socks5.h +++ b/src/base/net/stratum/Socks5.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/SubmitResult.h b/src/base/net/stratum/SubmitResult.h index a180f6fa5..b98869f4a 100644 --- a/src/base/net/stratum/SubmitResult.h +++ b/src/base/net/stratum/SubmitResult.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/strategies/FailoverStrategy.cpp b/src/base/net/stratum/strategies/FailoverStrategy.cpp index 604f55966..d532421e2 100644 --- a/src/base/net/stratum/strategies/FailoverStrategy.cpp +++ b/src/base/net/stratum/strategies/FailoverStrategy.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,12 +16,10 @@ * along with this program. If not, see . */ - #include "base/net/stratum/strategies/FailoverStrategy.h" #include "3rdparty/rapidjson/document.h" #include "base/kernel/interfaces/IClient.h" #include "base/kernel/interfaces/IStrategyListener.h" -#include "base/kernel/Platform.h" xmrig::FailoverStrategy::FailoverStrategy(const std::vector &pools, int retryPause, int retries, IStrategyListener *listener, bool quiet) : diff --git a/src/base/net/stratum/strategies/FailoverStrategy.h b/src/base/net/stratum/strategies/FailoverStrategy.h index a25c82b78..e0bfc0a54 100644 --- a/src/base/net/stratum/strategies/FailoverStrategy.h +++ b/src/base/net/stratum/strategies/FailoverStrategy.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/strategies/SinglePoolStrategy.cpp b/src/base/net/stratum/strategies/SinglePoolStrategy.cpp index fc0fc5624..37ae7a146 100644 --- a/src/base/net/stratum/strategies/SinglePoolStrategy.cpp +++ b/src/base/net/stratum/strategies/SinglePoolStrategy.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -22,12 +16,10 @@ * along with this program. If not, see . */ - #include "base/net/stratum/strategies/SinglePoolStrategy.h" #include "3rdparty/rapidjson/document.h" #include "base/kernel/interfaces/IClient.h" #include "base/kernel/interfaces/IStrategyListener.h" -#include "base/kernel/Platform.h" #include "base/net/stratum/Pool.h" diff --git a/src/base/net/stratum/strategies/SinglePoolStrategy.h b/src/base/net/stratum/strategies/SinglePoolStrategy.h index 90b85c7d7..bdedd743f 100644 --- a/src/base/net/stratum/strategies/SinglePoolStrategy.h +++ b/src/base/net/stratum/strategies/SinglePoolStrategy.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/stratum/strategies/StrategyProxy.h b/src/base/net/stratum/strategies/StrategyProxy.h index 2c0fc235e..505d50715 100644 --- a/src/base/net/stratum/strategies/StrategyProxy.h +++ b/src/base/net/stratum/strategies/StrategyProxy.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/tls/ServerTls.cpp b/src/base/net/tls/ServerTls.cpp index abae315d7..338777c7d 100644 --- a/src/base/net/tls/ServerTls.cpp +++ b/src/base/net/tls/ServerTls.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/tls/ServerTls.h" diff --git a/src/base/net/tls/ServerTls.h b/src/base/net/tls/ServerTls.h index 20337eb6b..d17519751 100644 --- a/src/base/net/tls/ServerTls.h +++ b/src/base/net/tls/ServerTls.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #ifndef XMRIG_SERVERTLS_H #define XMRIG_SERVERTLS_H diff --git a/src/base/net/tools/LineReader.cpp b/src/base/net/tools/LineReader.cpp index 07d0f1dc2..e811547b6 100644 --- a/src/base/net/tools/LineReader.cpp +++ b/src/base/net/tools/LineReader.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #include "base/net/tools/LineReader.h" #include "base/kernel/constants.h" #include "base/kernel/interfaces/ILineListener.h" diff --git a/src/base/net/tools/LineReader.h b/src/base/net/tools/LineReader.h index da6e6967d..e84853b65 100644 --- a/src/base/net/tools/LineReader.h +++ b/src/base/net/tools/LineReader.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2020 cohcho - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/tools/MemPool.h b/src/base/net/tools/MemPool.h index 8a0a126b4..196c67fc9 100644 --- a/src/base/net/tools/MemPool.h +++ b/src/base/net/tools/MemPool.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/tools/NetBuffer.cpp b/src/base/net/tools/NetBuffer.cpp index 8931f06e7..f597ca3a6 100644 --- a/src/base/net/tools/NetBuffer.cpp +++ b/src/base/net/tools/NetBuffer.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/net/tools/NetBuffer.h" #include "base/kernel/constants.h" #include "base/net/tools/MemPool.h" diff --git a/src/base/net/tools/NetBuffer.h b/src/base/net/tools/NetBuffer.h index a7a2ee05e..93616601e 100644 --- a/src/base/net/tools/NetBuffer.h +++ b/src/base/net/tools/NetBuffer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/net/tools/TcpServer.cpp b/src/base/net/tools/TcpServer.cpp index 06d4033a7..9e516a001 100644 --- a/src/base/net/tools/TcpServer.cpp +++ b/src/base/net/tools/TcpServer.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -22,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/kernel/interfaces/ITcpServerListener.h" #include "base/net/tools/TcpServer.h" #include "base/tools/Handle.h" diff --git a/src/base/net/tools/TcpServer.h b/src/base/net/tools/TcpServer.h index de464d372..24ae42d64 100644 --- a/src/base/net/tools/TcpServer.h +++ b/src/base/net/tools/TcpServer.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/tools/Baton.h b/src/base/tools/Baton.h index accaf51ce..3ccac6b4e 100644 --- a/src/base/tools/Baton.h +++ b/src/base/tools/Baton.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/tools/Buffer.h b/src/base/tools/Buffer.h index 91c98e644..871e7a6a0 100644 --- a/src/base/tools/Buffer.h +++ b/src/base/tools/Buffer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/tools/Cvt.cpp b/src/base/tools/Cvt.cpp index 3f083a266..fa4642537 100644 --- a/src/base/tools/Cvt.cpp +++ b/src/base/tools/Cvt.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2013-2020 Frank Denis - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 @@ -17,6 +17,10 @@ * along with this program. If not, see . */ +#ifdef XMRIG_OS_WIN +# include +#endif + #include "base/tools/Cvt.h" #include "3rdparty/rapidjson/document.h" @@ -25,7 +29,7 @@ #include -#ifdef XMRIG_SODIUM +#if defined(XMRIG_FEATURE_SODIUM) || defined(XMRIG_SODIUM) # include #endif @@ -63,7 +67,7 @@ static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigne } -#ifndef XMRIG_SODIUM +#if !defined(XMRIG_FEATURE_SODIUM) && !defined(XMRIG_SODIUM) static std::random_device randomDevice; static std::mt19937 randomEngine(randomDevice()); @@ -224,7 +228,7 @@ xmrig::Buffer xmrig::Cvt::randomBytes(const size_t size) { Buffer buf(size); -# ifndef XMRIG_SODIUM +# if !defined(XMRIG_FEATURE_SODIUM) && !defined(XMRIG_SODIUM) std::uniform_int_distribution<> dis(0, 255); for (size_t i = 0; i < size; ++i) { @@ -284,7 +288,7 @@ xmrig::String xmrig::Cvt::toHex(const uint8_t *in, size_t size) void xmrig::Cvt::randomBytes(void *buf, size_t size) { -# ifndef XMRIG_SODIUM +# if !defined(XMRIG_FEATURE_SODIUM) && !defined(XMRIG_SODIUM) std::uniform_int_distribution<> dis(0, 255); for (size_t i = 0; i < size; ++i) { @@ -294,3 +298,32 @@ void xmrig::Cvt::randomBytes(void *buf, size_t size) randombytes_buf(buf, size); # endif } + + +#ifdef XMRIG_OS_WIN +std::string xmrig::Cvt::toUtf8(const wchar_t *str, int size) +{ + std::string ret; + const int len = WideCharToMultiByte(CP_UTF8, 0, str, size, nullptr, 0, nullptr, nullptr); + if (len > 0) { + ret.resize(static_cast(len)); + WideCharToMultiByte(CP_UTF8, 0, str, size, &ret[0], len, nullptr, nullptr); + } + + return ret; +} + + +std::wstring xmrig::Cvt::toUtf16(const char *str, int size) +{ + std::wstring ret; + + const int len = MultiByteToWideChar(CP_UTF8, 0, str, size, nullptr, 0); + if (len > 0) { + ret.resize(static_cast(len)); + MultiByteToWideChar(CP_UTF8, 0, str, size, &ret[0], len); + } + + return ret; +} +#endif diff --git a/src/base/tools/Cvt.h b/src/base/tools/Cvt.h index 58058127b..b546cd03a 100644 --- a/src/base/tools/Cvt.h +++ b/src/base/tools/Cvt.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 @@ -57,6 +57,11 @@ public: 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 void randomBytes(void *buf, size_t size); + +# ifdef XMRIG_OS_WIN + static std::string toUtf8(const wchar_t *str, int size = -1); + static std::wstring toUtf16(const char *str, int size = -1); +# endif }; diff --git a/src/base/tools/Handle.h b/src/base/tools/Handle.h index fcd341478..de269549f 100644 --- a/src/base/tools/Handle.h +++ b/src/base/tools/Handle.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 diff --git a/src/base/tools/Object.h b/src/base/tools/Object.h index 00bd9315a..6614b312e 100644 --- a/src/base/tools/Object.h +++ b/src/base/tools/Object.h @@ -20,7 +20,9 @@ #define XMRIG_OBJECT_H -#include +#include +#include +#include namespace xmrig { @@ -41,6 +43,10 @@ namespace xmrig { X &operator=(X &&other) = delete; -} /* namespace xmrig */ +#define XMRIG_DECL_PRIVATE() class Private; const std::shared_ptr d; -#endif /* XMRIG_OBJECT_H */ + +} // namespace xmrig + + +#endif // XMRIG_OBJECT_H diff --git a/src/base/tools/String.cpp b/src/base/tools/String.cpp index 2d9ef4da1..676ac2077 100644 --- a/src/base/tools/String.cpp +++ b/src/base/tools/String.cpp @@ -26,7 +26,7 @@ xmrig::String::String(const char *str, size_t size) : m_size(size) { - if (str == nullptr) { + if (str == nullptr || size == 0) { m_size = 0; return; diff --git a/src/base/tools/String.h b/src/base/tools/String.h index 59d6f1a26..b9fed8948 100644 --- a/src/base/tools/String.h +++ b/src/base/tools/String.h @@ -59,25 +59,29 @@ public: inline bool contains(const char *str) const { return isNull() ? false : strstr(m_data, str) != nullptr; } - inline bool isEmpty() const { return size() == 0; } - inline bool isNull() const { return m_data == nullptr; } - inline bool isValid() const { return m_data != nullptr; } - inline char *data() { return m_data; } - inline const char *data() const { return m_data; } - inline size_t size() const { return m_size; } + inline bool isEmpty() const { return size() == 0; } + inline bool isNull() const { return m_data == nullptr; } + inline bool isValid() const { return m_data != nullptr; } + inline char *data() { return m_data; } + inline const char *data() const { return m_data; } + inline int32_t toInt(int32_t dv = 0) const { return isEmpty() ? dv : strtol(data(), nullptr, 0); } + inline int64_t toInt64(int64_t dv = 0) const { return isEmpty() ? dv : strtoll(data(), nullptr, 0); } + inline size_t size() const { return m_size; } + inline uint32_t toUint(uint32_t dv = 0) const { return isEmpty() ? dv : strtoul(data(), nullptr, 0); } + inline uint64_t toUint64(uint64_t dv = 0) const { return isEmpty() ? dv : strtoull(data(), nullptr, 0); } - inline bool operator!=(const char *str) const { return !isEqual(str); } - inline bool operator!=(const String &other) const { return !isEqual(other); } - inline bool operator<(const String &str) const { return !isEmpty() && !str.isEmpty() && strcmp(data(), str.data()) < 0; } - inline bool operator==(const char *str) const { return isEqual(str); } - inline bool operator==(const String &other) const { return isEqual(other); } - inline operator const char*() const { return m_data; } - inline String &operator=(char *str) { move(str); return *this; } - inline String &operator=(const char *str) { copy(str); return *this; } - inline String &operator=(const String &str) { copy(str); return *this; } - inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; } - inline String &operator=(String &&other) noexcept { move(std::move(other)); return *this; } + inline bool operator!=(const char *str) const { return !isEqual(str); } + inline bool operator!=(const String &other) const { return !isEqual(other); } + inline bool operator<(const String &str) const { return !isEmpty() && !str.isEmpty() && strcmp(data(), str.data()) < 0; } + inline bool operator==(const char *str) const { return isEqual(str); } + inline bool operator==(const String &other) const { return isEqual(other); } + inline operator const char*() const { return m_data; } + inline String &operator=(char *str) { move(str); return *this; } + inline String &operator=(const char *str) { copy(str); return *this; } + inline String &operator=(const String &str) { copy(str); return *this; } + inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; } + inline String &operator=(String &&other) noexcept { move(std::move(other)); return *this; } rapidjson::Value toJSON() const; rapidjson::Value toJSON(rapidjson::Document &doc) const; diff --git a/src/base/tools/Timer.cpp b/src/base/tools/Timer.cpp index 858d1219e..0ad792782 100644 --- a/src/base/tools/Timer.cpp +++ b/src/base/tools/Timer.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -16,29 +16,15 @@ * along with this program. If not, see . */ - #include "base/tools/Timer.h" #include "base/kernel/interfaces/ITimerListener.h" #include "base/tools/Handle.h" -xmrig::Timer::Timer(ITimerListener *listener) : - m_listener(listener) -{ - init(); -} - - -xmrig::Timer::Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) : - m_listener(listener) -{ - init(); - start(timeout, repeat); -} - - xmrig::Timer::~Timer() { + stop(); + Handle::close(m_timer); } diff --git a/src/base/tools/Timer.h b/src/base/tools/Timer.h index 8fd040f83..f9c016266 100644 --- a/src/base/tools/Timer.h +++ b/src/base/tools/Timer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * 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 @@ -26,9 +26,6 @@ using uv_timer_t = struct uv_timer_s; #include "base/tools/Object.h" -#include - - namespace xmrig { @@ -40,8 +37,9 @@ class Timer public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(Timer); - Timer(ITimerListener *listener); - Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat); + Timer(ITimerListener *listener, uint64_t repeat) : m_listener(listener) { init(); start(repeat, repeat); } + Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) : m_listener(listener) { init(); start(timeout, repeat); } + Timer(ITimerListener *listener) : m_listener(listener) { init(); } ~Timer(); inline int id() const { return m_id; } @@ -63,7 +61,7 @@ private: }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_TIMER_H */ +#endif // XMRIG_TIMER_H diff --git a/src/base/tools/bswap_64.h b/src/base/tools/bswap_64.h index 462a33553..9fc3f3971 100644 --- a/src/base/tools/bswap_64.h +++ b/src/base/tools/bswap_64.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2022 SChernykh + * Copyright (c) 2016-2022 XMRig , * * 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 @@ -19,21 +19,17 @@ #ifndef XMRIG_BSWAP_64_H #define XMRIG_BSWAP_64_H + #ifdef _MSC_VER - -#include -#define bswap_64(x) _byteswap_uint64(x) -#define bswap_32(x) _byteswap_ulong(x) - +# include +# define bswap_64(x) _byteswap_uint64(x) +# define bswap_32(x) _byteswap_ulong(x) #elif defined __GNUC__ - -#define bswap_64(x) __builtin_bswap64(x) -#define bswap_32(x) __builtin_bswap32(x) - +# define bswap_64(x) __builtin_bswap64(x) +# define bswap_32(x) __builtin_bswap32(x) #else - -#include - +# include #endif -#endif /* XMRIG_BSWAP_64_H */ + +#endif // XMRIG_BSWAP_64_H