This commit is contained in:
commit
ca0f93bb22
109 changed files with 4895 additions and 461 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,3 +1,13 @@
|
|||
# v5.10.0
|
||||
- [#1602](https://github.com/xmrig/xmrig/pull/1602) Added AMD GPUs support for AstroBWT algorithm.
|
||||
- [#1590](https://github.com/xmrig/xmrig/pull/1590) MSR mod automatically deactivated after switching from RandomX algorithms.
|
||||
- [#1592](https://github.com/xmrig/xmrig/pull/1592) Added AVX2 optimized code for AstroBWT algorithm.
|
||||
- Added new config option `astrobwt-avx2` in `cpu` object and command line option `--astrobwt-avx2`.
|
||||
- [#1596](https://github.com/xmrig/xmrig/issues/1596) Major TLS (Transport Layer Security) subsystem update.
|
||||
- Added new TLS options, please check [xmrig-proxy documentation](https://xmrig.com/docs/proxy/tls) for details.
|
||||
- `cn/gpu` algorithm now disabled by default and will be removed in next major (v6.x.x) release, no ETA for it right now.
|
||||
- Added command line option `--data-dir`.
|
||||
|
||||
# v5.9.0
|
||||
- [#1578](https://github.com/xmrig/xmrig/pull/1578) Added new RandomKEVA algorithm for upcoming Kevacoin fork, as `"algo": "rx/keva"` or `"coin": "keva"`.
|
||||
- [#1584](https://github.com/xmrig/xmrig/pull/1584) Fixed invalid AstroBWT hashes after algorithm switching.
|
||||
|
|
10
README.md
10
README.md
|
@ -68,6 +68,7 @@ CPU backend:
|
|||
--randomx-wrmsr=N write custom value (0-15) to Intel MSR register 0x1a4 or disable MSR mod (-1)
|
||||
--randomx-no-rdmsr disable reverting initial MSR values on exit
|
||||
--astrobwt-max-size=N skip hashes with large stage 2 size, default: 550, min: 400, max: 1200
|
||||
--astrobwt-avx2 enable AVX2 optimizations for AstroBWT algorithm
|
||||
|
||||
API:
|
||||
--api-worker-id=ID custom worker-id for API
|
||||
|
@ -93,6 +94,15 @@ CUDA backend:
|
|||
--cuda-bsleep-hint=N bsleep hint for autoconfig
|
||||
--no-nvml disable NVML (NVIDIA Management Library) support
|
||||
|
||||
TLS:
|
||||
--tls-gen=HOSTNAME generate TLS certificate for specific hostname
|
||||
--tls-cert=FILE load TLS certificate chain from a file in the PEM format
|
||||
--tls-cert-key=FILE load TLS certificate private key from a file in the PEM format
|
||||
--tls-dhparam=FILE load DH parameters for DHE ciphers from a file in the PEM format
|
||||
--tls-protocols=N enable specified TLS protocols, example: "TLSv1 TLSv1.1 TLSv1.2 TLSv1.3"
|
||||
--tls-ciphers=S set list of available ciphers (TLSv1.2 and below)
|
||||
--tls-ciphersuites=S set list of available TLSv1.3 ciphersuites
|
||||
|
||||
Logging:
|
||||
-S, --syslog use system log for output messages
|
||||
-l, --log-file=FILE log all output to a file
|
||||
|
|
|
@ -13,11 +13,30 @@ if (WITH_TLS)
|
|||
find_package(OpenSSL)
|
||||
|
||||
if (OPENSSL_FOUND)
|
||||
set(TLS_SOURCES src/base/net/stratum/Tls.h src/base/net/stratum/Tls.cpp)
|
||||
set(TLS_SOURCES
|
||||
src/base/net/stratum/Tls.cpp
|
||||
src/base/net/stratum/Tls.h
|
||||
src/base/net/tls/ServerTls.cpp
|
||||
src/base/net/tls/ServerTls.h
|
||||
src/base/net/tls/TlsConfig.cpp
|
||||
src/base/net/tls/TlsConfig.h
|
||||
src/base/net/tls/TlsContext.cpp
|
||||
src/base/net/tls/TlsContext.h
|
||||
src/base/net/tls/TlsGen.cpp
|
||||
src/base/net/tls/TlsGen.h
|
||||
)
|
||||
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
if (WITH_HTTP)
|
||||
set(TLS_SOURCES ${TLS_SOURCES} src/base/net/http/HttpsClient.h src/base/net/http/HttpsClient.cpp)
|
||||
set(TLS_SOURCES ${TLS_SOURCES}
|
||||
src/base/net/https/HttpsClient.cpp
|
||||
src/base/net/https/HttpsClient.h
|
||||
src/base/net/https/HttpsContext.cpp
|
||||
src/base/net/https/HttpsContext.h
|
||||
src/base/net/https/HttpsServer.cpp
|
||||
src/base/net/https/HttpsServer.h
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "OpenSSL NOT found: use `-DWITH_TLS=OFF` to build without TLS support")
|
||||
|
@ -29,5 +48,12 @@ else()
|
|||
set(OPENSSL_LIBRARIES "")
|
||||
remove_definitions(/DXMRIG_FEATURE_TLS)
|
||||
|
||||
if (WITH_HTTP)
|
||||
set(TLS_SOURCES ${TLS_SOURCES}
|
||||
src/base/net/http/HttpServer.cpp
|
||||
src/base/net/http/HttpServer.h
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_PROJECT_NAME "${CMAKE_PROJECT_NAME}-notls")
|
||||
endif()
|
||||
|
|
|
@ -23,6 +23,16 @@ if (WITH_ASTROBWT)
|
|||
src/crypto/astrobwt/salsa20_ref/salsa20.c
|
||||
)
|
||||
else()
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
enable_language(ASM_MASM)
|
||||
add_definitions(/DASTROBWT_AVX2)
|
||||
if (CMAKE_C_COMPILER_ID MATCHES MSVC)
|
||||
list(APPEND SOURCES_CRYPTO src/crypto/astrobwt/sha3_256_avx2.asm)
|
||||
else()
|
||||
list(APPEND SOURCES_CRYPTO src/crypto/astrobwt/sha3_256_avx2.S)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND HEADERS_CRYPTO
|
||||
src/crypto/astrobwt/Salsa20.hpp
|
||||
)
|
||||
|
|
|
@ -76,6 +76,15 @@ function rx()
|
|||
}
|
||||
|
||||
|
||||
function astrobwt()
|
||||
{
|
||||
const astrobwt = opencl_minify(addIncludes('astrobwt.cl', [ 'BWT.cl', 'salsa20.cl', 'sha3.cl' ]));
|
||||
|
||||
// fs.writeFileSync('astrobwt_gen.cl', astrobwt);
|
||||
fs.writeFileSync('astrobwt_cl.h', text2h(astrobwt, 'xmrig', 'astrobwt_cl'));
|
||||
}
|
||||
|
||||
|
||||
process.chdir(path.resolve('src/backend/opencl/cl/cn'));
|
||||
|
||||
cn();
|
||||
|
@ -85,4 +94,9 @@ cn_gpu();
|
|||
process.chdir(cwd);
|
||||
process.chdir(path.resolve('src/backend/opencl/cl/rx'));
|
||||
|
||||
rx();
|
||||
rx();
|
||||
|
||||
process.chdir(cwd);
|
||||
process.chdir(path.resolve('src/backend/opencl/cl/astrobwt'));
|
||||
|
||||
astrobwt();
|
||||
|
|
|
@ -52,6 +52,7 @@ static const char *kArgon2Impl = "argon2-impl";
|
|||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
static const char* kAstroBWTMaxSize = "astrobwt-max-size";
|
||||
static const char* kAstroBWTAVX2 = "astrobwt-avx2";
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -93,7 +94,8 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
|
|||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
obj.AddMember(StringRef(kAstroBWTMaxSize), m_astrobwtMaxSize, allocator);
|
||||
obj.AddMember(StringRef(kAstroBWTMaxSize), m_astrobwtMaxSize, allocator);
|
||||
obj.AddMember(StringRef(kAstroBWTAVX2), m_astrobwtAVX2, allocator);
|
||||
# endif
|
||||
|
||||
m_threads.toJSON(obj, doc);
|
||||
|
@ -148,12 +150,20 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
|||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
const auto& obj = Json::getValue(value, kAstroBWTMaxSize);
|
||||
if (obj.IsNull() || !obj.IsInt()) {
|
||||
const auto& astroBWTMaxSize = Json::getValue(value, kAstroBWTMaxSize);
|
||||
if (astroBWTMaxSize.IsNull() || !astroBWTMaxSize.IsInt()) {
|
||||
m_shouldSave = true;
|
||||
}
|
||||
else {
|
||||
m_astrobwtMaxSize = std::min(std::max(obj.GetInt(), 400), 1200);
|
||||
m_astrobwtMaxSize = std::min(std::max(astroBWTMaxSize.GetInt(), 400), 1200);
|
||||
}
|
||||
|
||||
const auto& astroBWTAVX2 = Json::getValue(value, kAstroBWTAVX2);
|
||||
if (astroBWTAVX2.IsNull() || !astroBWTAVX2.IsBool()) {
|
||||
m_shouldSave = true;
|
||||
}
|
||||
else {
|
||||
m_astrobwtAVX2 = astroBWTAVX2.GetBool();
|
||||
}
|
||||
# endif
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
inline const String &argon2Impl() const { return m_argon2Impl; }
|
||||
inline const Threads<CpuThreads> &threads() const { return m_threads; }
|
||||
inline int astrobwtMaxSize() const { return m_astrobwtMaxSize; }
|
||||
inline bool astrobwtAVX2() const { return m_astrobwtAVX2; }
|
||||
inline int priority() const { return m_priority; }
|
||||
inline uint32_t limit() const { return m_limit; }
|
||||
|
||||
|
@ -72,6 +73,7 @@ private:
|
|||
|
||||
AesMode m_aes = AES_AUTO;
|
||||
Assembly m_assembly;
|
||||
bool m_astrobwtAVX2 = false;
|
||||
bool m_enabled = true;
|
||||
bool m_hugePages = true;
|
||||
bool m_shouldSave = false;
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorithm, const CpuConfig &config, const CpuThread &thread) :
|
||||
algorithm(algorithm),
|
||||
assembly(config.assembly()),
|
||||
astrobwtAVX2(config.astrobwtAVX2()),
|
||||
hugePages(config.isHugePages()),
|
||||
hwAES(config.isHwAES()),
|
||||
yield(config.isYield()),
|
||||
astrobwtMaxSize(config.astrobwtMaxSize()),
|
||||
astrobwtMaxSize(config.astrobwtMaxSize()),
|
||||
priority(config.priority()),
|
||||
affinity(thread.affinity()),
|
||||
miner(miner),
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
const Algorithm algorithm;
|
||||
const Assembly assembly;
|
||||
const bool astrobwtAVX2;
|
||||
const bool hugePages;
|
||||
const bool hwAES;
|
||||
const bool yield;
|
||||
|
|
|
@ -78,6 +78,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
|||
Worker(id, data.affinity, data.priority),
|
||||
m_algorithm(data.algorithm),
|
||||
m_assembly(data.assembly),
|
||||
m_astrobwtAVX2(data.astrobwtAVX2),
|
||||
m_hwAES(data.hwAES),
|
||||
m_yield(data.yield),
|
||||
m_av(data.av()),
|
||||
|
@ -273,7 +274,7 @@ void xmrig::CpuWorker<N>::start()
|
|||
{
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (job.algorithm().family() == Algorithm::ASTROBWT) {
|
||||
if (!astrobwt::astrobwt_dero(m_job.blob(), job.size(), m_ctx[0]->memory, m_hash, m_astrobwtMaxSize))
|
||||
if (!astrobwt::astrobwt_dero(m_job.blob(), job.size(), m_ctx[0]->memory, m_hash, m_astrobwtMaxSize, m_astrobwtAVX2))
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -70,6 +70,7 @@ private:
|
|||
|
||||
const Algorithm m_algorithm;
|
||||
const Assembly m_assembly;
|
||||
const bool m_astrobwtAVX2;
|
||||
const bool m_hwAES;
|
||||
const bool m_yield;
|
||||
const CnHash::AlgoVariant m_av;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/OclWorker.h"
|
||||
#include "backend/opencl/runners/tools/OclSharedState.h"
|
||||
#include "backend/opencl/runners/OclAstroBWTRunner.h"
|
||||
#include "backend/opencl/wrappers/OclContext.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
|
@ -202,6 +203,14 @@ public:
|
|||
|
||||
Log::print(WHITE_BOLD("| # | GPU | BUS ID | I | W | SI | MC | U | MEM | NAME"));
|
||||
|
||||
size_t algo_l3 = algo.l3();
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (algo.family() == Algorithm::ASTROBWT) {
|
||||
algo_l3 = OclAstroBWTRunner::BWT_DATA_STRIDE * 17 + 324;
|
||||
}
|
||||
# endif
|
||||
|
||||
size_t i = 0;
|
||||
for (const auto &data : threads) {
|
||||
Log::print("|" CYAN_BOLD("%3zu") " |" CYAN_BOLD("%4u") " |" YELLOW(" %7s") " |" CYAN_BOLD("%5u") " |" CYAN_BOLD("%3u") " |"
|
||||
|
@ -214,7 +223,7 @@ public:
|
|||
data.thread.stridedIndex(),
|
||||
data.thread.stridedIndex() == 2 ? std::to_string(data.thread.memChunk()).c_str() : "-",
|
||||
data.thread.unrollFactor(),
|
||||
data.thread.intensity() * algo.l3() / oneMiB,
|
||||
data.thread.intensity() * algo_l3 / oneMiB,
|
||||
data.device.printableName().data()
|
||||
);
|
||||
|
||||
|
|
|
@ -220,6 +220,7 @@ void xmrig::OclConfig::generate()
|
|||
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, devices);
|
||||
|
||||
m_shouldSave = count > 0;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,15 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<OclThreads> &threads, const
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
template<>
|
||||
size_t inline generate<Algorithm::ASTROBWT>(Threads<OclThreads>& threads, const std::vector<OclDevice>& devices)
|
||||
{
|
||||
return generate("astrobwt", threads, Algorithm::ASTROBWT_DERO, devices);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static inline std::vector<OclDevice> filterDevices(const std::vector<OclDevice> &devices, const std::vector<uint32_t> &hints)
|
||||
{
|
||||
std::vector<OclDevice> out;
|
||||
|
|
|
@ -123,7 +123,9 @@ rapidjson::Value xmrig::OclThread::toJSON(rapidjson::Document &doc) const
|
|||
|
||||
out.AddMember(StringRef(kIndex), index(), allocator);
|
||||
out.AddMember(StringRef(kIntensity), intensity(), allocator);
|
||||
out.AddMember(StringRef(kWorksize), worksize(), allocator);
|
||||
if (!m_fields.test(ASTROBWT_FIELDS)) {
|
||||
out.AddMember(StringRef(kWorksize), worksize(), allocator);
|
||||
}
|
||||
|
||||
if (m_fields.test(STRIDED_INDEX_FIELD)) {
|
||||
Value si(kArrayType);
|
||||
|
@ -149,7 +151,7 @@ rapidjson::Value xmrig::OclThread::toJSON(rapidjson::Document &doc) const
|
|||
out.AddMember(StringRef(kDatasetHost), isDatasetHost(), allocator);
|
||||
# endif
|
||||
}
|
||||
else {
|
||||
else if (!m_fields.test(ASTROBWT_FIELDS)) {
|
||||
out.AddMember(StringRef(kUnroll), unrollFactor(), allocator);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,20 @@ public:
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
OclThread(uint32_t index, uint32_t intensity, uint32_t threads) :
|
||||
m_fields(4),
|
||||
m_threads(threads, -1),
|
||||
m_index(index),
|
||||
m_memChunk(0),
|
||||
m_stridedIndex(0),
|
||||
m_unrollFactor(1),
|
||||
m_worksize(1)
|
||||
{
|
||||
setIntensity(intensity);
|
||||
}
|
||||
# endif
|
||||
|
||||
OclThread(const rapidjson::Value &value);
|
||||
|
||||
inline bool isAsm() const { return m_gcnAsm; }
|
||||
|
@ -105,6 +119,7 @@ private:
|
|||
enum Fields {
|
||||
STRIDED_INDEX_FIELD,
|
||||
RANDOMX_FIELDS,
|
||||
ASTROBWT_FIELDS,
|
||||
FIELD_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
# include "backend/opencl/runners/OclRxVmRunner.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
# include "backend/opencl/runners/OclAstroBWTRunner.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
# include "backend/opencl/runners/OclRyoRunner.h"
|
||||
#endif
|
||||
|
@ -96,6 +100,12 @@ xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) :
|
|||
# endif
|
||||
break;
|
||||
|
||||
case Algorithm::ASTROBWT:
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
m_runner = new OclAstroBWTRunner(id, data);
|
||||
# endif
|
||||
break;
|
||||
|
||||
default:
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (m_algorithm == Algorithm::CN_GPU) {
|
||||
|
@ -148,6 +158,8 @@ void xmrig::OclWorker::start()
|
|||
{
|
||||
cl_uint results[0x100];
|
||||
|
||||
const uint32_t runnerRoundSize = m_runner->roundSize();
|
||||
|
||||
while (Nonce::sequence(Nonce::OPENCL) > 0) {
|
||||
if (!isReady()) {
|
||||
m_sharedData.setResumeCounter(0);
|
||||
|
@ -186,7 +198,7 @@ void xmrig::OclWorker::start()
|
|||
JobResults::submit(m_job.currentJob(), results, results[0xFF]);
|
||||
}
|
||||
|
||||
if (!m_job.nextRound(roundSize(m_intensity), m_intensity)) {
|
||||
if (!m_job.nextRound(roundSize(runnerRoundSize), runnerRoundSize)) {
|
||||
JobResults::done(m_job.currentJob());
|
||||
}
|
||||
|
||||
|
@ -228,7 +240,7 @@ void xmrig::OclWorker::storeStats(uint64_t t)
|
|||
return;
|
||||
}
|
||||
|
||||
m_count += m_intensity;
|
||||
m_count += m_runner->processedHashes();
|
||||
|
||||
m_sharedData.setRunTime(Chrono::steadyMSecs() - t);
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
# include "backend/opencl/cl/rx/randomx_cl.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
# include "backend/opencl/cl/astrobwt/astrobwt_cl.h"
|
||||
#endif
|
||||
|
||||
|
||||
const char *xmrig::OclSource::get(const Algorithm &algorithm)
|
||||
{
|
||||
|
@ -45,6 +49,12 @@ const char *xmrig::OclSource::get(const Algorithm &algorithm)
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (algorithm.family() == Algorithm::ASTROBWT) {
|
||||
return astrobwt_cl;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (algorithm == Algorithm::CN_GPU) {
|
||||
return cryptonight_gpu_cl;
|
||||
|
|
199
src/backend/opencl/cl/astrobwt/BWT.cl
Normal file
199
src/backend/opencl/cl/astrobwt/BWT.cl
Normal file
|
@ -0,0 +1,199 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define STAGE1_SIZE 147253
|
||||
|
||||
#define COUNTING_SORT_BITS 11
|
||||
#define COUNTING_SORT_SIZE (1 << COUNTING_SORT_BITS)
|
||||
#define FINAL_SORT_BATCH_SIZE COUNTING_SORT_SIZE
|
||||
#define FINAL_SORT_OVERLAP_SIZE 32
|
||||
|
||||
__attribute__((reqd_work_group_size(BWT_GROUP_SIZE, 1, 1)))
|
||||
__kernel void BWT(__global uint8_t* datas, __global uint32_t* data_sizes, uint32_t data_stride, __global uint64_t* indices, __global uint64_t* tmp_indices)
|
||||
{
|
||||
const uint32_t tid = get_local_id(0);
|
||||
const uint32_t gid = get_group_id(0);
|
||||
|
||||
__local int counters[COUNTING_SORT_SIZE][2];
|
||||
|
||||
for (uint32_t i = tid; i < COUNTING_SORT_SIZE * 2; i += BWT_GROUP_SIZE)
|
||||
((__local int*)counters)[i] = 0;
|
||||
|
||||
const uint64_t data_offset = (uint64_t)(gid) * data_stride;
|
||||
|
||||
__global uint8_t* input = datas + data_offset + 128;
|
||||
const uint32_t N = data_sizes[gid] + 1;
|
||||
|
||||
__global uint64_t* p = (__global uint64_t*)(input);
|
||||
volatile __local uint8_t* counters_atomic = (volatile __local uint8_t*)(counters);
|
||||
|
||||
indices += data_offset;
|
||||
tmp_indices += data_offset;
|
||||
|
||||
for (uint32_t i = tid; i < N; i += BWT_GROUP_SIZE)
|
||||
{
|
||||
const uint32_t index = i >> 3;
|
||||
const uint32_t bit_offset = (i & 7) << 3;
|
||||
|
||||
const uint64_t a = p[index];
|
||||
uint64_t b = p[index + 1];
|
||||
if (bit_offset == 0)
|
||||
b = 0;
|
||||
|
||||
uint64_t value = (a >> bit_offset) | (b << (64 - bit_offset));
|
||||
|
||||
uint2 tmp;
|
||||
const uchar4 mask = (uchar4)(3, 2, 1, 0);
|
||||
|
||||
tmp.x = as_uint(shuffle(as_uchar4(as_uint2(value).y), mask));
|
||||
tmp.y = as_uint(shuffle(as_uchar4(as_uint2(value).x), mask));
|
||||
|
||||
value = as_ulong(tmp);
|
||||
|
||||
indices[i] = (value & ((uint64_t)(-1) << 21)) | i;
|
||||
atomic_add((volatile __local int*)(counters_atomic + (((value >> (64 - COUNTING_SORT_BITS * 2)) & (COUNTING_SORT_SIZE - 1)) << 3)), 1);
|
||||
atomic_add((volatile __local int*)(counters_atomic + ((value >> (64 - COUNTING_SORT_BITS)) << 3) + 4), 1);
|
||||
}
|
||||
|
||||
if (tid == 0)
|
||||
{
|
||||
int t0 = counters[0][0];
|
||||
int t1 = counters[0][1];
|
||||
counters[0][0] = t0 - 1;
|
||||
counters[0][1] = t1 - 1;
|
||||
for (uint32_t i = 1; i < COUNTING_SORT_SIZE; ++i)
|
||||
{
|
||||
t0 += counters[i][0];
|
||||
t1 += counters[i][1];
|
||||
counters[i][0] = t0 - 1;
|
||||
counters[i][1] = t1 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = tid; i < N; i += BWT_GROUP_SIZE)
|
||||
{
|
||||
const uint64_t data = indices[i];
|
||||
const int k = atomic_sub((volatile __local int*)(counters_atomic + (((data >> (64 - COUNTING_SORT_BITS * 2)) & (COUNTING_SORT_SIZE - 1)) << 3)), 1);
|
||||
tmp_indices[k] = data;
|
||||
}
|
||||
|
||||
for (int i = N - 1 - tid; i >= 0; i -= BWT_GROUP_SIZE)
|
||||
{
|
||||
const uint64_t data = tmp_indices[i];
|
||||
const int k = atomic_sub((volatile __local int*)(counters_atomic + ((data >> (64 - COUNTING_SORT_BITS)) << 3) + 4), 1);
|
||||
indices[k] = data;
|
||||
}
|
||||
|
||||
__local uint64_t* buf = (__local uint64_t*)(counters);
|
||||
for (uint32_t i = 0; i < N; i += FINAL_SORT_BATCH_SIZE - FINAL_SORT_OVERLAP_SIZE)
|
||||
{
|
||||
const uint32_t len = (N - i < FINAL_SORT_BATCH_SIZE) ? (N - i) : FINAL_SORT_BATCH_SIZE;
|
||||
|
||||
for (uint32_t j = tid; j < len; j += BWT_GROUP_SIZE)
|
||||
buf[j] = indices[i + j];
|
||||
|
||||
if (tid == 0)
|
||||
{
|
||||
uint64_t prev_t = buf[0];
|
||||
for (int i = 1; i < len; ++i)
|
||||
{
|
||||
uint64_t t = buf[i];
|
||||
if (t < prev_t)
|
||||
{
|
||||
const uint64_t t2 = prev_t;
|
||||
int j = i - 1;
|
||||
do
|
||||
{
|
||||
buf[j + 1] = prev_t;
|
||||
--j;
|
||||
if (j < 0)
|
||||
break;
|
||||
prev_t = buf[j];
|
||||
} while (t < prev_t);
|
||||
buf[j + 1] = t;
|
||||
t = t2;
|
||||
}
|
||||
prev_t = t;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t j = tid; j < len; j += BWT_GROUP_SIZE)
|
||||
indices[i + j] = buf[j];
|
||||
}
|
||||
|
||||
--input;
|
||||
__global uint8_t* output = (__global uint8_t*)(tmp_indices);
|
||||
for (int i = tid; i <= N; i += BWT_GROUP_SIZE)
|
||||
output[i] = input[indices[i] & ((1 << 21) - 1)];
|
||||
}
|
||||
|
||||
__kernel void filter(uint32_t nonce, uint32_t bwt_max_size, __global const uint32_t* hashes, __global uint32_t* filtered_hashes)
|
||||
{
|
||||
const uint32_t global_id = get_global_id(0);
|
||||
|
||||
__global const uint32_t* hash = hashes + global_id * (32 / sizeof(uint32_t));
|
||||
const uint32_t stage2_size = STAGE1_SIZE + (*hash & 0xfffff);
|
||||
|
||||
if (stage2_size < bwt_max_size)
|
||||
{
|
||||
const int index = atomic_add((volatile __global int*)(filtered_hashes), 1) * (36 / sizeof(uint32_t)) + 1;
|
||||
|
||||
filtered_hashes[index] = nonce + global_id;
|
||||
|
||||
#pragma unroll(8)
|
||||
for (uint32_t i = 0; i < 8; ++i)
|
||||
filtered_hashes[index + i + 1] = hash[i];
|
||||
}
|
||||
}
|
||||
|
||||
__kernel void prepare_batch2(__global uint32_t* hashes, __global uint32_t* filtered_hashes, __global uint32_t* data_sizes)
|
||||
{
|
||||
const uint32_t global_id = get_global_id(0);
|
||||
const uint32_t N = filtered_hashes[0] - get_global_size(0);
|
||||
|
||||
if (global_id == 0)
|
||||
filtered_hashes[0] = N;
|
||||
|
||||
__global uint32_t* hash = hashes + global_id * 8;
|
||||
__global uint32_t* filtered_hash = filtered_hashes + (global_id + N) * 9 + 1;
|
||||
|
||||
const uint32_t stage2_size = STAGE1_SIZE + (filtered_hash[1] & 0xfffff);
|
||||
data_sizes[global_id] = stage2_size;
|
||||
|
||||
#pragma unroll(8)
|
||||
for (uint32_t i = 0; i < 8; ++i)
|
||||
hash[i] = filtered_hash[i + 1];
|
||||
}
|
||||
|
||||
__kernel void find_shares(__global const uint64_t* hashes, __global const uint32_t* filtered_hashes, uint64_t target, __global uint32_t* shares)
|
||||
{
|
||||
const uint32_t global_index = get_global_id(0);
|
||||
|
||||
if (hashes[global_index * 4 + 3] < target)
|
||||
{
|
||||
const uint32_t idx = atomic_inc(shares + 0xFF);
|
||||
if (idx < 0xFF)
|
||||
shares[idx] = filtered_hashes[(filtered_hashes[0] + global_index) * 9 + 1];
|
||||
}
|
||||
}
|
35
src/backend/opencl/cl/astrobwt/astrobwt.cl
Normal file
35
src/backend/opencl/cl/astrobwt/astrobwt.cl
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
typedef uchar uint8_t;
|
||||
typedef ushort uint16_t;
|
||||
typedef uint uint32_t;
|
||||
typedef ulong uint64_t;
|
||||
|
||||
typedef int int32_t;
|
||||
typedef long int64_t;
|
||||
|
||||
#include "BWT.cl"
|
||||
#include "salsa20.cl"
|
||||
#include "sha3.cl"
|
395
src/backend/opencl/cl/astrobwt/astrobwt_cl.h
Normal file
395
src/backend/opencl/cl/astrobwt/astrobwt_cl.h
Normal file
|
@ -0,0 +1,395 @@
|
|||
#pragma once
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static char astrobwt_cl[12378] = {
|
||||
0x74,0x79,0x70,0x65,0x64,0x65,0x66,0x20,0x75,0x63,0x68,0x61,0x72,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x3b,0x0a,0x74,0x79,0x70,0x65,0x64,0x65,0x66,0x20,0x75,
|
||||
0x73,0x68,0x6f,0x72,0x74,0x20,0x75,0x69,0x6e,0x74,0x31,0x36,0x5f,0x74,0x3b,0x0a,0x74,0x79,0x70,0x65,0x64,0x65,0x66,0x20,0x75,0x69,0x6e,0x74,0x20,0x75,0x69,0x6e,
|
||||
0x74,0x33,0x32,0x5f,0x74,0x3b,0x0a,0x74,0x79,0x70,0x65,0x64,0x65,0x66,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x3b,0x0a,0x74,
|
||||
0x79,0x70,0x65,0x64,0x65,0x66,0x20,0x69,0x6e,0x74,0x20,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x3b,0x0a,0x74,0x79,0x70,0x65,0x64,0x65,0x66,0x20,0x6c,0x6f,0x6e,0x67,
|
||||
0x20,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x3b,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x53,0x54,0x41,0x47,0x45,0x31,0x5f,0x53,0x49,0x5a,0x45,0x20,0x31,0x34,
|
||||
0x37,0x32,0x35,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x49,0x54,0x53,0x20,
|
||||
0x31,0x31,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x20,0x28,0x31,
|
||||
0x20,0x3c,0x3c,0x20,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x49,0x54,0x53,0x29,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,
|
||||
0x46,0x49,0x4e,0x41,0x4c,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x41,0x54,0x43,0x48,0x5f,0x53,0x49,0x5a,0x45,0x20,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,
|
||||
0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x46,0x49,0x4e,0x41,0x4c,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x4f,0x56,0x45,0x52,
|
||||
0x4c,0x41,0x50,0x5f,0x53,0x49,0x5a,0x45,0x20,0x33,0x32,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,
|
||||
0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x73,0x69,0x7a,0x65,0x28,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x2c,0x31,
|
||||
0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x42,0x57,0x54,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,
|
||||
0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x64,0x61,0x74,0x61,0x73,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,
|
||||
0x74,0x2a,0x20,0x64,0x61,0x74,0x61,0x5f,0x73,0x69,0x7a,0x65,0x73,0x2c,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x64,0x61,0x74,0x61,0x5f,0x73,0x74,0x72,0x69,
|
||||
0x64,0x65,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x2c,0x5f,0x5f,
|
||||
0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x74,0x6d,0x70,0x5f,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x29,0x0a,0x7b,0x0a,
|
||||
0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x74,0x69,0x64,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,
|
||||
0x30,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x69,0x64,0x3d,0x67,0x65,0x74,0x5f,0x67,0x72,0x6f,0x75,0x70,
|
||||
0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x20,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5b,0x43,0x4f,0x55,
|
||||
0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x5d,0x5b,0x32,0x5d,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,
|
||||
0x5f,0x74,0x20,0x69,0x3d,0x74,0x69,0x64,0x3b,0x20,0x69,0x3c,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x2a,0x32,
|
||||
0x3b,0x20,0x69,0x2b,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,
|
||||
0x6e,0x74,0x2a,0x29,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x29,0x5b,0x69,0x5d,0x3d,0x30,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,
|
||||
0x5f,0x74,0x20,0x64,0x61,0x74,0x61,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x3d,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x67,0x69,0x64,0x29,0x2a,0x64,
|
||||
0x61,0x74,0x61,0x5f,0x73,0x74,0x72,0x69,0x64,0x65,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x69,0x6e,
|
||||
0x70,0x75,0x74,0x3d,0x64,0x61,0x74,0x61,0x73,0x2b,0x64,0x61,0x74,0x61,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x2b,0x31,0x32,0x38,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,
|
||||
0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x4e,0x3d,0x64,0x61,0x74,0x61,0x5f,0x73,0x69,0x7a,0x65,0x73,0x5b,0x67,0x69,0x64,0x5d,0x2b,0x31,0x3b,0x0a,0x5f,
|
||||
0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x70,0x3d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,
|
||||
0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x29,0x28,0x69,0x6e,0x70,0x75,0x74,0x29,0x3b,0x0a,0x76,0x6f,0x6c,0x61,0x74,0x69,0x6c,0x65,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,
|
||||
0x6c,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5f,0x61,0x74,0x6f,0x6d,0x69,0x63,0x3d,0x28,0x76,0x6f,0x6c,0x61,
|
||||
0x74,0x69,0x6c,0x65,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x29,0x28,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x29,
|
||||
0x3b,0x0a,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x2b,0x3d,0x64,0x61,0x74,0x61,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x3b,0x0a,0x74,0x6d,0x70,0x5f,0x69,0x6e,0x64,0x69,
|
||||
0x63,0x65,0x73,0x2b,0x3d,0x64,0x61,0x74,0x61,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,
|
||||
0x69,0x3d,0x74,0x69,0x64,0x3b,0x20,0x69,0x3c,0x4e,0x3b,0x20,0x69,0x2b,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x7b,
|
||||
0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x6e,0x64,0x65,0x78,0x3d,0x69,0x3e,0x3e,0x33,0x3b,0x0a,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x62,0x69,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x3d,0x28,0x69,0x26,0x37,0x29,0x3c,0x3c,0x33,0x3b,0x0a,
|
||||
0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x61,0x3d,0x70,0x5b,0x69,0x6e,0x64,0x65,0x78,0x5d,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x36,
|
||||
0x34,0x5f,0x74,0x20,0x62,0x3d,0x70,0x5b,0x69,0x6e,0x64,0x65,0x78,0x2b,0x31,0x5d,0x3b,0x0a,0x69,0x66,0x28,0x62,0x69,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x3d,
|
||||
0x3d,0x30,0x29,0x0a,0x62,0x3d,0x30,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x76,0x61,0x6c,0x75,0x65,0x3d,0x28,0x61,0x3e,0x3e,0x62,0x69,0x74,0x5f,
|
||||
0x6f,0x66,0x66,0x73,0x65,0x74,0x29,0x7c,0x28,0x62,0x3c,0x3c,0x28,0x36,0x34,0x2d,0x62,0x69,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x29,0x29,0x3b,0x0a,0x75,0x69,
|
||||
0x6e,0x74,0x32,0x20,0x74,0x6d,0x70,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x63,0x68,0x61,0x72,0x34,0x20,0x6d,0x61,0x73,0x6b,0x3d,0x28,0x75,0x63,0x68,0x61,
|
||||
0x72,0x34,0x29,0x28,0x33,0x2c,0x32,0x2c,0x31,0x2c,0x30,0x29,0x3b,0x0a,0x74,0x6d,0x70,0x2e,0x78,0x3d,0x61,0x73,0x5f,0x75,0x69,0x6e,0x74,0x28,0x73,0x68,0x75,0x66,
|
||||
0x66,0x6c,0x65,0x28,0x61,0x73,0x5f,0x75,0x63,0x68,0x61,0x72,0x34,0x28,0x61,0x73,0x5f,0x75,0x69,0x6e,0x74,0x32,0x28,0x76,0x61,0x6c,0x75,0x65,0x29,0x2e,0x79,0x29,
|
||||
0x2c,0x6d,0x61,0x73,0x6b,0x29,0x29,0x3b,0x0a,0x74,0x6d,0x70,0x2e,0x79,0x3d,0x61,0x73,0x5f,0x75,0x69,0x6e,0x74,0x28,0x73,0x68,0x75,0x66,0x66,0x6c,0x65,0x28,0x61,
|
||||
0x73,0x5f,0x75,0x63,0x68,0x61,0x72,0x34,0x28,0x61,0x73,0x5f,0x75,0x69,0x6e,0x74,0x32,0x28,0x76,0x61,0x6c,0x75,0x65,0x29,0x2e,0x78,0x29,0x2c,0x6d,0x61,0x73,0x6b,
|
||||
0x29,0x29,0x3b,0x0a,0x76,0x61,0x6c,0x75,0x65,0x3d,0x61,0x73,0x5f,0x75,0x6c,0x6f,0x6e,0x67,0x28,0x74,0x6d,0x70,0x29,0x3b,0x0a,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,
|
||||
0x5b,0x69,0x5d,0x3d,0x28,0x76,0x61,0x6c,0x75,0x65,0x26,0x28,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x2d,0x31,0x29,0x3c,0x3c,0x32,0x31,0x29,0x29,
|
||||
0x7c,0x69,0x3b,0x0a,0x61,0x74,0x6f,0x6d,0x69,0x63,0x5f,0x61,0x64,0x64,0x28,0x28,0x76,0x6f,0x6c,0x61,0x74,0x69,0x6c,0x65,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,
|
||||
0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5f,0x61,0x74,0x6f,0x6d,0x69,0x63,0x2b,0x28,0x28,0x28,0x76,0x61,0x6c,0x75,0x65,0x3e,
|
||||
0x3e,0x28,0x36,0x34,0x2d,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x49,0x54,0x53,0x2a,0x32,0x29,0x29,0x26,0x28,0x43,0x4f,0x55,
|
||||
0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x2d,0x31,0x29,0x29,0x3c,0x3c,0x33,0x29,0x29,0x2c,0x31,0x29,0x3b,0x0a,0x61,0x74,0x6f,
|
||||
0x6d,0x69,0x63,0x5f,0x61,0x64,0x64,0x28,0x28,0x76,0x6f,0x6c,0x61,0x74,0x69,0x6c,0x65,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,
|
||||
0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5f,0x61,0x74,0x6f,0x6d,0x69,0x63,0x2b,0x28,0x28,0x76,0x61,0x6c,0x75,0x65,0x3e,0x3e,0x28,0x36,0x34,0x2d,0x43,0x4f,0x55,
|
||||
0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x49,0x54,0x53,0x29,0x29,0x3c,0x3c,0x33,0x29,0x2b,0x34,0x29,0x2c,0x31,0x29,0x3b,0x0a,0x7d,0x0a,0x69,
|
||||
0x66,0x28,0x74,0x69,0x64,0x3d,0x3d,0x30,0x29,0x0a,0x7b,0x0a,0x69,0x6e,0x74,0x20,0x74,0x30,0x3d,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5b,0x30,0x5d,0x5b,0x30,
|
||||
0x5d,0x3b,0x0a,0x69,0x6e,0x74,0x20,0x74,0x31,0x3d,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5b,0x30,0x5d,0x5b,0x31,0x5d,0x3b,0x0a,0x63,0x6f,0x75,0x6e,0x74,0x65,
|
||||
0x72,0x73,0x5b,0x30,0x5d,0x5b,0x30,0x5d,0x3d,0x74,0x30,0x2d,0x31,0x3b,0x0a,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5b,0x30,0x5d,0x5b,0x31,0x5d,0x3d,0x74,0x31,
|
||||
0x2d,0x31,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x31,0x3b,0x20,0x69,0x3c,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,
|
||||
0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x0a,0x7b,0x0a,0x74,0x30,0x2b,0x3d,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,
|
||||
0x5b,0x69,0x5d,0x5b,0x30,0x5d,0x3b,0x0a,0x74,0x31,0x2b,0x3d,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5b,0x69,0x5d,0x5b,0x31,0x5d,0x3b,0x0a,0x63,0x6f,0x75,0x6e,
|
||||
0x74,0x65,0x72,0x73,0x5b,0x69,0x5d,0x5b,0x30,0x5d,0x3d,0x74,0x30,0x2d,0x31,0x3b,0x0a,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5b,0x69,0x5d,0x5b,0x31,0x5d,0x3d,
|
||||
0x74,0x31,0x2d,0x31,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x74,0x69,0x64,0x3b,0x20,0x69,0x3c,0x4e,0x3b,0x20,0x69,
|
||||
0x2b,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,
|
||||
0x5f,0x74,0x20,0x64,0x61,0x74,0x61,0x3d,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x5b,0x69,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x6b,0x3d,
|
||||
0x61,0x74,0x6f,0x6d,0x69,0x63,0x5f,0x73,0x75,0x62,0x28,0x28,0x76,0x6f,0x6c,0x61,0x74,0x69,0x6c,0x65,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,
|
||||
0x2a,0x29,0x28,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5f,0x61,0x74,0x6f,0x6d,0x69,0x63,0x2b,0x28,0x28,0x28,0x64,0x61,0x74,0x61,0x3e,0x3e,0x28,0x36,0x34,0x2d,
|
||||
0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x49,0x54,0x53,0x2a,0x32,0x29,0x29,0x26,0x28,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,
|
||||
0x5f,0x53,0x4f,0x52,0x54,0x5f,0x53,0x49,0x5a,0x45,0x2d,0x31,0x29,0x29,0x3c,0x3c,0x33,0x29,0x29,0x2c,0x31,0x29,0x3b,0x0a,0x74,0x6d,0x70,0x5f,0x69,0x6e,0x64,0x69,
|
||||
0x63,0x65,0x73,0x5b,0x6b,0x5d,0x3d,0x64,0x61,0x74,0x61,0x3b,0x0a,0x7d,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x4e,0x2d,0x31,0x2d,0x74,0x69,
|
||||
0x64,0x3b,0x20,0x69,0x3e,0x3d,0x30,0x3b,0x20,0x69,0x2d,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x7b,0x0a,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x64,0x61,0x74,0x61,0x3d,0x74,0x6d,0x70,0x5f,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x5b,0x69,0x5d,
|
||||
0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x6b,0x3d,0x61,0x74,0x6f,0x6d,0x69,0x63,0x5f,0x73,0x75,0x62,0x28,0x28,0x76,0x6f,0x6c,0x61,0x74,0x69,
|
||||
0x6c,0x65,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x5f,0x61,0x74,0x6f,0x6d,0x69,0x63,
|
||||
0x2b,0x28,0x28,0x64,0x61,0x74,0x61,0x3e,0x3e,0x28,0x36,0x34,0x2d,0x43,0x4f,0x55,0x4e,0x54,0x49,0x4e,0x47,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x49,0x54,0x53,0x29,
|
||||
0x29,0x3c,0x3c,0x33,0x29,0x2b,0x34,0x29,0x2c,0x31,0x29,0x3b,0x0a,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x5b,0x6b,0x5d,0x3d,0x64,0x61,0x74,0x61,0x3b,0x0a,0x7d,0x0a,
|
||||
0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x62,0x75,0x66,0x3d,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x29,0x28,0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x73,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,
|
||||
0x5f,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x4e,0x3b,0x20,0x69,0x2b,0x3d,0x46,0x49,0x4e,0x41,0x4c,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x42,0x41,0x54,0x43,0x48,
|
||||
0x5f,0x53,0x49,0x5a,0x45,0x2d,0x46,0x49,0x4e,0x41,0x4c,0x5f,0x53,0x4f,0x52,0x54,0x5f,0x4f,0x56,0x45,0x52,0x4c,0x41,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x7b,
|
||||
0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6c,0x65,0x6e,0x3d,0x28,0x4e,0x2d,0x69,0x3c,0x46,0x49,0x4e,0x41,0x4c,0x5f,0x53,
|
||||
0x4f,0x52,0x54,0x5f,0x42,0x41,0x54,0x43,0x48,0x5f,0x53,0x49,0x5a,0x45,0x29,0x3f,0x28,0x4e,0x2d,0x69,0x29,0x3a,0x46,0x49,0x4e,0x41,0x4c,0x5f,0x53,0x4f,0x52,0x54,
|
||||
0x5f,0x42,0x41,0x54,0x43,0x48,0x5f,0x53,0x49,0x5a,0x45,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x3d,0x74,0x69,0x64,
|
||||
0x3b,0x20,0x6a,0x3c,0x6c,0x65,0x6e,0x3b,0x20,0x6a,0x2b,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x62,0x75,0x66,0x5b,
|
||||
0x6a,0x5d,0x3d,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x5b,0x69,0x2b,0x6a,0x5d,0x3b,0x0a,0x69,0x66,0x28,0x74,0x69,0x64,0x3d,0x3d,0x30,0x29,0x0a,0x7b,0x0a,0x75,0x69,
|
||||
0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x70,0x72,0x65,0x76,0x5f,0x74,0x3d,0x62,0x75,0x66,0x5b,0x30,0x5d,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,
|
||||
0x3d,0x31,0x3b,0x20,0x69,0x3c,0x6c,0x65,0x6e,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x0a,0x7b,0x0a,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x74,0x3d,0x62,0x75,0x66,
|
||||
0x5b,0x69,0x5d,0x3b,0x0a,0x69,0x66,0x28,0x74,0x3c,0x70,0x72,0x65,0x76,0x5f,0x74,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,
|
||||
0x5f,0x74,0x20,0x74,0x32,0x3d,0x70,0x72,0x65,0x76,0x5f,0x74,0x3b,0x0a,0x69,0x6e,0x74,0x20,0x6a,0x3d,0x69,0x2d,0x31,0x3b,0x0a,0x64,0x6f,0x0a,0x7b,0x0a,0x62,0x75,
|
||||
0x66,0x5b,0x6a,0x2b,0x31,0x5d,0x3d,0x70,0x72,0x65,0x76,0x5f,0x74,0x3b,0x0a,0x2d,0x2d,0x6a,0x3b,0x0a,0x69,0x66,0x28,0x6a,0x3c,0x30,0x29,0x0a,0x62,0x72,0x65,0x61,
|
||||
0x6b,0x3b,0x0a,0x70,0x72,0x65,0x76,0x5f,0x74,0x3d,0x62,0x75,0x66,0x5b,0x6a,0x5d,0x3b,0x0a,0x7d,0x20,0x77,0x68,0x69,0x6c,0x65,0x20,0x28,0x74,0x3c,0x70,0x72,0x65,
|
||||
0x76,0x5f,0x74,0x29,0x3b,0x0a,0x62,0x75,0x66,0x5b,0x6a,0x2b,0x31,0x5d,0x3d,0x74,0x3b,0x0a,0x74,0x3d,0x74,0x32,0x3b,0x0a,0x7d,0x0a,0x70,0x72,0x65,0x76,0x5f,0x74,
|
||||
0x3d,0x74,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x3d,0x74,0x69,0x64,0x3b,0x20,0x6a,0x3c,0x6c,
|
||||
0x65,0x6e,0x3b,0x20,0x6a,0x2b,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x5b,0x69,
|
||||
0x2b,0x6a,0x5d,0x3d,0x62,0x75,0x66,0x5b,0x6a,0x5d,0x3b,0x0a,0x7d,0x0a,0x2d,0x2d,0x69,0x6e,0x70,0x75,0x74,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,
|
||||
0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x3d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,
|
||||
0x74,0x2a,0x29,0x28,0x74,0x6d,0x70,0x5f,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x74,0x69,0x64,
|
||||
0x3b,0x20,0x69,0x3c,0x3d,0x4e,0x3b,0x20,0x69,0x2b,0x3d,0x42,0x57,0x54,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x6f,0x75,0x74,0x70,0x75,
|
||||
0x74,0x5b,0x69,0x5d,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5b,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x5b,0x69,0x5d,0x26,0x28,0x28,0x31,0x3c,0x3c,0x32,0x31,0x29,0x2d,0x31,
|
||||
0x29,0x5d,0x3b,0x0a,0x7d,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x66,0x69,0x6c,0x74,0x65,0x72,0x28,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x6e,0x6f,0x6e,0x63,0x65,0x2c,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x62,0x77,0x74,0x5f,0x6d,0x61,0x78,0x5f,0x73,0x69,0x7a,0x65,0x2c,
|
||||
0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x68,0x61,0x73,0x68,0x65,0x73,0x2c,
|
||||
0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,
|
||||
0x65,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x3d,0x67,
|
||||
0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,
|
||||
0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x68,0x61,0x73,0x68,0x3d,0x68,0x61,0x73,0x68,0x65,0x73,0x2b,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x2a,
|
||||
0x28,0x33,0x32,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,
|
||||
0x74,0x33,0x32,0x5f,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x32,0x5f,0x73,0x69,0x7a,0x65,0x3d,0x53,0x54,0x41,0x47,0x45,0x31,0x5f,0x53,0x49,0x5a,0x45,0x2b,0x28,0x2a,
|
||||
0x68,0x61,0x73,0x68,0x26,0x30,0x78,0x66,0x66,0x66,0x66,0x66,0x29,0x3b,0x0a,0x69,0x66,0x28,0x73,0x74,0x61,0x67,0x65,0x32,0x5f,0x73,0x69,0x7a,0x65,0x3c,0x62,0x77,
|
||||
0x74,0x5f,0x6d,0x61,0x78,0x5f,0x73,0x69,0x7a,0x65,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x69,0x6e,0x64,0x65,0x78,0x3d,0x61,0x74,
|
||||
0x6f,0x6d,0x69,0x63,0x5f,0x61,0x64,0x64,0x28,0x28,0x76,0x6f,0x6c,0x61,0x74,0x69,0x6c,0x65,0x20,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,
|
||||
0x29,0x28,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x29,0x2c,0x31,0x29,0x2a,0x28,0x33,0x36,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,
|
||||
0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x29,0x2b,0x31,0x3b,0x0a,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x69,
|
||||
0x6e,0x64,0x65,0x78,0x5d,0x3d,0x6e,0x6f,0x6e,0x63,0x65,0x2b,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,
|
||||
0x6e,0x72,0x6f,0x6c,0x6c,0x28,0x38,0x29,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x38,0x3b,
|
||||
0x20,0x2b,0x2b,0x69,0x29,0x0a,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x69,0x6e,0x64,0x65,0x78,0x2b,0x69,0x2b,0x31,0x5d,
|
||||
0x3d,0x68,0x61,0x73,0x68,0x5b,0x69,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x70,0x72,0x65,0x70,
|
||||
0x61,0x72,0x65,0x5f,0x62,0x61,0x74,0x63,0x68,0x32,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x68,0x61,
|
||||
0x73,0x68,0x65,0x73,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,
|
||||
0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x64,0x61,0x74,0x61,0x5f,
|
||||
0x73,0x69,0x7a,0x65,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,
|
||||
0x64,0x3d,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,
|
||||
0x5f,0x74,0x20,0x4e,0x3d,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x30,0x5d,0x2d,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,
|
||||
0x61,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x28,0x30,0x29,0x3b,0x0a,0x69,0x66,0x28,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x3d,0x3d,0x30,0x29,0x0a,0x66,0x69,0x6c,
|
||||
0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x30,0x5d,0x3d,0x4e,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,
|
||||
0x33,0x32,0x5f,0x74,0x2a,0x20,0x68,0x61,0x73,0x68,0x3d,0x68,0x61,0x73,0x68,0x65,0x73,0x2b,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x2a,0x38,0x3b,0x0a,0x5f,
|
||||
0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x3d,
|
||||
0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x2b,0x28,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x2b,0x4e,0x29,0x2a,0x39,0x2b,
|
||||
0x31,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x32,0x5f,0x73,0x69,0x7a,0x65,0x3d,0x53,0x54,
|
||||
0x41,0x47,0x45,0x31,0x5f,0x53,0x49,0x5a,0x45,0x2b,0x28,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x5b,0x31,0x5d,0x26,0x30,0x78,0x66,0x66,
|
||||
0x66,0x66,0x66,0x29,0x3b,0x0a,0x64,0x61,0x74,0x61,0x5f,0x73,0x69,0x7a,0x65,0x73,0x5b,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x5d,0x3d,0x73,0x74,0x61,0x67,
|
||||
0x65,0x32,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x28,0x38,0x29,0x0a,0x66,0x6f,0x72,0x20,0x28,
|
||||
0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x38,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x0a,0x68,0x61,0x73,0x68,0x5b,0x69,0x5d,0x3d,
|
||||
0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x5b,0x69,0x2b,0x31,0x5d,0x3b,0x0a,0x7d,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x66,0x69,0x6e,0x64,0x5f,0x73,0x68,0x61,0x72,0x65,0x73,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x68,0x61,0x73,0x68,0x65,0x73,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x2c,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,
|
||||
0x74,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x73,0x68,0x61,0x72,
|
||||
0x65,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x6e,0x64,0x65,
|
||||
0x78,0x3d,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x69,0x66,0x28,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x67,0x6c,
|
||||
0x6f,0x62,0x61,0x6c,0x5f,0x69,0x6e,0x64,0x65,0x78,0x2a,0x34,0x2b,0x33,0x5d,0x3c,0x74,0x61,0x72,0x67,0x65,0x74,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,
|
||||
0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x64,0x78,0x3d,0x61,0x74,0x6f,0x6d,0x69,0x63,0x5f,0x69,0x6e,0x63,0x28,0x73,0x68,0x61,0x72,0x65,0x73,0x2b,0x30,
|
||||
0x78,0x46,0x46,0x29,0x3b,0x0a,0x69,0x66,0x28,0x69,0x64,0x78,0x3c,0x30,0x78,0x46,0x46,0x29,0x0a,0x73,0x68,0x61,0x72,0x65,0x73,0x5b,0x69,0x64,0x78,0x5d,0x3d,0x66,
|
||||
0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x28,0x66,0x69,0x6c,0x74,0x65,0x72,0x65,0x64,0x5f,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,
|
||||
0x30,0x5d,0x2b,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x6e,0x64,0x65,0x78,0x29,0x2a,0x39,0x2b,0x31,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x23,0x64,0x65,0x66,0x69,
|
||||
0x6e,0x65,0x20,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x76,0x2c,0x63,0x29,0x20,0x28,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x76,0x2c,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,
|
||||
0x5f,0x74,0x29,0x63,0x29,0x29,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x58,0x4f,0x52,0x28,0x76,0x2c,0x77,0x29,0x20,0x28,0x28,0x76,0x29,0x20,0x5e,0x20,0x28,
|
||||
0x77,0x29,0x29,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x50,0x4c,0x55,0x53,0x28,0x76,0x2c,0x77,0x29,0x20,0x28,0x28,0x76,0x29,0x20,0x2b,0x20,0x28,0x77,0x29,
|
||||
0x29,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,
|
||||
0x5f,0x73,0x69,0x7a,0x65,0x28,0x53,0x41,0x4c,0x53,0x41,0x32,0x30,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x2c,0x31,0x2c,0x31,0x29,0x29,0x29,0x0a,
|
||||
0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x53,0x61,0x6c,0x73,0x61,0x32,0x30,0x5f,0x58,0x4f,0x52,0x4b,0x65,0x79,0x53,0x74,0x72,0x65,
|
||||
0x61,0x6d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x6b,0x65,0x79,0x73,
|
||||
0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x73,0x2c,0x5f,0x5f,0x67,0x6c,
|
||||
0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x73,0x2c,0x75,0x69,0x6e,0x74,
|
||||
0x33,0x32,0x5f,0x74,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x74,0x72,0x69,0x64,0x65,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,
|
||||
0x33,0x32,0x5f,0x74,0x20,0x74,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,
|
||||
0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x3d,0x67,0x65,0x74,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,
|
||||
0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x3d,0x67,0x2a,0x28,0x28,0x75,0x69,0x6e,0x74,0x36,
|
||||
0x34,0x5f,0x74,0x29,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x74,0x72,0x69,0x64,0x65,0x29,0x2b,0x31,0x32,0x38,0x3b,0x0a,0x7b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,
|
||||
0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x70,0x3d,0x6f,0x75,0x74,0x70,0x75,0x74,0x73,0x2b,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x6f,
|
||||
0x66,0x66,0x73,0x65,0x74,0x2d,0x31,0x32,0x38,0x29,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x3b,0x0a,0x66,0x6f,0x72,
|
||||
0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x74,0x3b,0x20,0x69,0x3c,0x31,0x32,0x38,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,
|
||||
0x74,0x33,0x32,0x5f,0x74,0x29,0x3b,0x20,0x69,0x2b,0x3d,0x53,0x41,0x4c,0x53,0x41,0x32,0x30,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x29,0x0a,0x70,
|
||||
0x5b,0x69,0x5d,0x3d,0x30,0x3b,0x0a,0x7d,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,
|
||||
0x2a,0x20,0x6b,0x3d,0x6b,0x65,0x79,0x73,0x2b,0x67,0x2a,0x38,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,
|
||||
0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x3d,0x6f,0x75,0x74,0x70,0x75,0x74,0x73,0x2b,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x2b,0x28,
|
||||
0x74,0x2a,0x36,0x34,0x29,0x29,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x3d,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x73,
|
||||
0x5b,0x67,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x31,0x3d,0x6b,0x5b,0x30,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,
|
||||
0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x32,0x3d,0x6b,0x5b,0x31,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x6a,0x33,0x3d,0x6b,0x5b,0x32,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x34,0x3d,0x6b,
|
||||
0x5b,0x33,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x31,0x31,0x3d,0x6b,0x5b,0x34,0x5d,0x3b,0x0a,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x31,0x32,0x3d,0x6b,0x5b,0x35,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,
|
||||
0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x31,0x33,0x3d,0x6b,0x5b,0x36,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,
|
||||
0x31,0x34,0x3d,0x6b,0x5b,0x37,0x5d,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x30,0x3d,0x30,0x78,0x36,0x31,0x37,
|
||||
0x30,0x37,0x38,0x36,0x35,0x55,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x35,0x3d,0x30,0x78,0x33,0x33,0x32,0x30,
|
||||
0x36,0x34,0x36,0x45,0x55,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x31,0x30,0x3d,0x30,0x78,0x37,0x39,0x36,0x32,
|
||||
0x32,0x44,0x33,0x32,0x55,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x31,0x35,0x3d,0x30,0x78,0x36,0x42,0x32,0x30,
|
||||
0x36,0x35,0x37,0x34,0x55,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x36,0x3d,0x30,0x3b,0x0a,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x37,0x3d,0x30,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,
|
||||
0x6a,0x38,0x3d,0x30,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x39,0x3d,0x30,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,
|
||||
0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x74,0x2a,0x36,0x34,0x3b,0x20,0x69,0x3c,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,
|
||||
0x69,0x2b,0x3d,0x53,0x41,0x4c,0x53,0x41,0x32,0x30,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,0x53,0x49,0x5a,0x45,0x2a,0x36,0x34,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x38,0x5f,0x31,0x3d,0x6a,0x38,0x2b,0x28,0x69,0x2f,0x36,0x34,0x29,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x78,0x30,0x3d,0x6a,0x30,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x31,0x3d,0x6a,0x31,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x78,0x32,0x3d,0x6a,0x32,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x33,0x3d,0x6a,0x33,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x78,0x34,0x3d,0x6a,0x34,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x35,0x3d,0x6a,0x35,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x78,0x36,0x3d,0x6a,0x36,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x37,0x3d,0x6a,0x37,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,
|
||||
0x32,0x5f,0x74,0x20,0x78,0x38,0x3d,0x6a,0x38,0x5f,0x31,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x39,0x3d,0x6a,0x39,0x3b,0x0a,0x75,0x69,0x6e,
|
||||
0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x31,0x30,0x3d,0x6a,0x31,0x30,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x31,0x31,0x3d,0x6a,0x31,0x31,0x3b,
|
||||
0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x31,0x32,0x3d,0x6a,0x31,0x32,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x31,0x33,0x3d,
|
||||
0x6a,0x31,0x33,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x78,0x31,0x34,0x3d,0x6a,0x31,0x34,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,
|
||||
0x78,0x31,0x35,0x3d,0x6a,0x31,0x35,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x28,0x35,0x29,0x0a,0x66,0x6f,0x72,0x20,0x28,
|
||||
0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6a,0x3d,0x30,0x3b,0x20,0x6a,0x3c,0x31,0x30,0x3b,0x20,0x2b,0x2b,0x6a,0x29,0x0a,0x7b,0x0a,0x78,0x34,0x3d,0x58,0x4f,
|
||||
0x52,0x28,0x20,0x78,0x34,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x30,0x2c,0x78,0x31,0x32,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,
|
||||
0x78,0x38,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x38,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x34,0x2c,0x78,0x30,0x29,0x2c,0x39,
|
||||
0x29,0x29,0x3b,0x0a,0x78,0x31,0x32,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x32,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x38,0x2c,
|
||||
0x78,0x34,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x30,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x30,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,
|
||||
0x28,0x78,0x31,0x32,0x2c,0x78,0x38,0x29,0x2c,0x31,0x38,0x29,0x29,0x3b,0x0a,0x78,0x39,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x39,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,
|
||||
0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x35,0x2c,0x78,0x31,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,0x78,0x31,0x33,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x33,0x2c,0x52,
|
||||
0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x39,0x2c,0x78,0x35,0x29,0x2c,0x39,0x29,0x29,0x3b,0x0a,0x78,0x31,0x3d,0x58,0x4f,0x52,0x28,0x20,
|
||||
0x78,0x31,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x33,0x2c,0x78,0x39,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x35,0x3d,
|
||||
0x58,0x4f,0x52,0x28,0x20,0x78,0x35,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x31,0x2c,0x78,0x31,0x33,0x29,0x2c,0x31,0x38,0x29,
|
||||
0x29,0x3b,0x0a,0x78,0x31,0x34,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x34,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x30,0x2c,0x78,
|
||||
0x36,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,0x78,0x32,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x32,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,
|
||||
0x31,0x34,0x2c,0x78,0x31,0x30,0x29,0x2c,0x39,0x29,0x29,0x3b,0x0a,0x78,0x36,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x36,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,
|
||||
0x4c,0x55,0x53,0x28,0x20,0x78,0x32,0x2c,0x78,0x31,0x34,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x31,0x30,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x30,0x2c,0x52,
|
||||
0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x36,0x2c,0x78,0x32,0x29,0x2c,0x31,0x38,0x29,0x29,0x3b,0x0a,0x78,0x33,0x3d,0x58,0x4f,0x52,0x28,
|
||||
0x20,0x78,0x33,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x35,0x2c,0x78,0x31,0x31,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,0x78,0x37,
|
||||
0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x37,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x33,0x2c,0x78,0x31,0x35,0x29,0x2c,0x39,0x29,
|
||||
0x29,0x3b,0x0a,0x78,0x31,0x31,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x31,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x37,0x2c,0x78,
|
||||
0x33,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x31,0x35,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x35,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,
|
||||
0x28,0x78,0x31,0x31,0x2c,0x78,0x37,0x29,0x2c,0x31,0x38,0x29,0x29,0x3b,0x0a,0x78,0x31,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x31,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,
|
||||
0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x30,0x2c,0x78,0x33,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,0x78,0x32,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x32,0x2c,0x52,0x4f,
|
||||
0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x31,0x2c,0x78,0x30,0x29,0x2c,0x39,0x29,0x29,0x3b,0x0a,0x78,0x33,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,
|
||||
0x33,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x32,0x2c,0x78,0x31,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x30,0x3d,0x58,
|
||||
0x4f,0x52,0x28,0x20,0x78,0x30,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x33,0x2c,0x78,0x32,0x29,0x2c,0x31,0x38,0x29,0x29,0x3b,
|
||||
0x0a,0x78,0x36,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x36,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x35,0x2c,0x78,0x34,0x29,0x2c,
|
||||
0x37,0x29,0x29,0x3b,0x0a,0x78,0x37,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x37,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x36,0x2c,
|
||||
0x78,0x35,0x29,0x2c,0x39,0x29,0x29,0x3b,0x0a,0x78,0x34,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x34,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,
|
||||
0x20,0x78,0x37,0x2c,0x78,0x36,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x35,0x3d,0x58,0x4f,0x52,0x28,0x20,0x78,0x35,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,
|
||||
0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x34,0x2c,0x78,0x37,0x29,0x2c,0x31,0x38,0x29,0x29,0x3b,0x0a,0x78,0x31,0x31,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x31,0x2c,0x52,
|
||||
0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x30,0x2c,0x78,0x39,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,0x78,0x38,0x3d,0x58,0x4f,0x52,0x28,0x20,
|
||||
0x78,0x38,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x31,0x2c,0x78,0x31,0x30,0x29,0x2c,0x39,0x29,0x29,0x3b,0x0a,0x78,0x39,0x3d,
|
||||
0x58,0x4f,0x52,0x28,0x20,0x78,0x39,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x38,0x2c,0x78,0x31,0x31,0x29,0x2c,0x31,0x33,0x29,
|
||||
0x29,0x3b,0x0a,0x78,0x31,0x30,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x30,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x20,0x78,0x39,0x2c,0x78,
|
||||
0x38,0x29,0x2c,0x31,0x38,0x29,0x29,0x3b,0x0a,0x78,0x31,0x32,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x32,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,
|
||||
0x28,0x78,0x31,0x35,0x2c,0x78,0x31,0x34,0x29,0x2c,0x37,0x29,0x29,0x3b,0x0a,0x78,0x31,0x33,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x33,0x2c,0x52,0x4f,0x54,0x41,0x54,
|
||||
0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x32,0x2c,0x78,0x31,0x35,0x29,0x2c,0x39,0x29,0x29,0x3b,0x0a,0x78,0x31,0x34,0x3d,0x58,0x4f,0x52,0x28,0x78,0x31,0x34,
|
||||
0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x33,0x2c,0x78,0x31,0x32,0x29,0x2c,0x31,0x33,0x29,0x29,0x3b,0x0a,0x78,0x31,0x35,0x3d,
|
||||
0x58,0x4f,0x52,0x28,0x78,0x31,0x35,0x2c,0x52,0x4f,0x54,0x41,0x54,0x45,0x28,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x34,0x2c,0x78,0x31,0x33,0x29,0x2c,0x31,0x38,0x29,
|
||||
0x29,0x3b,0x0a,0x7d,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x30,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x30,0x2c,0x6a,0x30,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,
|
||||
0x75,0x74,0x5b,0x31,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x2c,0x6a,0x31,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x32,0x5d,0x3d,0x50,0x4c,0x55,
|
||||
0x53,0x28,0x78,0x32,0x2c,0x6a,0x32,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x33,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x33,0x2c,0x6a,0x33,0x29,0x3b,
|
||||
0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x34,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x34,0x2c,0x6a,0x34,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x35,
|
||||
0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x35,0x2c,0x6a,0x35,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x36,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x36,
|
||||
0x2c,0x6a,0x36,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x37,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x37,0x2c,0x6a,0x37,0x29,0x3b,0x0a,0x6f,0x75,0x74,
|
||||
0x70,0x75,0x74,0x5b,0x38,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x38,0x2c,0x6a,0x38,0x5f,0x31,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x39,0x5d,0x3d,
|
||||
0x50,0x4c,0x55,0x53,0x28,0x78,0x39,0x2c,0x6a,0x39,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x31,0x30,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x30,
|
||||
0x2c,0x6a,0x31,0x30,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x31,0x31,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x31,0x2c,0x6a,0x31,0x31,0x29,0x3b,
|
||||
0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x31,0x32,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x32,0x2c,0x6a,0x31,0x32,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,
|
||||
0x74,0x5b,0x31,0x33,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x33,0x2c,0x6a,0x31,0x33,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x31,0x34,0x5d,0x3d,
|
||||
0x50,0x4c,0x55,0x53,0x28,0x78,0x31,0x34,0x2c,0x6a,0x31,0x34,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x31,0x35,0x5d,0x3d,0x50,0x4c,0x55,0x53,0x28,0x78,
|
||||
0x31,0x35,0x2c,0x6a,0x31,0x35,0x29,0x3b,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x2b,0x3d,0x28,0x53,0x41,0x4c,0x53,0x41,0x32,0x30,0x5f,0x47,0x52,0x4f,0x55,0x50,0x5f,
|
||||
0x53,0x49,0x5a,0x45,0x2a,0x36,0x34,0x29,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,
|
||||
0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x47,0x4c,0x4f,0x42,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x69,0x66,0x28,0x74,
|
||||
0x3c,0x31,0x36,0x29,0x0a,0x7b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x70,0x3d,0x6f,0x75,0x74,0x70,
|
||||
0x75,0x74,0x73,0x2b,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x2b,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x2b,0x33,
|
||||
0x29,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x3b,0x0a,0x70,0x5b,0x74,0x5d,0x3d,0x30,0x3b,0x0a,0x7d,0x0a,0x69,0x66,
|
||||
0x28,0x28,0x74,0x3d,0x3d,0x30,0x29,0x26,0x26,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x26,0x33,0x29,0x29,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,
|
||||
0x73,0x5b,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x2b,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x29,0x2f,0x73,0x69,
|
||||
0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x29,0x5d,0x20,0x26,0x3d,0x20,0x30,0x78,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x55,0x3e,0x3e,
|
||||
0x28,0x28,0x34,0x2d,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x26,0x33,0x29,0x29,0x3c,0x3c,0x33,0x29,0x3b,0x0a,0x7d,0x0a,0x23,0x64,0x65,0x66,
|
||||
0x69,0x6e,0x65,0x20,0x52,0x4f,0x55,0x4e,0x44,0x53,0x20,0x32,0x34,0x20,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x52,0x36,0x34,0x28,0x61,0x2c,0x62,0x2c,0x63,
|
||||
0x29,0x20,0x28,0x28,0x28,0x61,0x29,0x20,0x3c,0x3c,0x20,0x62,0x29,0x20,0x7c,0x20,0x28,0x28,0x61,0x29,0x20,0x3e,0x3e,0x20,0x63,0x29,0x29,0x0a,0x5f,0x5f,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x72,0x63,0x5b,0x32,0x5d,0x5b,0x52,0x4f,0x55,0x4e,
|
||||
0x44,0x53,0x5d,0x3d,0x7b,0x0a,0x7b,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x38,0x32,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,
|
||||
0x30,0x38,0x41,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x38,0x42,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x31,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x38,0x31,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x39,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x38,0x41,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x38,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x30,0x39,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x41,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x38,0x42,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x42,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,
|
||||
0x30,0x38,0x39,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x33,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x32,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x38,0x30,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x41,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x41,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,
|
||||
0x30,0x38,0x31,0x55,0x4c,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x38,0x30,0x55,0x4c,0x2c,0x30,0x78,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x55,0x4c,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,
|
||||
0x30,0x30,0x38,0x55,0x4c,0x7d,0x2c,0x0a,0x7b,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,
|
||||
0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x0a,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,
|
||||
0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x0a,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,
|
||||
0x55,0x4c,0x2c,0x30,0x55,0x4c,0x2c,0x30,0x55,0x4c,0x7d,0x0a,0x7d,0x3b,0x0a,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,
|
||||
0x69,0x6e,0x74,0x20,0x72,0x6f,0x5b,0x32,0x35,0x5d,0x5b,0x32,0x5d,0x3d,0x7b,0x0a,0x7b,0x20,0x30,0x2c,0x36,0x34,0x7d,0x2c,0x7b,0x34,0x34,0x2c,0x32,0x30,0x7d,0x2c,
|
||||
0x7b,0x34,0x33,0x2c,0x32,0x31,0x7d,0x2c,0x7b,0x32,0x31,0x2c,0x34,0x33,0x7d,0x2c,0x7b,0x31,0x34,0x2c,0x35,0x30,0x7d,0x2c,0x0a,0x7b,0x20,0x31,0x2c,0x36,0x33,0x7d,
|
||||
0x2c,0x7b,0x20,0x36,0x2c,0x35,0x38,0x7d,0x2c,0x7b,0x32,0x35,0x2c,0x33,0x39,0x7d,0x2c,0x7b,0x20,0x38,0x2c,0x35,0x36,0x7d,0x2c,0x7b,0x31,0x38,0x2c,0x34,0x36,0x7d,
|
||||
0x2c,0x0a,0x7b,0x36,0x32,0x2c,0x32,0x7d,0x2c,0x7b,0x35,0x35,0x2c,0x39,0x7d,0x2c,0x7b,0x33,0x39,0x2c,0x32,0x35,0x7d,0x2c,0x7b,0x34,0x31,0x2c,0x32,0x33,0x7d,0x2c,
|
||||
0x7b,0x20,0x32,0x2c,0x36,0x32,0x7d,0x2c,0x0a,0x7b,0x32,0x38,0x2c,0x33,0x36,0x7d,0x2c,0x7b,0x32,0x30,0x2c,0x34,0x34,0x7d,0x2c,0x7b,0x20,0x33,0x2c,0x36,0x31,0x7d,
|
||||
0x2c,0x7b,0x34,0x35,0x2c,0x31,0x39,0x7d,0x2c,0x7b,0x36,0x31,0x2c,0x33,0x7d,0x2c,0x0a,0x7b,0x32,0x37,0x2c,0x33,0x37,0x7d,0x2c,0x7b,0x33,0x36,0x2c,0x32,0x38,0x7d,
|
||||
0x2c,0x7b,0x31,0x30,0x2c,0x35,0x34,0x7d,0x2c,0x7b,0x31,0x35,0x2c,0x34,0x39,0x7d,0x2c,0x7b,0x35,0x36,0x2c,0x38,0x7d,0x0a,0x7d,0x3b,0x0a,0x5f,0x5f,0x63,0x6f,0x6e,
|
||||
0x73,0x74,0x61,0x6e,0x74,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x61,0x5b,0x32,0x35,0x5d,0x3d,0x7b,0x0a,0x30,0x2c,0x36,0x2c,0x31,0x32,0x2c,0x31,
|
||||
0x38,0x2c,0x32,0x34,0x2c,0x0a,0x31,0x2c,0x37,0x2c,0x31,0x33,0x2c,0x31,0x39,0x2c,0x32,0x30,0x2c,0x0a,0x32,0x2c,0x38,0x2c,0x31,0x34,0x2c,0x31,0x35,0x2c,0x32,0x31,
|
||||
0x2c,0x0a,0x33,0x2c,0x39,0x2c,0x31,0x30,0x2c,0x31,0x36,0x2c,0x32,0x32,0x2c,0x0a,0x34,0x2c,0x35,0x2c,0x31,0x31,0x2c,0x31,0x37,0x2c,0x32,0x33,0x0a,0x7d,0x3b,0x0a,
|
||||
0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x62,0x5b,0x32,0x35,0x5d,0x3d,0x7b,0x0a,0x30,0x2c,0x31,
|
||||
0x2c,0x32,0x2c,0x33,0x2c,0x34,0x2c,0x0a,0x31,0x2c,0x32,0x2c,0x33,0x2c,0x34,0x2c,0x30,0x2c,0x0a,0x32,0x2c,0x33,0x2c,0x34,0x2c,0x30,0x2c,0x31,0x2c,0x0a,0x33,0x2c,
|
||||
0x34,0x2c,0x30,0x2c,0x31,0x2c,0x32,0x2c,0x0a,0x34,0x2c,0x30,0x2c,0x31,0x2c,0x32,0x2c,0x33,0x0a,0x7d,0x3b,0x0a,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
|
||||
0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x63,0x5b,0x32,0x35,0x5d,0x5b,0x33,0x5d,0x3d,0x7b,0x0a,0x7b,0x20,0x30,0x2c,0x31,0x2c,0x32,0x7d,0x2c,0x7b,
|
||||
0x20,0x31,0x2c,0x32,0x2c,0x33,0x7d,0x2c,0x7b,0x20,0x32,0x2c,0x33,0x2c,0x34,0x7d,0x2c,0x7b,0x20,0x33,0x2c,0x34,0x2c,0x30,0x7d,0x2c,0x7b,0x20,0x34,0x2c,0x30,0x2c,
|
||||
0x31,0x7d,0x2c,0x0a,0x7b,0x20,0x35,0x2c,0x36,0x2c,0x37,0x7d,0x2c,0x7b,0x20,0x36,0x2c,0x37,0x2c,0x38,0x7d,0x2c,0x7b,0x20,0x37,0x2c,0x38,0x2c,0x39,0x7d,0x2c,0x7b,
|
||||
0x20,0x38,0x2c,0x39,0x2c,0x35,0x7d,0x2c,0x7b,0x20,0x39,0x2c,0x35,0x2c,0x36,0x7d,0x2c,0x0a,0x7b,0x31,0x30,0x2c,0x31,0x31,0x2c,0x31,0x32,0x7d,0x2c,0x7b,0x31,0x31,
|
||||
0x2c,0x31,0x32,0x2c,0x31,0x33,0x7d,0x2c,0x7b,0x31,0x32,0x2c,0x31,0x33,0x2c,0x31,0x34,0x7d,0x2c,0x7b,0x31,0x33,0x2c,0x31,0x34,0x2c,0x31,0x30,0x7d,0x2c,0x7b,0x31,
|
||||
0x34,0x2c,0x31,0x30,0x2c,0x31,0x31,0x7d,0x2c,0x0a,0x7b,0x31,0x35,0x2c,0x31,0x36,0x2c,0x31,0x37,0x7d,0x2c,0x7b,0x31,0x36,0x2c,0x31,0x37,0x2c,0x31,0x38,0x7d,0x2c,
|
||||
0x7b,0x31,0x37,0x2c,0x31,0x38,0x2c,0x31,0x39,0x7d,0x2c,0x7b,0x31,0x38,0x2c,0x31,0x39,0x2c,0x31,0x35,0x7d,0x2c,0x7b,0x31,0x39,0x2c,0x31,0x35,0x2c,0x31,0x36,0x7d,
|
||||
0x2c,0x0a,0x7b,0x32,0x30,0x2c,0x32,0x31,0x2c,0x32,0x32,0x7d,0x2c,0x7b,0x32,0x31,0x2c,0x32,0x32,0x2c,0x32,0x33,0x7d,0x2c,0x7b,0x32,0x32,0x2c,0x32,0x33,0x2c,0x32,
|
||||
0x34,0x7d,0x2c,0x7b,0x32,0x33,0x2c,0x32,0x34,0x2c,0x32,0x30,0x7d,0x2c,0x7b,0x32,0x34,0x2c,0x32,0x30,0x2c,0x32,0x31,0x7d,0x0a,0x7d,0x3b,0x0a,0x5f,0x5f,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x69,0x6e,0x74,0x20,0x64,0x5b,0x32,0x35,0x5d,0x3d,0x7b,0x0a,0x30,0x2c,0x31,0x2c,0x32,0x2c,0x33,
|
||||
0x2c,0x34,0x2c,0x0a,0x31,0x30,0x2c,0x31,0x31,0x2c,0x31,0x32,0x2c,0x31,0x33,0x2c,0x31,0x34,0x2c,0x0a,0x32,0x30,0x2c,0x32,0x31,0x2c,0x32,0x32,0x2c,0x32,0x33,0x2c,
|
||||
0x32,0x34,0x2c,0x0a,0x35,0x2c,0x36,0x2c,0x37,0x2c,0x38,0x2c,0x39,0x2c,0x0a,0x31,0x35,0x2c,0x31,0x36,0x2c,0x31,0x37,0x2c,0x31,0x38,0x2c,0x31,0x39,0x0a,0x7d,0x3b,
|
||||
0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,
|
||||
0x73,0x69,0x7a,0x65,0x28,0x33,0x32,0x2c,0x31,0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x73,0x68,0x61,
|
||||
0x33,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x69,0x6e,0x70,0x75,0x74,0x73,
|
||||
0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x69,0x6e,0x70,0x75,0x74,0x5f,
|
||||
0x73,0x69,0x7a,0x65,0x73,0x2c,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x74,0x72,0x69,0x64,0x65,0x2c,0x5f,0x5f,0x67,0x6c,
|
||||
0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x68,0x61,0x73,0x68,0x65,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x74,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,
|
||||
0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x3d,0x67,0x65,0x74,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x69,0x66,0x28,
|
||||
0x74,0x3e,0x3d,0x32,0x35,0x29,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x73,0x3d,
|
||||
0x74,0x20,0x25,0x20,0x35,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x69,0x6e,0x70,0x75,0x74,0x5f,0x6f,0x66,0x66,0x73,
|
||||
0x65,0x74,0x3d,0x28,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x74,0x72,0x69,0x64,0x65,0x29,0x2a,0x67,0x3b,0x0a,0x5f,
|
||||
0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x69,0x6e,0x70,0x75,0x74,0x3d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,
|
||||
0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x29,0x28,0x69,0x6e,0x70,0x75,0x74,0x73,0x2b,0x69,0x6e,0x70,0x75,0x74,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,
|
||||
0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x3d,0x69,0x6e,0x70,
|
||||
0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x73,0x5b,0x67,0x5d,0x2b,0x31,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,
|
||||
0x41,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x43,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x5f,
|
||||
0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x44,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x41,0x5b,0x74,0x5d,0x3d,0x30,0x3b,0x0a,0x63,
|
||||
0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x77,0x6f,0x72,0x64,0x73,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x2f,0x73,
|
||||
0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,
|
||||
0x74,0x61,0x69,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x20,0x25,0x20,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,
|
||||
0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,0x3d,0x30,0x3b,0x0a,0x66,
|
||||
0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x77,0x6f,0x72,0x64,0x73,0x3b,0x20,0x2b,0x2b,0x69,0x2c,0x2b,
|
||||
0x2b,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x41,0x5b,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,0x5d,0x20,0x5e,0x3d,0x20,0x2a,0x69,0x6e,0x70,0x75,0x74,
|
||||
0x3b,0x0a,0x2b,0x2b,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,0x3b,0x0a,0x69,0x66,0x28,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,0x3d,0x3d,0x31,0x37,0x29,
|
||||
0x0a,0x7b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x28,0x52,0x4f,0x55,0x4e,0x44,0x53,0x29,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,
|
||||
0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x52,0x4f,0x55,0x4e,0x44,0x53,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x0a,0x7b,0x0a,0x43,0x5b,0x74,0x5d,0x3d,0x41,0x5b,
|
||||
0x73,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x35,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x31,0x30,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x31,0x35,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x32,0x30,
|
||||
0x5d,0x3b,0x0a,0x44,0x5b,0x74,0x5d,0x3d,0x43,0x5b,0x62,0x5b,0x32,0x30,0x2b,0x73,0x5d,0x5d,0x5e,0x52,0x36,0x34,0x28,0x43,0x5b,0x62,0x5b,0x35,0x2b,0x73,0x5d,0x5d,
|
||||
0x2c,0x31,0x2c,0x36,0x33,0x29,0x3b,0x0a,0x43,0x5b,0x74,0x5d,0x3d,0x52,0x36,0x34,0x28,0x41,0x5b,0x61,0x5b,0x74,0x5d,0x5d,0x5e,0x44,0x5b,0x62,0x5b,0x74,0x5d,0x5d,
|
||||
0x2c,0x72,0x6f,0x5b,0x74,0x5d,0x5b,0x30,0x5d,0x2c,0x72,0x6f,0x5b,0x74,0x5d,0x5b,0x31,0x5d,0x29,0x3b,0x0a,0x41,0x5b,0x64,0x5b,0x74,0x5d,0x5d,0x3d,0x43,0x5b,0x63,
|
||||
0x5b,0x74,0x5d,0x5b,0x30,0x5d,0x5d,0x5e,0x28,0x28,0x7e,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x31,0x5d,0x5d,0x29,0x26,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x32,0x5d,
|
||||
0x5d,0x29,0x3b,0x0a,0x41,0x5b,0x74,0x5d,0x20,0x5e,0x3d,0x20,0x72,0x63,0x5b,0x28,0x74,0x3d,0x3d,0x30,0x29,0x3f,0x30,0x3a,0x31,0x5d,0x5b,0x69,0x5d,0x3b,0x20,0x0a,
|
||||
0x7d,0x0a,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,0x3d,0x30,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x74,0x61,0x69,0x6c,
|
||||
0x3d,0x30,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x70,0x3d,0x28,0x5f,
|
||||
0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x29,0x69,0x6e,0x70,0x75,0x74,0x3b,0x0a,0x66,0x6f,
|
||||
0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x74,0x61,0x69,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x20,0x2b,0x2b,
|
||||
0x69,0x29,0x0a,0x7b,0x0a,0x74,0x61,0x69,0x6c,0x7c,0x3d,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x70,0x5b,0x69,0x5d,0x29,0x3c,0x3c,0x28,0x69,0x2a,
|
||||
0x38,0x29,0x3b,0x0a,0x7d,0x0a,0x41,0x5b,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,0x5d,0x20,0x5e,0x3d,0x20,0x74,0x61,0x69,0x6c,0x5e,0x28,0x28,0x75,0x69,0x6e,
|
||||
0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x28,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x30,0x78,0x30,0x32,0x7c,0x28,0x31,0x3c,0x3c,0x32,0x29,0x29,0x29,
|
||||
0x3c,0x3c,0x28,0x74,0x61,0x69,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x2a,0x38,0x29,0x29,0x29,0x3b,0x0a,0x41,0x5b,0x31,0x36,0x5d,0x20,0x5e,0x3d,0x20,0x30,0x78,0x38,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x55,0x4c,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,
|
||||
0x28,0x31,0x29,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x52,0x4f,0x55,0x4e,0x44,0x53,0x3b,0x20,0x2b,0x2b,0x69,0x29,
|
||||
0x0a,0x7b,0x0a,0x43,0x5b,0x74,0x5d,0x3d,0x41,0x5b,0x73,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x35,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x31,0x30,0x5d,0x5e,0x41,0x5b,0x73,0x2b,
|
||||
0x31,0x35,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x32,0x30,0x5d,0x3b,0x0a,0x44,0x5b,0x74,0x5d,0x3d,0x43,0x5b,0x62,0x5b,0x32,0x30,0x2b,0x73,0x5d,0x5d,0x5e,0x52,0x36,0x34,
|
||||
0x28,0x43,0x5b,0x62,0x5b,0x35,0x2b,0x73,0x5d,0x5d,0x2c,0x31,0x2c,0x36,0x33,0x29,0x3b,0x0a,0x43,0x5b,0x74,0x5d,0x3d,0x52,0x36,0x34,0x28,0x41,0x5b,0x61,0x5b,0x74,
|
||||
0x5d,0x5d,0x5e,0x44,0x5b,0x62,0x5b,0x74,0x5d,0x5d,0x2c,0x72,0x6f,0x5b,0x74,0x5d,0x5b,0x30,0x5d,0x2c,0x72,0x6f,0x5b,0x74,0x5d,0x5b,0x31,0x5d,0x29,0x3b,0x0a,0x41,
|
||||
0x5b,0x64,0x5b,0x74,0x5d,0x5d,0x3d,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x30,0x5d,0x5d,0x5e,0x28,0x28,0x7e,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x31,0x5d,0x5d,0x29,
|
||||
0x26,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x32,0x5d,0x5d,0x29,0x3b,0x0a,0x41,0x5b,0x74,0x5d,0x20,0x5e,0x3d,0x20,0x72,0x63,0x5b,0x28,0x74,0x3d,0x3d,0x30,0x29,0x3f,
|
||||
0x30,0x3a,0x31,0x5d,0x5b,0x69,0x5d,0x3b,0x20,0x0a,0x7d,0x0a,0x69,0x66,0x28,0x74,0x3c,0x34,0x29,0x0a,0x7b,0x0a,0x68,0x61,0x73,0x68,0x65,0x73,0x2b,0x3d,0x67,0x2a,
|
||||
0x28,0x33,0x32,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x29,0x3b,0x0a,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x74,0x5d,
|
||||
0x3d,0x41,0x5b,0x74,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,0x77,
|
||||
0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x73,0x69,0x7a,0x65,0x28,0x33,0x32,0x2c,0x31,0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,
|
||||
0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x73,0x68,0x61,0x33,0x5f,0x69,0x6e,0x69,0x74,0x69,0x61,0x6c,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x6f,0x6e,
|
||||
0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x38,0x5f,0x74,0x2a,0x20,0x69,0x6e,0x70,0x75,0x74,0x5f,0x64,0x61,0x74,0x61,0x2c,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,
|
||||
0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x2c,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x6e,0x6f,0x6e,0x63,0x65,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,
|
||||
0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x68,0x61,0x73,0x68,0x65,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,
|
||||
0x74,0x33,0x32,0x5f,0x74,0x20,0x74,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x67,0x3d,0x67,0x65,0x74,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x0a,0x69,0x66,0x28,0x74,0x3e,
|
||||
0x3d,0x32,0x35,0x29,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x73,0x3d,0x74,0x20,
|
||||
0x25,0x20,0x35,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x20,0x69,0x6e,0x70,0x75,0x74,0x3d,0x28,0x5f,
|
||||
0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x2a,0x29,0x28,0x69,0x6e,0x70,0x75,0x74,0x5f,0x64,0x61,0x74,0x61,0x29,0x3b,0x0a,
|
||||
0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x41,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,
|
||||
0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x20,0x43,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,
|
||||
0x20,0x44,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x41,0x5b,0x74,0x5d,0x3d,0x28,0x74,0x3c,0x31,0x36,0x29,0x3f,0x69,0x6e,0x70,0x75,0x74,0x5b,0x74,0x5d,0x3a,0x30,0x3b,0x0a,
|
||||
0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x20,0x6e,0x6f,0x6e,0x63,0x65,0x5f,0x70,0x6f,0x73,0x3d,0x28,0x5f,0x5f,0x6c,
|
||||
0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x2a,0x29,0x28,0x41,0x29,0x2b,0x39,0x3b,0x0a,0x6e,0x6f,0x6e,0x63,0x65,0x2b,0x3d,0x67,0x3b,0x0a,
|
||||
0x6e,0x6f,0x6e,0x63,0x65,0x5f,0x70,0x6f,0x73,0x5b,0x30,0x5d,0x3d,0x28,0x6e,0x6f,0x6e,0x63,0x65,0x5f,0x70,0x6f,0x73,0x5b,0x30,0x5d,0x26,0x30,0x78,0x46,0x46,0x46,
|
||||
0x46,0x46,0x46,0x55,0x29,0x7c,0x28,0x28,0x6e,0x6f,0x6e,0x63,0x65,0x26,0x30,0x78,0x46,0x46,0x29,0x3c,0x3c,0x32,0x34,0x29,0x3b,0x0a,0x6e,0x6f,0x6e,0x63,0x65,0x5f,
|
||||
0x70,0x6f,0x73,0x5b,0x31,0x5d,0x3d,0x28,0x6e,0x6f,0x6e,0x63,0x65,0x5f,0x70,0x6f,0x73,0x5b,0x31,0x5d,0x26,0x30,0x78,0x46,0x46,0x30,0x30,0x30,0x30,0x30,0x30,0x55,
|
||||
0x29,0x7c,0x28,0x6e,0x6f,0x6e,0x63,0x65,0x3e,0x3e,0x38,0x29,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,0x78,
|
||||
0x3d,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,0x65,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x3b,0x0a,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x33,0x32,0x5f,0x74,0x20,0x74,0x61,0x69,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5f,0x73,0x69,0x7a,
|
||||
0x65,0x20,0x25,0x20,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x3b,0x0a,0x41,0x5b,0x77,0x6f,0x72,0x64,0x49,0x6e,0x64,0x65,
|
||||
0x78,0x5d,0x20,0x5e,0x3d,0x20,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x28,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,0x74,0x29,0x28,0x30,0x78,0x30,
|
||||
0x32,0x7c,0x28,0x31,0x3c,0x3c,0x32,0x29,0x29,0x29,0x3c,0x3c,0x28,0x74,0x61,0x69,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x2a,0x38,0x29,0x29,0x3b,0x0a,0x41,0x5b,0x31,0x36,
|
||||
0x5d,0x20,0x5e,0x3d,0x20,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x55,0x4c,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,
|
||||
0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x28,0x52,0x4f,0x55,0x4e,0x44,0x53,0x29,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,
|
||||
0x69,0x3c,0x52,0x4f,0x55,0x4e,0x44,0x53,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x0a,0x7b,0x0a,0x43,0x5b,0x74,0x5d,0x3d,0x41,0x5b,0x73,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x35,
|
||||
0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x31,0x30,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x31,0x35,0x5d,0x5e,0x41,0x5b,0x73,0x2b,0x32,0x30,0x5d,0x3b,0x0a,0x44,0x5b,0x74,0x5d,0x3d,
|
||||
0x43,0x5b,0x62,0x5b,0x32,0x30,0x2b,0x73,0x5d,0x5d,0x5e,0x52,0x36,0x34,0x28,0x43,0x5b,0x62,0x5b,0x35,0x2b,0x73,0x5d,0x5d,0x2c,0x31,0x2c,0x36,0x33,0x29,0x3b,0x0a,
|
||||
0x43,0x5b,0x74,0x5d,0x3d,0x52,0x36,0x34,0x28,0x41,0x5b,0x61,0x5b,0x74,0x5d,0x5d,0x5e,0x44,0x5b,0x62,0x5b,0x74,0x5d,0x5d,0x2c,0x72,0x6f,0x5b,0x74,0x5d,0x5b,0x30,
|
||||
0x5d,0x2c,0x72,0x6f,0x5b,0x74,0x5d,0x5b,0x31,0x5d,0x29,0x3b,0x0a,0x41,0x5b,0x64,0x5b,0x74,0x5d,0x5d,0x3d,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x30,0x5d,0x5d,0x5e,
|
||||
0x28,0x28,0x7e,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x31,0x5d,0x5d,0x29,0x26,0x43,0x5b,0x63,0x5b,0x74,0x5d,0x5b,0x32,0x5d,0x5d,0x29,0x3b,0x0a,0x41,0x5b,0x74,0x5d,
|
||||
0x20,0x5e,0x3d,0x20,0x72,0x63,0x5b,0x28,0x74,0x3d,0x3d,0x30,0x29,0x3f,0x30,0x3a,0x31,0x5d,0x5b,0x69,0x5d,0x3b,0x20,0x0a,0x7d,0x0a,0x69,0x66,0x28,0x74,0x3c,0x34,
|
||||
0x29,0x0a,0x7b,0x0a,0x68,0x61,0x73,0x68,0x65,0x73,0x2b,0x3d,0x67,0x2a,0x28,0x33,0x32,0x2f,0x73,0x69,0x7a,0x65,0x6f,0x66,0x28,0x75,0x69,0x6e,0x74,0x36,0x34,0x5f,
|
||||
0x74,0x29,0x29,0x3b,0x0a,0x68,0x61,0x73,0x68,0x65,0x73,0x5b,0x74,0x5d,0x3d,0x41,0x5b,0x74,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x00
|
||||
};
|
||||
|
||||
} // namespace xmrig
|
153
src/backend/opencl/cl/astrobwt/salsa20.cl
Normal file
153
src/backend/opencl/cl/astrobwt/salsa20.cl
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define ROTATE(v,c) (rotate(v,(uint32_t)c))
|
||||
#define XOR(v,w) ((v) ^ (w))
|
||||
#define PLUS(v,w) ((v) + (w))
|
||||
|
||||
__attribute__((reqd_work_group_size(SALSA20_GROUP_SIZE, 1, 1)))
|
||||
__kernel void Salsa20_XORKeyStream(__global const uint32_t* keys, __global uint32_t* outputs, __global uint32_t* output_sizes, uint32_t output_stride)
|
||||
{
|
||||
const uint32_t t = get_local_id(0);
|
||||
const uint32_t g = get_group_id(0);
|
||||
|
||||
// Put zeroes in the beginning
|
||||
const uint64_t output_offset = g * ((uint64_t)output_stride) + 128;
|
||||
{
|
||||
__global uint32_t* p = outputs + (output_offset - 128) / sizeof(uint32_t);
|
||||
for (uint32_t i = t; i < 128 / sizeof(uint32_t); i += SALSA20_GROUP_SIZE)
|
||||
p[i] = 0;
|
||||
}
|
||||
|
||||
__global const uint32_t* k = keys + g * 8;
|
||||
__global uint32_t* output = outputs + (output_offset + (t * 64)) / sizeof(uint32_t);
|
||||
const uint32_t output_size = output_sizes[g];
|
||||
|
||||
const uint32_t j1 = k[0];
|
||||
const uint32_t j2 = k[1];
|
||||
const uint32_t j3 = k[2];
|
||||
const uint32_t j4 = k[3];
|
||||
const uint32_t j11 = k[4];
|
||||
const uint32_t j12 = k[5];
|
||||
const uint32_t j13 = k[6];
|
||||
const uint32_t j14 = k[7];
|
||||
const uint32_t j0 = 0x61707865U;
|
||||
const uint32_t j5 = 0x3320646EU;
|
||||
const uint32_t j10 = 0x79622D32U;
|
||||
const uint32_t j15 = 0x6B206574U;
|
||||
const uint32_t j6 = 0;
|
||||
const uint32_t j7 = 0;
|
||||
const uint32_t j8 = 0;
|
||||
const uint32_t j9 = 0;
|
||||
|
||||
for (uint32_t i = t * 64; i < output_size; i += SALSA20_GROUP_SIZE * 64)
|
||||
{
|
||||
const uint32_t j8_1 = j8 + (i / 64);
|
||||
|
||||
uint32_t x0 = j0;
|
||||
uint32_t x1 = j1;
|
||||
uint32_t x2 = j2;
|
||||
uint32_t x3 = j3;
|
||||
uint32_t x4 = j4;
|
||||
uint32_t x5 = j5;
|
||||
uint32_t x6 = j6;
|
||||
uint32_t x7 = j7;
|
||||
uint32_t x8 = j8_1;
|
||||
uint32_t x9 = j9;
|
||||
uint32_t x10 = j10;
|
||||
uint32_t x11 = j11;
|
||||
uint32_t x12 = j12;
|
||||
uint32_t x13 = j13;
|
||||
uint32_t x14 = j14;
|
||||
uint32_t x15 = j15;
|
||||
|
||||
#pragma unroll(5)
|
||||
for (uint32_t j = 0; j < 10; ++j)
|
||||
{
|
||||
x4 = XOR( x4,ROTATE(PLUS( x0,x12), 7));
|
||||
x8 = XOR( x8,ROTATE(PLUS( x4, x0), 9));
|
||||
x12 = XOR(x12,ROTATE(PLUS( x8, x4),13));
|
||||
x0 = XOR( x0,ROTATE(PLUS(x12, x8),18));
|
||||
x9 = XOR( x9,ROTATE(PLUS( x5, x1), 7));
|
||||
x13 = XOR(x13,ROTATE(PLUS( x9, x5), 9));
|
||||
x1 = XOR( x1,ROTATE(PLUS(x13, x9),13));
|
||||
x5 = XOR( x5,ROTATE(PLUS( x1,x13),18));
|
||||
x14 = XOR(x14,ROTATE(PLUS(x10, x6), 7));
|
||||
x2 = XOR( x2,ROTATE(PLUS(x14,x10), 9));
|
||||
x6 = XOR( x6,ROTATE(PLUS( x2,x14),13));
|
||||
x10 = XOR(x10,ROTATE(PLUS( x6, x2),18));
|
||||
x3 = XOR( x3,ROTATE(PLUS(x15,x11), 7));
|
||||
x7 = XOR( x7,ROTATE(PLUS( x3,x15), 9));
|
||||
x11 = XOR(x11,ROTATE(PLUS( x7, x3),13));
|
||||
x15 = XOR(x15,ROTATE(PLUS(x11, x7),18));
|
||||
x1 = XOR( x1,ROTATE(PLUS( x0, x3), 7));
|
||||
x2 = XOR( x2,ROTATE(PLUS( x1, x0), 9));
|
||||
x3 = XOR( x3,ROTATE(PLUS( x2, x1),13));
|
||||
x0 = XOR( x0,ROTATE(PLUS( x3, x2),18));
|
||||
x6 = XOR( x6,ROTATE(PLUS( x5, x4), 7));
|
||||
x7 = XOR( x7,ROTATE(PLUS( x6, x5), 9));
|
||||
x4 = XOR( x4,ROTATE(PLUS( x7, x6),13));
|
||||
x5 = XOR( x5,ROTATE(PLUS( x4, x7),18));
|
||||
x11 = XOR(x11,ROTATE(PLUS(x10, x9), 7));
|
||||
x8 = XOR( x8,ROTATE(PLUS(x11,x10), 9));
|
||||
x9 = XOR( x9,ROTATE(PLUS( x8,x11),13));
|
||||
x10 = XOR(x10,ROTATE(PLUS( x9, x8),18));
|
||||
x12 = XOR(x12,ROTATE(PLUS(x15,x14), 7));
|
||||
x13 = XOR(x13,ROTATE(PLUS(x12,x15), 9));
|
||||
x14 = XOR(x14,ROTATE(PLUS(x13,x12),13));
|
||||
x15 = XOR(x15,ROTATE(PLUS(x14,x13),18));
|
||||
}
|
||||
|
||||
output[0] = PLUS(x0, j0);
|
||||
output[1] = PLUS(x1, j1);
|
||||
output[2] = PLUS(x2, j2);
|
||||
output[3] = PLUS(x3, j3);
|
||||
output[4] = PLUS(x4, j4);
|
||||
output[5] = PLUS(x5, j5);
|
||||
output[6] = PLUS(x6, j6);
|
||||
output[7] = PLUS(x7, j7);
|
||||
output[8] = PLUS(x8, j8_1);
|
||||
output[9] = PLUS(x9, j9);
|
||||
output[10] = PLUS(x10,j10);
|
||||
output[11] = PLUS(x11,j11);
|
||||
output[12] = PLUS(x12,j12);
|
||||
output[13] = PLUS(x13,j13);
|
||||
output[14] = PLUS(x14,j14);
|
||||
output[15] = PLUS(x15,j15);
|
||||
|
||||
output += (SALSA20_GROUP_SIZE * 64) / sizeof(uint32_t);
|
||||
}
|
||||
|
||||
barrier(CLK_GLOBAL_MEM_FENCE);
|
||||
|
||||
// Put zeroes after output's end
|
||||
if (t < 16)
|
||||
{
|
||||
__global uint32_t* p = outputs + (output_offset + output_size + 3) / sizeof(uint32_t);
|
||||
p[t] = 0;
|
||||
}
|
||||
|
||||
if ((t == 0) && (output_size & 3))
|
||||
outputs[(output_offset + output_size) / sizeof(uint32_t)] &= 0xFFFFFFFFU >> ((4 - (output_size & 3)) << 3);
|
||||
}
|
198
src/backend/opencl/cl/astrobwt/sha3.cl
Normal file
198
src/backend/opencl/cl/astrobwt/sha3.cl
Normal file
|
@ -0,0 +1,198 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define ROUNDS 24
|
||||
#define R64(a,b,c) (((a) << b) | ((a) >> c))
|
||||
|
||||
__constant const uint64_t rc[2][ROUNDS] = {
|
||||
{0x0000000000000001UL, 0x0000000000008082UL, 0x800000000000808AUL,
|
||||
0x8000000080008000UL, 0x000000000000808BUL, 0x0000000080000001UL,
|
||||
0x8000000080008081UL, 0x8000000000008009UL, 0x000000000000008AUL,
|
||||
0x0000000000000088UL, 0x0000000080008009UL, 0x000000008000000AUL,
|
||||
0x000000008000808BUL, 0x800000000000008BUL, 0x8000000000008089UL,
|
||||
0x8000000000008003UL, 0x8000000000008002UL, 0x8000000000000080UL,
|
||||
0x000000000000800AUL, 0x800000008000000AUL, 0x8000000080008081UL,
|
||||
0x8000000000008080UL, 0x0000000080000001UL, 0x8000000080008008UL},
|
||||
{0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL,
|
||||
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL,
|
||||
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL}
|
||||
};
|
||||
|
||||
|
||||
__constant const int ro[25][2] = {
|
||||
{ 0,64}, {44,20}, {43,21}, {21,43}, {14,50},
|
||||
{ 1,63}, { 6,58}, {25,39}, { 8,56}, {18,46},
|
||||
{62, 2}, {55, 9}, {39,25}, {41,23}, { 2,62},
|
||||
{28,36}, {20,44}, { 3,61}, {45,19}, {61, 3},
|
||||
{27,37}, {36,28}, {10,54}, {15,49}, {56, 8}
|
||||
};
|
||||
|
||||
__constant const int a[25] = {
|
||||
0, 6, 12, 18, 24,
|
||||
1, 7, 13, 19, 20,
|
||||
2, 8, 14, 15, 21,
|
||||
3, 9, 10, 16, 22,
|
||||
4, 5, 11, 17, 23
|
||||
};
|
||||
|
||||
__constant const int b[25] = {
|
||||
0, 1, 2, 3, 4,
|
||||
1, 2, 3, 4, 0,
|
||||
2, 3, 4, 0, 1,
|
||||
3, 4, 0, 1, 2,
|
||||
4, 0, 1, 2, 3
|
||||
};
|
||||
|
||||
__constant const int c[25][3] = {
|
||||
{ 0, 1, 2}, { 1, 2, 3}, { 2, 3, 4}, { 3, 4, 0}, { 4, 0, 1},
|
||||
{ 5, 6, 7}, { 6, 7, 8}, { 7, 8, 9}, { 8, 9, 5}, { 9, 5, 6},
|
||||
{10,11,12}, {11,12,13}, {12,13,14}, {13,14,10}, {14,10,11},
|
||||
{15,16,17}, {16,17,18}, {17,18,19}, {18,19,15}, {19,15,16},
|
||||
{20,21,22}, {21,22,23}, {22,23,24}, {23,24,20}, {24,20,21}
|
||||
};
|
||||
|
||||
__constant const int d[25] = {
|
||||
0, 1, 2, 3, 4,
|
||||
10, 11, 12, 13, 14,
|
||||
20, 21, 22, 23, 24,
|
||||
5, 6, 7, 8, 9,
|
||||
15, 16, 17, 18, 19
|
||||
};
|
||||
|
||||
__attribute__((reqd_work_group_size(32, 1, 1)))
|
||||
__kernel void sha3(__global const uint8_t* inputs, __global const uint32_t* input_sizes, uint32_t input_stride, __global uint64_t* hashes)
|
||||
{
|
||||
const uint32_t t = get_local_id(0);
|
||||
const uint32_t g = get_group_id(0);
|
||||
|
||||
if (t >= 25)
|
||||
return;
|
||||
|
||||
const uint32_t s = t % 5;
|
||||
|
||||
const uint64_t input_offset = ((uint64_t)input_stride) * g;
|
||||
__global uint64_t* input = (__global uint64_t*)(inputs + input_offset);
|
||||
const uint32_t input_size = input_sizes[g] + 1;
|
||||
|
||||
__local uint64_t A[25];
|
||||
__local uint64_t C[25];
|
||||
__local uint64_t D[25];
|
||||
|
||||
A[t] = 0;
|
||||
|
||||
const uint32_t words = input_size / sizeof(uint64_t);
|
||||
const uint32_t tail_size = input_size % sizeof(uint64_t);
|
||||
|
||||
uint32_t wordIndex = 0;
|
||||
for (uint32_t i = 0; i < words; ++i, ++input)
|
||||
{
|
||||
A[wordIndex] ^= *input;
|
||||
++wordIndex;
|
||||
if (wordIndex == 17)
|
||||
{
|
||||
#pragma unroll(ROUNDS)
|
||||
for (int i = 0; i < ROUNDS; ++i)
|
||||
{
|
||||
C[t] = A[s] ^ A[s+5] ^ A[s+10] ^ A[s+15] ^ A[s+20];
|
||||
D[t] = C[b[20+s]] ^ R64(C[b[5+s]], 1, 63);
|
||||
C[t] = R64(A[a[t]] ^ D[b[t]], ro[t][0], ro[t][1]);
|
||||
A[d[t]] = C[c[t][0]] ^ ((~C[c[t][1]]) & C[c[t][2]]);
|
||||
A[t] ^= rc[(t == 0) ? 0 : 1][i];
|
||||
}
|
||||
wordIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t tail = 0;
|
||||
__global const uint8_t* p = (__global const uint8_t*)input;
|
||||
for (uint32_t i = 0; i < tail_size; ++i)
|
||||
{
|
||||
tail |= (uint64_t)(p[i]) << (i * 8);
|
||||
}
|
||||
A[wordIndex] ^= tail ^ ((uint64_t)(((uint64_t)(0x02 | (1 << 2))) << (tail_size * 8)));
|
||||
A[16] ^= 0x8000000000000000UL;
|
||||
|
||||
#pragma unroll(1)
|
||||
for (int i = 0; i < ROUNDS; ++i)
|
||||
{
|
||||
C[t] = A[s] ^ A[s+5] ^ A[s+10] ^ A[s+15] ^ A[s+20];
|
||||
D[t] = C[b[20+s]] ^ R64(C[b[5+s]], 1, 63);
|
||||
C[t] = R64(A[a[t]] ^ D[b[t]], ro[t][0], ro[t][1]);
|
||||
A[d[t]] = C[c[t][0]] ^ ((~C[c[t][1]]) & C[c[t][2]]);
|
||||
A[t] ^= rc[(t == 0) ? 0 : 1][i];
|
||||
}
|
||||
|
||||
if (t < 4)
|
||||
{
|
||||
hashes += g * (32 / sizeof(uint64_t));
|
||||
hashes[t] = A[t];
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((reqd_work_group_size(32, 1, 1)))
|
||||
__kernel void sha3_initial(__global const uint8_t* input_data, uint32_t input_size, uint32_t nonce, __global uint64_t* hashes)
|
||||
{
|
||||
const uint32_t t = get_local_id(0);
|
||||
const uint32_t g = get_group_id(0);
|
||||
|
||||
if (t >= 25)
|
||||
return;
|
||||
|
||||
const uint32_t s = t % 5;
|
||||
|
||||
__global uint64_t* input = (__global uint64_t*)(input_data);
|
||||
|
||||
__local uint64_t A[25];
|
||||
__local uint64_t C[25];
|
||||
__local uint64_t D[25];
|
||||
|
||||
A[t] = (t < 16) ? input[t] : 0;
|
||||
|
||||
__local uint32_t* nonce_pos = (__local uint32_t*)(A) + 9;
|
||||
nonce += g;
|
||||
nonce_pos[0] = (nonce_pos[0] & 0xFFFFFFU) | ((nonce & 0xFF) << 24);
|
||||
nonce_pos[1] = (nonce_pos[1] & 0xFF000000U) | (nonce >> 8);
|
||||
|
||||
uint32_t wordIndex = input_size / sizeof(uint64_t);
|
||||
const uint32_t tail_size = input_size % sizeof(uint64_t);
|
||||
|
||||
A[wordIndex] ^= (uint64_t)(((uint64_t)(0x02 | (1 << 2))) << (tail_size * 8));
|
||||
A[16] ^= 0x8000000000000000UL;
|
||||
|
||||
#pragma unroll(ROUNDS)
|
||||
for (int i = 0; i < ROUNDS; ++i)
|
||||
{
|
||||
C[t] = A[s] ^ A[s+5] ^ A[s+10] ^ A[s+15] ^ A[s+20];
|
||||
D[t] = C[b[20+s]] ^ R64(C[b[5+s]], 1, 63);
|
||||
C[t] = R64(A[a[t]] ^ D[b[t]], ro[t][0], ro[t][1]);
|
||||
A[d[t]] = C[c[t][0]] ^ ((~C[c[t][1]]) & C[c[t][2]]);
|
||||
A[t] ^= rc[(t == 0) ? 0 : 1][i];
|
||||
}
|
||||
|
||||
if (t < 4)
|
||||
{
|
||||
hashes += g * (32 / sizeof(uint64_t));
|
||||
hashes[t] = A[t];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/OclThreads.h"
|
||||
#include "backend/opencl/wrappers/OclDevice.h"
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "crypto/randomx/randomx.h"
|
||||
#include "crypto/rx/RxAlgo.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
bool ocl_generic_astrobwt_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads)
|
||||
{
|
||||
if (algorithm.family() != Algorithm::ASTROBWT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t mem = device.globalMemSize();
|
||||
|
||||
uint32_t per_thread_mem = 10 << 20;
|
||||
uint32_t intensity = static_cast<uint32_t>((mem - (128 << 20)) / per_thread_mem / 2);
|
||||
|
||||
intensity &= ~63U;
|
||||
|
||||
if (!intensity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (intensity > 256) {
|
||||
intensity = 256;
|
||||
}
|
||||
|
||||
threads.add(OclThread(device.index(), intensity, 2));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
|
@ -59,6 +59,8 @@ public:
|
|||
virtual const OclLaunchData &data() const = 0;
|
||||
virtual size_t intensity() const = 0;
|
||||
virtual size_t threadId() const = 0;
|
||||
virtual uint32_t roundSize() const = 0;
|
||||
virtual uint32_t processedHashes() const = 0;
|
||||
virtual uint32_t deviceIndex() const = 0;
|
||||
virtual void build() = 0;
|
||||
virtual void init() = 0;
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_FilterKernel::enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size)
|
||||
{
|
||||
enqueueNDRange(queue, 1, nullptr, &threads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_FilterKernel::setArgs(uint32_t nonce, uint32_t bwt_max_size, cl_mem hashes, cl_mem filtered_hashes)
|
||||
{
|
||||
setArg(0, sizeof(uint32_t), &nonce);
|
||||
setArg(1, sizeof(uint32_t), &bwt_max_size);
|
||||
setArg(2, sizeof(cl_mem), &hashes);
|
||||
setArg(3, sizeof(cl_mem), &filtered_hashes);
|
||||
}
|
48
src/backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.h
Normal file
48
src/backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWT_FILTERKERNEL_H
|
||||
#define XMRIG_ASTROBWT_FILTERKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_FilterKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_FilterKernel(cl_program program) : OclKernel(program, "filter") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size);
|
||||
void setArgs(uint32_t nonce, uint32_t bwt_max_size, cl_mem hashes, cl_mem filtered_hashes);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWT_FILTERKERNEL_H */
|
|
@ -0,0 +1,47 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_FindSharesKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_FindSharesKernel::enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size)
|
||||
{
|
||||
enqueueNDRange(queue, 1, nullptr, &threads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_FindSharesKernel::setArgs(cl_mem hashes, cl_mem filtered_hashes, cl_mem shares)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &hashes);
|
||||
setArg(1, sizeof(cl_mem), &filtered_hashes);
|
||||
setArg(3, sizeof(cl_mem), &shares);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_FindSharesKernel::setTarget(uint64_t target)
|
||||
{
|
||||
setArg(2, sizeof(uint64_t), &target);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWTFINDSHARESKERNEL_H
|
||||
#define XMRIG_ASTROBWTFINDSHARESKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_FindSharesKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_FindSharesKernel(cl_program program) : OclKernel(program, "find_shares") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size);
|
||||
void setArgs(cl_mem hashes, cl_mem filtered_hashes, cl_mem shares);
|
||||
void setTarget(uint64_t target);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWTFINDSHARESKERNEL_H */
|
44
src/backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.cpp
Normal file
44
src/backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_MainKernel::enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size)
|
||||
{
|
||||
const size_t gthreads = threads * workgroup_size;
|
||||
enqueueNDRange(queue, 1, nullptr, >hreads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_MainKernel::setArgs(cl_mem inputs, cl_mem input_sizes, uint32_t input_stride, cl_mem indices, cl_mem tmp_indices)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &inputs);
|
||||
setArg(1, sizeof(cl_mem), &input_sizes);
|
||||
setArg(2, sizeof(uint32_t), &input_stride);
|
||||
setArg(3, sizeof(cl_mem), &indices);
|
||||
setArg(4, sizeof(cl_mem), &tmp_indices);
|
||||
}
|
48
src/backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.h
Normal file
48
src/backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWT_MAINKERNEL_H
|
||||
#define XMRIG_ASTROBWT_MAINKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_MainKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_MainKernel(cl_program program) : OclKernel(program, "BWT") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size);
|
||||
void setArgs(cl_mem inputs, cl_mem input_sizes, uint32_t input_stride, cl_mem indices, cl_mem tmp_indices);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWT_MAINKERNEL_H */
|
|
@ -0,0 +1,41 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_PrepareBatch2Kernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_PrepareBatch2Kernel::enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size)
|
||||
{
|
||||
enqueueNDRange(queue, 1, nullptr, &threads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_PrepareBatch2Kernel::setArgs(cl_mem hashes, cl_mem filtered_hashes, cl_mem bwt_data_sizes)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &hashes);
|
||||
setArg(1, sizeof(cl_mem), &filtered_hashes);
|
||||
setArg(2, sizeof(cl_mem), &bwt_data_sizes);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWT_PREPAREBATCH2KERNEL_H
|
||||
#define XMRIG_ASTROBWT_PREPAREBATCH2KERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_PrepareBatch2Kernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_PrepareBatch2Kernel(cl_program program) : OclKernel(program, "prepare_batch2") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size);
|
||||
void setArgs(cl_mem hashes, cl_mem filtered_hashes, cl_mem bwt_data_sizes);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWT_PREPAREBATCH2KERNEL_H */
|
|
@ -0,0 +1,44 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_SHA3InitialKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_SHA3InitialKernel::enqueue(cl_command_queue queue, size_t threads)
|
||||
{
|
||||
const size_t workgroup_size = 32;
|
||||
const size_t gthreads = threads * workgroup_size;
|
||||
enqueueNDRange(queue, 1, nullptr, >hreads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_SHA3InitialKernel::setArgs(cl_mem input, uint32_t input_size, uint32_t nonce, cl_mem output_salsa20_keys)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &input);
|
||||
setArg(1, sizeof(uint32_t), &input_size);
|
||||
setArg(2, sizeof(uint32_t), &nonce);
|
||||
setArg(3, sizeof(cl_mem), &output_salsa20_keys);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWT_SHA3INITIALKERNEL_H
|
||||
#define XMRIG_ASTROBWT_SHA3INITIALKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_SHA3InitialKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_SHA3InitialKernel(cl_program program) : OclKernel(program, "sha3_initial") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads);
|
||||
void setArgs(cl_mem input, uint32_t input_size, uint32_t nonce, cl_mem output_salsa20_keys);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWT_SHA3INITIALKERNEL_H */
|
44
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.cpp
Normal file
44
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_SHA3Kernel::enqueue(cl_command_queue queue, size_t threads)
|
||||
{
|
||||
const size_t workgroup_size = 32;
|
||||
const size_t gthreads = threads * workgroup_size;
|
||||
enqueueNDRange(queue, 1, nullptr, >hreads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_SHA3Kernel::setArgs(cl_mem inputs, cl_mem input_sizes, uint32_t input_stride, cl_mem output_salsa20_keys)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &inputs);
|
||||
setArg(1, sizeof(cl_mem), &input_sizes);
|
||||
setArg(2, sizeof(uint32_t), &input_stride);
|
||||
setArg(3, sizeof(cl_mem), &output_salsa20_keys);
|
||||
}
|
48
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.h
Normal file
48
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWT_SHA3KERNEL_H
|
||||
#define XMRIG_ASTROBWT_SHA3KERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_SHA3Kernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_SHA3Kernel(cl_program program) : OclKernel(program, "sha3") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads);
|
||||
void setArgs(cl_mem inputs, cl_mem input_sizes, uint32_t input_stride, cl_mem output_salsa20_keys);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWT_SHA3KERNEL_H */
|
|
@ -0,0 +1,43 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_Salsa20Kernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::AstroBWT_Salsa20Kernel::enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size)
|
||||
{
|
||||
const size_t gthreads = threads * workgroup_size;
|
||||
enqueueNDRange(queue, 1, nullptr, >hreads, &workgroup_size);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::AstroBWT_Salsa20Kernel::setArgs(cl_mem salsa20_keys, cl_mem outputs, cl_mem output_sizes, uint32_t output_stride)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &salsa20_keys);
|
||||
setArg(1, sizeof(cl_mem), &outputs);
|
||||
setArg(2, sizeof(cl_mem), &output_sizes);
|
||||
setArg(3, sizeof(uint32_t), &output_stride);
|
||||
}
|
48
src/backend/opencl/kernels/astrobwt/AstroBWT_Salsa20Kernel.h
Normal file
48
src/backend/opencl/kernels/astrobwt/AstroBWT_Salsa20Kernel.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASTROBWT_SALSA20KERNEL_H
|
||||
#define XMRIG_ASTROBWT_SALSA20KERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_Salsa20Kernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline AstroBWT_Salsa20Kernel(cl_program program) : OclKernel(program, "Salsa20_XORKeyStream") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads, size_t workgroup_size);
|
||||
void setArgs(cl_mem salsa20_keys, cl_mem outputs, cl_mem output_sizes, uint32_t output_stride);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_ASTROBWT_SALSA20KERNEL_H */
|
|
@ -100,6 +100,31 @@ if (WITH_OPENCL)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (WITH_ASTROBWT)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.h
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_FindSharesKernel.h
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.h
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_PrepareBatch2Kernel.h
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_Salsa20Kernel.h
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3InitialKernel.h
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.h
|
||||
src/backend/opencl/runners/OclAstroBWTRunner.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/generators/ocl_generic_astrobwt_generator.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_FindSharesKernel.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_PrepareBatch2Kernel.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_Salsa20Kernel.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3InitialKernel.cpp
|
||||
src/backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.cpp
|
||||
src/backend/opencl/runners/OclAstroBWTRunner.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.h
|
||||
|
|
218
src/backend/opencl/runners/OclAstroBWTRunner.cpp
Normal file
218
src/backend/opencl/runners/OclAstroBWTRunner.cpp
Normal file
|
@ -0,0 +1,218 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/runners/OclAstroBWTRunner.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_FindSharesKernel.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_MainKernel.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_PrepareBatch2Kernel.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_Salsa20Kernel.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_SHA3InitialKernel.h"
|
||||
#include "backend/opencl/kernels/astrobwt/AstroBWT_SHA3Kernel.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
constexpr int STAGE1_SIZE = 147253;
|
||||
constexpr uint32_t STAGE1_DATA_STRIDE = (STAGE1_SIZE + 256 + 255) & ~255U;
|
||||
constexpr uint32_t OclAstroBWTRunner::BWT_DATA_STRIDE;
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::OclAstroBWTRunner::OclAstroBWTRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
||||
{
|
||||
switch (data.device.type())
|
||||
{
|
||||
case OclDevice::Baffin:
|
||||
case OclDevice::Polaris:
|
||||
case OclDevice::Lexa:
|
||||
case OclDevice::Vega_10:
|
||||
case OclDevice::Vega_20:
|
||||
case OclDevice::Raven:
|
||||
m_workgroup_size = 64;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_workgroup_size = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
m_options += " -DSALSA20_GROUP_SIZE=" + std::to_string(m_workgroup_size);
|
||||
m_options += " -DBWT_GROUP_SIZE=" + std::to_string(m_workgroup_size);
|
||||
|
||||
m_bwt_allocation_size = static_cast<uint64_t>(m_intensity) * BWT_DATA_STRIDE;
|
||||
m_batch_size1 = static_cast<uint32_t>(m_bwt_allocation_size / STAGE1_DATA_STRIDE) & ~255U;
|
||||
|
||||
m_bwt_data_sizes_host = new uint32_t[m_batch_size1];
|
||||
}
|
||||
|
||||
|
||||
xmrig::OclAstroBWTRunner::~OclAstroBWTRunner()
|
||||
{
|
||||
delete m_sha3_initial_kernel;
|
||||
delete m_sha3_kernel;
|
||||
delete m_salsa20_kernel;
|
||||
delete m_bwt_kernel;
|
||||
delete m_filter_kernel;
|
||||
delete m_prepare_batch2_kernel;
|
||||
delete m_find_shares_kernel;
|
||||
|
||||
OclLib::release(m_salsa20_keys);
|
||||
OclLib::release(m_bwt_data);
|
||||
OclLib::release(m_bwt_data_sizes);
|
||||
OclLib::release(m_indices);
|
||||
OclLib::release(m_tmp_indices);
|
||||
OclLib::release(m_filtered_hashes);
|
||||
|
||||
delete m_bwt_data_sizes_host;
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::OclAstroBWTRunner::bufferSize() const
|
||||
{
|
||||
return OclBaseRunner::bufferSize() +
|
||||
align(m_batch_size1 * 32) + // m_salsa20_keys
|
||||
align(m_bwt_allocation_size) + // m_bwt_data
|
||||
align(m_batch_size1 * 4) + // m_bwt_data_sizes
|
||||
align(m_bwt_allocation_size * 8) + // m_indices
|
||||
align(m_bwt_allocation_size * 8) + // m_tmp_indices
|
||||
align((m_batch_size1 + m_intensity) * 36 + 4); // m_filtered_hashes
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclAstroBWTRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||
{
|
||||
m_sha3_initial_kernel->setArg(2, sizeof(nonce), &nonce);
|
||||
m_salsa20_kernel->setArg(3, sizeof(STAGE1_DATA_STRIDE), &STAGE1_DATA_STRIDE);
|
||||
m_bwt_kernel->setArg(2, sizeof(STAGE1_DATA_STRIDE), &STAGE1_DATA_STRIDE);
|
||||
|
||||
const uint32_t t = STAGE1_DATA_STRIDE * 8;
|
||||
m_sha3_kernel->setArg(2, sizeof(t), &t);
|
||||
m_filter_kernel->setArg(0, sizeof(nonce), &nonce);
|
||||
|
||||
const uint32_t zero = 0;
|
||||
enqueueWriteBuffer(m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(uint32_t), &zero);
|
||||
|
||||
m_sha3_initial_kernel->enqueue(m_queue, m_batch_size1);
|
||||
|
||||
for (uint32_t i = 0; i < m_batch_size1; ++i)
|
||||
m_bwt_data_sizes_host[i] = STAGE1_SIZE;
|
||||
|
||||
enqueueWriteBuffer(m_bwt_data_sizes, CL_FALSE, 0, m_batch_size1 * sizeof(uint32_t), m_bwt_data_sizes_host);
|
||||
|
||||
m_salsa20_kernel->enqueue(m_queue, m_batch_size1, m_workgroup_size);
|
||||
m_bwt_kernel->enqueue(m_queue, m_batch_size1, m_workgroup_size);
|
||||
m_sha3_kernel->enqueue(m_queue, m_batch_size1);
|
||||
m_filter_kernel->enqueue(m_queue, m_batch_size1, m_workgroup_size);
|
||||
|
||||
uint32_t num_filtered_hashes = 0;
|
||||
enqueueReadBuffer(m_filtered_hashes, CL_TRUE, 0, sizeof(num_filtered_hashes), &num_filtered_hashes);
|
||||
|
||||
m_processedHashes = 0;
|
||||
while (num_filtered_hashes >= m_intensity)
|
||||
{
|
||||
num_filtered_hashes -= m_intensity;
|
||||
m_processedHashes += m_intensity;
|
||||
|
||||
m_salsa20_kernel->setArg(3, sizeof(BWT_DATA_STRIDE), &BWT_DATA_STRIDE);
|
||||
m_bwt_kernel->setArg(2, sizeof(BWT_DATA_STRIDE), &BWT_DATA_STRIDE);
|
||||
|
||||
const uint32_t t = BWT_DATA_STRIDE * 8;
|
||||
m_sha3_kernel->setArg(2, sizeof(t), &t);
|
||||
|
||||
m_prepare_batch2_kernel->enqueue(m_queue, m_intensity, m_workgroup_size);
|
||||
m_salsa20_kernel->enqueue(m_queue, m_intensity, m_workgroup_size);
|
||||
m_bwt_kernel->enqueue(m_queue, m_intensity, m_workgroup_size);
|
||||
m_sha3_kernel->enqueue(m_queue, m_intensity);
|
||||
|
||||
m_find_shares_kernel->enqueue(m_queue, m_intensity, m_workgroup_size);
|
||||
|
||||
finalize(hashOutput);
|
||||
|
||||
OclLib::finish(m_queue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclAstroBWTRunner::set(const Job &job, uint8_t *blob)
|
||||
{
|
||||
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||
throw std::length_error("job size too big");
|
||||
}
|
||||
|
||||
if (job.size() < Job::kMaxBlobSize) {
|
||||
memset(blob + job.size(), 0, Job::kMaxBlobSize - job.size());
|
||||
}
|
||||
|
||||
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
|
||||
|
||||
m_sha3_initial_kernel->setArgs(m_input, static_cast<uint32_t>(job.size()), *job.nonce(), m_salsa20_keys);
|
||||
m_salsa20_kernel->setArgs(m_salsa20_keys, m_bwt_data, m_bwt_data_sizes, STAGE1_DATA_STRIDE);
|
||||
m_bwt_kernel->setArgs(m_bwt_data, m_bwt_data_sizes, STAGE1_DATA_STRIDE, m_indices, m_tmp_indices);
|
||||
m_sha3_kernel->setArgs(m_tmp_indices, m_bwt_data_sizes, STAGE1_DATA_STRIDE * 8, m_salsa20_keys);
|
||||
m_filter_kernel->setArgs(*job.nonce(), BWT_DATA_MAX_SIZE, m_salsa20_keys, m_filtered_hashes);
|
||||
m_prepare_batch2_kernel->setArgs(m_salsa20_keys, m_filtered_hashes, m_bwt_data_sizes);
|
||||
m_find_shares_kernel->setArgs(m_salsa20_keys, m_filtered_hashes, m_output);
|
||||
m_find_shares_kernel->setTarget(job.target());
|
||||
|
||||
const uint32_t zero = 0;
|
||||
enqueueWriteBuffer(m_filtered_hashes, CL_TRUE, 0, sizeof(uint32_t), &zero);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclAstroBWTRunner::build()
|
||||
{
|
||||
OclBaseRunner::build();
|
||||
|
||||
m_sha3_initial_kernel = new AstroBWT_SHA3InitialKernel(m_program);
|
||||
m_sha3_kernel = new AstroBWT_SHA3Kernel(m_program);
|
||||
m_salsa20_kernel = new AstroBWT_Salsa20Kernel(m_program);
|
||||
m_bwt_kernel = new AstroBWT_MainKernel(m_program);
|
||||
m_filter_kernel = new AstroBWT_FilterKernel(m_program);
|
||||
m_prepare_batch2_kernel = new AstroBWT_PrepareBatch2Kernel(m_program);
|
||||
m_find_shares_kernel = new AstroBWT_FindSharesKernel(m_program);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclAstroBWTRunner::init()
|
||||
{
|
||||
OclBaseRunner::init();
|
||||
|
||||
const cl_mem_flags f = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
|
||||
|
||||
m_salsa20_keys = createSubBuffer(f, m_batch_size1 * 32);
|
||||
m_bwt_data = createSubBuffer(f, m_bwt_allocation_size);
|
||||
m_bwt_data_sizes = createSubBuffer(CL_MEM_READ_WRITE | CL_MEM_HOST_WRITE_ONLY, m_batch_size1 * 4);
|
||||
m_indices = createSubBuffer(f, m_bwt_allocation_size * 8);
|
||||
m_tmp_indices = createSubBuffer(f, m_bwt_allocation_size * 8);
|
||||
m_filtered_hashes = createSubBuffer(CL_MEM_READ_WRITE, (m_batch_size1 + m_intensity) * 36 + 4);
|
||||
}
|
95
src/backend/opencl/runners/OclAstroBWTRunner.h
Normal file
95
src/backend/opencl/runners/OclAstroBWTRunner.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_OCLASTROBWTRUNNER_H
|
||||
#define XMRIG_OCLASTROBWTRUNNER_H
|
||||
|
||||
|
||||
#include "backend/opencl/runners/OclBaseRunner.h"
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AstroBWT_FilterKernel;
|
||||
class AstroBWT_MainKernel;
|
||||
class AstroBWT_PrepareBatch2Kernel;
|
||||
class AstroBWT_Salsa20Kernel;
|
||||
class AstroBWT_SHA3InitialKernel;
|
||||
class AstroBWT_SHA3Kernel;
|
||||
class AstroBWT_FindSharesKernel;
|
||||
|
||||
|
||||
class OclAstroBWTRunner : public OclBaseRunner
|
||||
{
|
||||
public:
|
||||
static constexpr uint32_t BWT_DATA_MAX_SIZE = 600 * 1024 - 256;
|
||||
static constexpr uint32_t BWT_DATA_STRIDE = (BWT_DATA_MAX_SIZE + 256 + 255) & ~255U;
|
||||
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclAstroBWTRunner)
|
||||
|
||||
OclAstroBWTRunner(size_t index, const OclLaunchData &data);
|
||||
~OclAstroBWTRunner() override;
|
||||
|
||||
inline uint32_t roundSize() const override { return m_batch_size1; }
|
||||
|
||||
// ~0.5% of all hashes are invalid
|
||||
inline uint32_t processedHashes() const override { return static_cast<uint32_t>(m_processedHashes * 0.995); }
|
||||
|
||||
protected:
|
||||
size_t bufferSize() const override;
|
||||
void run(uint32_t nonce, uint32_t *hashOutput) override;
|
||||
void set(const Job &job, uint8_t *blob) override;
|
||||
void build() override;
|
||||
void init() override;
|
||||
|
||||
private:
|
||||
AstroBWT_SHA3InitialKernel* m_sha3_initial_kernel = nullptr;
|
||||
AstroBWT_SHA3Kernel* m_sha3_kernel = nullptr;
|
||||
AstroBWT_Salsa20Kernel* m_salsa20_kernel = nullptr;
|
||||
AstroBWT_MainKernel* m_bwt_kernel = nullptr;
|
||||
AstroBWT_FilterKernel* m_filter_kernel = nullptr;
|
||||
AstroBWT_PrepareBatch2Kernel* m_prepare_batch2_kernel = nullptr;
|
||||
AstroBWT_FindSharesKernel* m_find_shares_kernel = nullptr;
|
||||
|
||||
|
||||
cl_mem m_salsa20_keys = nullptr;
|
||||
cl_mem m_bwt_data = nullptr;
|
||||
cl_mem m_bwt_data_sizes = nullptr;
|
||||
cl_mem m_indices = nullptr;
|
||||
cl_mem m_tmp_indices = nullptr;
|
||||
cl_mem m_filtered_hashes = nullptr;
|
||||
|
||||
uint32_t m_workgroup_size = 0;
|
||||
uint64_t m_bwt_allocation_size = 0;
|
||||
uint64_t m_batch_size1 = 0;
|
||||
uint32_t m_processedHashes = 0;
|
||||
|
||||
uint32_t* m_bwt_data_sizes_host = nullptr;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_OCLASTROBWTRUNNER_H
|
|
@ -57,6 +57,8 @@ protected:
|
|||
inline const OclLaunchData &data() const override { return m_data; }
|
||||
inline size_t intensity() const override { return m_intensity; }
|
||||
inline size_t threadId() const override { return m_threadId; }
|
||||
inline uint32_t roundSize() const override { return m_intensity; }
|
||||
inline uint32_t processedHashes() const override { return m_intensity; }
|
||||
|
||||
size_t bufferSize() const override;
|
||||
uint32_t deviceIndex() const override;
|
||||
|
|
|
@ -52,6 +52,10 @@ namespace xmrig {
|
|||
extern bool ocl_generic_rx_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
extern bool ocl_generic_astrobwt_generator(const OclDevice& device, const Algorithm& algorithm, OclThreads& threads);
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
extern bool ocl_generic_cn_gpu_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||
#endif
|
||||
|
@ -64,6 +68,9 @@ static ocl_gen_config_fun generators[] = {
|
|||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
ocl_generic_rx_generator,
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
ocl_generic_astrobwt_generator,
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
ocl_generic_cn_gpu_generator,
|
||||
# endif
|
||||
|
|
|
@ -29,12 +29,18 @@
|
|||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpApiResponse.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpServer.h"
|
||||
#include "base/net/tools/TcpServer.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
# include "base/net/https/HttpsServer.h"
|
||||
#else
|
||||
# include "base/net/http/HttpServer.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const char *kAuthorization = "authorization";
|
||||
|
@ -48,10 +54,7 @@ static size_t faviconSize = 0;
|
|||
|
||||
|
||||
xmrig::Httpd::Httpd(Base *base) :
|
||||
m_base(base),
|
||||
m_http(nullptr),
|
||||
m_server(nullptr),
|
||||
m_port(0)
|
||||
m_base(base)
|
||||
{
|
||||
m_httpListener = std::make_shared<HttpListener>(this);
|
||||
|
||||
|
@ -64,18 +67,27 @@ xmrig::Httpd::~Httpd() = default;
|
|||
|
||||
bool xmrig::Httpd::start()
|
||||
{
|
||||
const Http &config = m_base->config()->http();
|
||||
const auto &config = m_base->config()->http();
|
||||
|
||||
if (!config.isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
m_http = new HttpServer(m_httpListener);
|
||||
bool tls = false;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
m_http = new HttpsServer(m_httpListener);
|
||||
tls = m_http->setTls(m_base->config()->tls());
|
||||
# else
|
||||
m_http = new HttpServer(m_httpListener);
|
||||
# endif
|
||||
|
||||
m_server = new TcpServer(config.host(), config.port(), m_http);
|
||||
|
||||
const int rc = m_server->bind();
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") BLUE_BOLD("%s:%d") " " RED_BOLD("%s"),
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CSI "1;%dm%s:%d" " " RED_BOLD("%s"),
|
||||
"HTTP API",
|
||||
tls ? 32 : 36,
|
||||
config.host().data(),
|
||||
rc < 0 ? config.port() : rc,
|
||||
rc < 0 ? uv_strerror(rc) : ""
|
||||
|
@ -143,7 +155,7 @@ void xmrig::Httpd::onHttpData(const HttpData &data)
|
|||
}
|
||||
# endif
|
||||
|
||||
return HttpResponse(data.id(), 404).end();
|
||||
return HttpResponse(data.id(), HTTP_STATUS_NOT_FOUND).end();
|
||||
}
|
||||
|
||||
if (data.method > 4) {
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace xmrig {
|
|||
|
||||
class Base;
|
||||
class HttpServer;
|
||||
class HttpsServer;
|
||||
class TcpServer;
|
||||
|
||||
|
||||
|
@ -61,11 +62,16 @@ protected:
|
|||
private:
|
||||
int auth(const HttpData &req) const;
|
||||
|
||||
Base *m_base;
|
||||
HttpServer *m_http;
|
||||
const Base *m_base;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
TcpServer *m_server;
|
||||
uint16_t m_port;
|
||||
TcpServer *m_server = nullptr;
|
||||
uint16_t m_port = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
HttpsServer *m_http = nullptr;
|
||||
# else
|
||||
HttpServer *m_http = nullptr;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,9 @@ set(HEADERS_BASE
|
|||
src/base/net/stratum/strategies/StrategyProxy.h
|
||||
src/base/net/stratum/SubmitResult.h
|
||||
src/base/net/stratum/Url.h
|
||||
src/base/net/tools/RecvBuf.h
|
||||
src/base/net/tools/LineReader.h
|
||||
src/base/net/tools/MemPool.h
|
||||
src/base/net/tools/NetBuffer.h
|
||||
src/base/net/tools/Storage.h
|
||||
src/base/tools/Arguments.h
|
||||
src/base/tools/Baton.h
|
||||
|
@ -99,6 +101,8 @@ set(SOURCES_BASE
|
|||
src/base/net/stratum/strategies/FailoverStrategy.cpp
|
||||
src/base/net/stratum/strategies/SinglePoolStrategy.cpp
|
||||
src/base/net/stratum/Url.cpp
|
||||
src/base/net/tools/LineReader.cpp
|
||||
src/base/net/tools/NetBuffer.cpp
|
||||
src/base/tools/Arguments.cpp
|
||||
src/base/tools/Buffer.cpp
|
||||
src/base/tools/String.cpp
|
||||
|
@ -157,7 +161,6 @@ if (WITH_HTTP)
|
|||
src/base/net/http/HttpContext.h
|
||||
src/base/net/http/HttpData.h
|
||||
src/base/net/http/HttpResponse.h
|
||||
src/base/net/http/HttpServer.h
|
||||
src/base/net/stratum/DaemonClient.h
|
||||
src/base/net/stratum/SelfSelectClient.h
|
||||
src/base/net/tools/TcpServer.h
|
||||
|
@ -176,7 +179,6 @@ if (WITH_HTTP)
|
|||
src/base/net/http/HttpData.cpp
|
||||
src/base/net/http/HttpListener.cpp
|
||||
src/base/net/http/HttpResponse.cpp
|
||||
src/base/net/http/HttpServer.cpp
|
||||
src/base/net/stratum/DaemonClient.cpp
|
||||
src/base/net/stratum/SelfSelectClient.cpp
|
||||
src/base/net/tools/TcpServer.cpp
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,16 +27,17 @@
|
|||
#include <memory>
|
||||
|
||||
|
||||
#include "base/kernel/Base.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/io/json/JsonChain.h"
|
||||
#include "base/io/log/backends/ConsoleLog.h"
|
||||
#include "base/io/log/backends/FileLog.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/Watcher.h"
|
||||
#include "base/kernel/Base.h"
|
||||
#include "base/kernel/interfaces/IBaseListener.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/kernel/Process.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/config/ConfigTransform.h"
|
||||
|
||||
|
@ -84,6 +85,8 @@ public:
|
|||
|
||||
delete config;
|
||||
delete watcher;
|
||||
|
||||
NetBuffer::destroy();
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +130,7 @@ private:
|
|||
return config.release();
|
||||
}
|
||||
|
||||
chain.addFile(Process::location(Process::ExeLocation, "config.json"));
|
||||
chain.addFile(Process::location(Process::DataLocation, "config.json"));
|
||||
|
||||
if (read(chain, config)) {
|
||||
return config.release();
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -56,9 +56,13 @@ static std::map<String, String> variables;
|
|||
|
||||
static void createVariables()
|
||||
{
|
||||
variables.insert({ "XMRIG_VERSION", APP_VERSION });
|
||||
variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation, "") });
|
||||
variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation, "") });
|
||||
variables.insert({ "XMRIG_VERSION", APP_VERSION });
|
||||
variables.insert({ "XMRIG_EXE", Process::exepath() });
|
||||
variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation) });
|
||||
variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation) });
|
||||
variables.insert({ "XMRIG_HOME_DIR", Process::location(Process::HomeLocation) });
|
||||
variables.insert({ "XMRIG_TEMP_DIR", Process::location(Process::TempLocation) });
|
||||
variables.insert({ "XMRIG_DATA_DIR", Process::location(Process::DataLocation) });
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,6 +24,7 @@
|
|||
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
|
@ -34,20 +35,75 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
static size_t getLocation(Process::Location location, char *buf, size_t max)
|
||||
{
|
||||
using namespace xmrig;
|
||||
static char pathBuf[520];
|
||||
static std::string dataDir;
|
||||
|
||||
|
||||
static std::string getPath(Process::Location location)
|
||||
{
|
||||
size_t size = sizeof(pathBuf);
|
||||
|
||||
if (location == Process::DataLocation) {
|
||||
if (!dataDir.empty()) {
|
||||
return dataDir;
|
||||
}
|
||||
|
||||
location = Process::ExeLocation;
|
||||
}
|
||||
|
||||
if (location == Process::HomeLocation) {
|
||||
# if UV_VERSION_HEX >= 0x010600
|
||||
return uv_os_homedir(pathBuf, &size) < 0 ? "" : std::string(pathBuf, size);
|
||||
# else
|
||||
location = Process::ExeLocation;
|
||||
# endif
|
||||
}
|
||||
|
||||
if (location == Process::TempLocation) {
|
||||
# if UV_VERSION_HEX >= 0x010900
|
||||
return uv_os_tmpdir(pathBuf, &size) < 0 ? "" : std::string(pathBuf, size);
|
||||
# else
|
||||
location = Process::ExeLocation;
|
||||
# endif
|
||||
}
|
||||
|
||||
size_t size = max;
|
||||
if (location == Process::ExeLocation) {
|
||||
return uv_exepath(buf, &size) < 0 ? 0 : size;
|
||||
if (uv_exepath(pathBuf, &size) < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto path = std::string(pathBuf, size);
|
||||
const auto pos = path.rfind(Process::kDirSeparator);
|
||||
|
||||
if (pos != std::string::npos) {
|
||||
return path.substr(0, pos);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
if (location == Process::CwdLocation) {
|
||||
return uv_cwd(buf, &size) < 0 ? 0 : size;
|
||||
return uv_cwd(pathBuf, &size) < 0 ? "" : std::string(pathBuf, size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
static void setDataDir(const char *path)
|
||||
{
|
||||
if (path == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string dir = path;
|
||||
if (!dir.empty() && (dir.back() == '/' || dir.back() == '\\')) {
|
||||
dir.pop_back();
|
||||
}
|
||||
|
||||
if (!dir.empty() && uv_chdir(dir.c_str()) == 0) {
|
||||
dataDir = dir;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,46 +114,25 @@ xmrig::Process::Process(int argc, char **argv) :
|
|||
m_arguments(argc, argv)
|
||||
{
|
||||
srand(static_cast<unsigned int>(Chrono::currentMSecsSinceEpoch() ^ reinterpret_cast<uintptr_t>(this)));
|
||||
|
||||
setDataDir(m_arguments.value("--data-dir"));
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Process::exepath()
|
||||
{
|
||||
size_t size = sizeof(pathBuf);
|
||||
|
||||
return uv_exepath(pathBuf, &size) < 0 ? "" : String(pathBuf, size);
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Process::location(Location location, const char *fileName)
|
||||
{
|
||||
constexpr const size_t max = 520;
|
||||
|
||||
char *buf = new char[max]();
|
||||
size_t size = getLocation(location, buf, max);
|
||||
|
||||
if (size == 0) {
|
||||
delete [] buf;
|
||||
|
||||
return String();
|
||||
auto path = getPath(location);
|
||||
if (path.empty() || fileName == nullptr) {
|
||||
return path.c_str();
|
||||
}
|
||||
|
||||
if (fileName == nullptr) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
if (location == ExeLocation) {
|
||||
char *p = strrchr(buf, kDirSeparator);
|
||||
|
||||
if (p == nullptr) {
|
||||
delete [] buf;
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
size = static_cast<size_t>(p - buf);
|
||||
}
|
||||
|
||||
if ((size + strlen(fileName) + 2) >= max) {
|
||||
delete [] buf;
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
buf[size] = kDirSeparator;
|
||||
strcpy(buf + size + 1, fileName);
|
||||
|
||||
return buf;
|
||||
return (path + kDirSeparator + fileName).c_str();
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -37,7 +37,10 @@ class Process
|
|||
public:
|
||||
enum Location {
|
||||
ExeLocation,
|
||||
CwdLocation
|
||||
CwdLocation,
|
||||
DataLocation,
|
||||
HomeLocation,
|
||||
TempLocation
|
||||
};
|
||||
|
||||
# ifdef WIN32
|
||||
|
@ -48,6 +51,7 @@ public:
|
|||
|
||||
Process(int argc, char **argv);
|
||||
|
||||
static String exepath();
|
||||
static String location(Location location, const char *fileName = nullptr);
|
||||
|
||||
inline const Arguments &arguments() const { return m_arguments; }
|
||||
|
|
|
@ -66,6 +66,11 @@ const char *BaseConfig::kVerbose = "verbose";
|
|||
const char *BaseConfig::kWatch = "watch";
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
const char *BaseConfig::kTls = "tls";
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -87,11 +92,16 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
|
||||
m_rebenchAlgo = reader.getBool("rebench-algo", m_rebenchAlgo);
|
||||
m_benchAlgoTime = reader.getInt("bench-algo-time", m_benchAlgoTime);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
m_tls = reader.getValue(kTls);
|
||||
# endif
|
||||
|
||||
Log::setColors(reader.getBool(kColors, Log::isColors()));
|
||||
setPrintTime(reader.getUint(kPrintTime, 60));
|
||||
setVerbose(reader.getValue(kVerbose));
|
||||
|
||||
const rapidjson::Value &api = reader.getObject(kApi);
|
||||
const auto &api = reader.getObject(kApi);
|
||||
if (api.IsObject()) {
|
||||
m_apiId = Json::getString(api, kApiId);
|
||||
m_apiWorkerId = Json::getString(api, kApiWorkerId);
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
#include "base/net/stratum/Pools.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
# include "base/net/tls/TlsConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -55,26 +60,34 @@ public:
|
|||
static const char *kVerbose;
|
||||
static const char *kWatch;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
static const char *kTls;
|
||||
# endif
|
||||
|
||||
BaseConfig() = default;
|
||||
|
||||
inline bool isAutoSave() const { return m_autoSave; }
|
||||
inline bool isBackground() const { return m_background; }
|
||||
inline bool isDryRun() const { return m_dryRun; }
|
||||
inline bool isSyslog() const { return m_syslog; }
|
||||
inline const char *logFile() const { return m_logFile.data(); }
|
||||
inline const char *userAgent() const { return m_userAgent.data(); }
|
||||
inline const Http &http() const { return m_http; }
|
||||
inline const Pools &pools() const { return m_pools; }
|
||||
inline const String &apiId() const { return m_apiId; }
|
||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||
inline uint32_t printTime() const { return m_printTime; }
|
||||
inline bool isAutoSave() const { return m_autoSave; }
|
||||
inline bool isBackground() const { return m_background; }
|
||||
inline bool isDryRun() const { return m_dryRun; }
|
||||
inline bool isSyslog() const { return m_syslog; }
|
||||
inline const char *logFile() const { return m_logFile.data(); }
|
||||
inline const char *userAgent() const { return m_userAgent.data(); }
|
||||
inline const Http &http() const { return m_http; }
|
||||
inline const Pools &pools() const { return m_pools; }
|
||||
inline const String &apiId() const { return m_apiId; }
|
||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||
inline uint32_t printTime() const { return m_printTime; }
|
||||
|
||||
inline bool isRebenchAlgo() const { return m_rebenchAlgo; }
|
||||
inline int benchAlgoTime() const { return m_benchAlgoTime; }
|
||||
inline bool isRebenchAlgo() const { return m_rebenchAlgo; }
|
||||
inline int benchAlgoTime() const { return m_benchAlgoTime; }
|
||||
|
||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const String &fileName() const override { return m_fileName; }
|
||||
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
inline const TlsConfig &tls() const { return m_tls; }
|
||||
# endif
|
||||
|
||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const String &fileName() const override { return m_fileName; }
|
||||
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
||||
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
bool save() override;
|
||||
|
@ -100,6 +113,10 @@ protected:
|
|||
bool m_rebenchAlgo = false;
|
||||
int m_benchAlgoTime = 10;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
TlsConfig m_tls;
|
||||
# endif
|
||||
|
||||
private:
|
||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
#include "core/config/Config_platform.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
# include "base/net/tls/TlsConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTransform &transform)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
@ -199,6 +204,29 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
case IConfig::UserAgentKey: /* --user-agent */
|
||||
return set(doc, BaseConfig::kUserAgent, arg);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
case IConfig::TlsCertKey: /* --tls-cert */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCert, arg);
|
||||
|
||||
case IConfig::TlsCertKeyKey: /* --tls-cert-key */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCertKey, arg);
|
||||
|
||||
case IConfig::TlsDHparamKey: /* --tls-dhparam */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kDhparam, arg);
|
||||
|
||||
case IConfig::TlsCiphersKey: /* --tls-ciphers */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCiphers, arg);
|
||||
|
||||
case IConfig::TlsCipherSuitesKey: /* --tls-ciphersuites */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCipherSuites, arg);
|
||||
|
||||
case IConfig::TlsProtocolsKey: /* --tls-protocols */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kProtocols, arg);
|
||||
|
||||
case IConfig::TlsGenKey: /* --tls-gen */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kGen, arg);
|
||||
# endif
|
||||
|
||||
case IConfig::RetriesKey: /* --retries */
|
||||
case IConfig::RetryPauseKey: /* --retry-pause */
|
||||
case IConfig::PrintTimeKey: /* --print-time */
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
DaemonKey = 1018,
|
||||
DaemonPollKey = 1019,
|
||||
SelfSelectKey = 1028,
|
||||
DataDirKey = 1035,
|
||||
|
||||
// xmrig common
|
||||
CPUPriorityKey = 1021,
|
||||
|
@ -100,6 +101,7 @@ public:
|
|||
MemoryPoolKey = 1027,
|
||||
YieldKey = 1030,
|
||||
AstroBWTMaxSizeKey = 1034,
|
||||
AstroBWTAVX2Key = 1036,
|
||||
|
||||
// xmrig amd
|
||||
OclPlatformKey = 1400,
|
||||
|
@ -133,6 +135,7 @@ public:
|
|||
TlsCiphersKey = 1112,
|
||||
TlsCipherSuitesKey = 1113,
|
||||
TlsProtocolsKey = 1114,
|
||||
TlsGenKey = 1117,
|
||||
AlgoExtKey = 1115,
|
||||
ProxyPasswordKey = 1116,
|
||||
LoginFileKey = 'L',
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -26,15 +26,12 @@
|
|||
#define XMRIG_ILINELISTENER_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class String;
|
||||
|
||||
|
||||
class ILineListener
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
# include "base/net/http/HttpsClient.h"
|
||||
# include "base/net/https/HttpsClient.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/tools/Baton.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
@ -41,31 +41,6 @@ namespace xmrig {
|
|||
static const char *kCRLF = "\r\n";
|
||||
|
||||
|
||||
class HttpClientWriteBaton : public Baton<uv_write_t>
|
||||
{
|
||||
public:
|
||||
inline HttpClientWriteBaton(const std::string &header, std::string &&body) :
|
||||
m_body(std::move(body)),
|
||||
m_header(header)
|
||||
{
|
||||
m_bufs[0] = uv_buf_init(const_cast<char *>(m_header.c_str()), m_header.size());
|
||||
m_bufs[1] = m_body.empty() ? uv_buf_init(nullptr, 0) : uv_buf_init(const_cast<char *>(m_body.c_str()), m_body.size());
|
||||
}
|
||||
|
||||
void write(uv_stream_t *stream)
|
||||
{
|
||||
uv_write(&req, stream, m_bufs, nbufs(), [](uv_write_t *req, int) { delete reinterpret_cast<HttpClientWriteBaton *>(req->data); });
|
||||
}
|
||||
|
||||
private:
|
||||
inline size_t nbufs() const { return m_bufs[1].len > 0 ? 2 : 1; }
|
||||
|
||||
std::string m_body;
|
||||
std::string m_header;
|
||||
uv_buf_t m_bufs[2]{};
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -137,7 +112,8 @@ void xmrig::HttpClient::handshake()
|
|||
|
||||
headers.clear();
|
||||
|
||||
write(ss.str());
|
||||
body.insert(0, ss.str());
|
||||
write(std::move(body), false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,13 +125,6 @@ void xmrig::HttpClient::read(const char *data, size_t size)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::HttpClient::write(const std::string &header)
|
||||
{
|
||||
auto baton = new HttpClientWriteBaton(header, std::move(body));
|
||||
baton->write(stream());
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
|
||||
{
|
||||
auto client = static_cast<HttpClient *>(req->data);
|
||||
|
@ -174,12 +143,7 @@ void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
|
|||
return;
|
||||
}
|
||||
|
||||
uv_read_start(client->stream(),
|
||||
[](uv_handle_t *, size_t suggested_size, uv_buf_t *buf)
|
||||
{
|
||||
buf->base = new char[suggested_size];
|
||||
buf->len = suggested_size;
|
||||
},
|
||||
uv_read_start(client->stream(), NetBuffer::onAlloc,
|
||||
[](uv_stream_t *tcp, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
auto client = static_cast<HttpClient*>(tcp->data);
|
||||
|
@ -194,7 +158,7 @@ void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
|
|||
client->close(static_cast<int>(nread));
|
||||
}
|
||||
|
||||
delete [] buf->base;
|
||||
NetBuffer::release(buf);
|
||||
});
|
||||
|
||||
client->handshake();
|
||||
|
|
|
@ -59,7 +59,6 @@ protected:
|
|||
|
||||
virtual void handshake();
|
||||
virtual void read(const char *data, size_t size);
|
||||
virtual void write(const std::string &header);
|
||||
|
||||
protected:
|
||||
inline const FetchRequest &req() const { return m_req; }
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "base/net/http/HttpContext.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/tools/Baton.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
|
@ -42,6 +43,37 @@ static std::map<uint64_t, HttpContext *> storage;
|
|||
static uint64_t SEQUENCE = 0;
|
||||
|
||||
|
||||
class HttpWriteBaton : public Baton<uv_write_t>
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpWriteBaton)
|
||||
|
||||
inline HttpWriteBaton(std::string &&body, HttpContext *ctx) :
|
||||
m_ctx(ctx),
|
||||
m_body(std::move(body))
|
||||
{
|
||||
m_buf = uv_buf_init(const_cast<char *>(m_body.c_str()), m_body.size());
|
||||
}
|
||||
|
||||
inline ~HttpWriteBaton()
|
||||
{
|
||||
if (m_ctx) {
|
||||
m_ctx->close();
|
||||
}
|
||||
}
|
||||
|
||||
void write(uv_stream_t *stream)
|
||||
{
|
||||
uv_write(&req, stream, &m_buf, 1, [](uv_write_t *req, int) { delete reinterpret_cast<HttpWriteBaton *>(req->data); });
|
||||
}
|
||||
|
||||
private:
|
||||
HttpContext *m_ctx;
|
||||
std::string m_body;
|
||||
uv_buf_t m_buf{};
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -75,6 +107,17 @@ xmrig::HttpContext::~HttpContext()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::HttpContext::write(std::string &&data, bool close)
|
||||
{
|
||||
if (uv_is_writable(stream()) != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto baton = new HttpWriteBaton(std::move(data), close ? this : nullptr);
|
||||
baton->write(stream());
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::HttpContext::isRequest() const
|
||||
{
|
||||
return m_parser->type == HTTP_REQUEST;
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
inline const char *tlsVersion() const override { return nullptr; }
|
||||
inline uint16_t port() const override { return 0; }
|
||||
|
||||
void write(std::string &&data, bool close) override;
|
||||
|
||||
bool isRequest() const override;
|
||||
size_t parse(const char *data, size_t size);
|
||||
std::string ip() const override;
|
||||
|
|
|
@ -53,12 +53,13 @@ public:
|
|||
|
||||
inline uint64_t id() const { return m_id; }
|
||||
|
||||
virtual bool isRequest() const = 0;
|
||||
virtual const char *host() const = 0;
|
||||
virtual const char *tlsFingerprint() const = 0;
|
||||
virtual const char *tlsVersion() const = 0;
|
||||
virtual std::string ip() const = 0;
|
||||
virtual uint16_t port() const = 0;
|
||||
virtual bool isRequest() const = 0;
|
||||
virtual const char *host() const = 0;
|
||||
virtual const char *tlsFingerprint() const = 0;
|
||||
virtual const char *tlsVersion() const = 0;
|
||||
virtual std::string ip() const = 0;
|
||||
virtual uint16_t port() const = 0;
|
||||
virtual void write(std::string &&data, bool close) = 0;
|
||||
|
||||
int method = 0;
|
||||
int status = 0;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -28,8 +28,6 @@
|
|||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "base/tools/Baton.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
|
@ -45,52 +43,6 @@ static const char *kCRLF = "\r\n";
|
|||
static const char *kUserAgent = "user-agent";
|
||||
|
||||
|
||||
class WriteBaton : public Baton<uv_write_t>
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(WriteBaton)
|
||||
|
||||
inline WriteBaton(const std::stringstream &ss, const char *data, size_t size, HttpContext *ctx) :
|
||||
m_ctx(ctx),
|
||||
m_header(ss.str())
|
||||
{
|
||||
bufs[0].len = m_header.size();
|
||||
bufs[0].base = const_cast<char *>(m_header.c_str());
|
||||
|
||||
if (data) {
|
||||
bufs[1].len = size;
|
||||
bufs[1].base = new char[size];
|
||||
memcpy(bufs[1].base, data, size);
|
||||
}
|
||||
else {
|
||||
bufs[1].base = nullptr;
|
||||
bufs[1].len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline ~WriteBaton()
|
||||
{
|
||||
if (count() == 2) {
|
||||
delete [] bufs[1].base;
|
||||
}
|
||||
|
||||
m_ctx->close();
|
||||
}
|
||||
|
||||
|
||||
inline size_t count() const { return bufs[1].base == nullptr ? 1 : 2; }
|
||||
inline size_t size() const { return bufs[0].len + bufs[1].len; }
|
||||
inline static void onWrite(uv_write_t *req, int) { delete reinterpret_cast<WriteBaton *>(req->data); }
|
||||
|
||||
|
||||
uv_buf_t bufs[2]{};
|
||||
|
||||
private:
|
||||
HttpContext *m_ctx;
|
||||
std::string m_header;
|
||||
};
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -134,8 +86,8 @@ void xmrig::HttpResponse::end(const char *data, size_t size)
|
|||
|
||||
ss << kCRLF;
|
||||
|
||||
auto ctx = HttpContext::get(m_id);
|
||||
auto baton = new WriteBaton(ss, data, size, ctx);
|
||||
auto ctx = HttpContext::get(m_id);
|
||||
std::string body = data ? (ss.str() + std::string(data, size)) : ss.str();
|
||||
|
||||
# ifndef APP_DEBUG
|
||||
if (statusCode() >= 400)
|
||||
|
@ -149,11 +101,11 @@ void xmrig::HttpResponse::end(const char *data, size_t size)
|
|||
ctx->url.c_str(),
|
||||
err ? 31 : 32,
|
||||
statusCode(),
|
||||
baton->size(),
|
||||
body.size(),
|
||||
ctx->elapsed(),
|
||||
ctx->headers.count(kUserAgent) ? ctx->headers.at(kUserAgent).c_str() : nullptr
|
||||
);
|
||||
}
|
||||
|
||||
uv_write(&baton->req, ctx->stream(), baton->bufs, baton->count(), WriteBaton::onWrite);
|
||||
ctx->write(std::move(body), true);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -28,11 +28,10 @@
|
|||
#include <uv.h>
|
||||
|
||||
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "base/net/http/HttpResponse.h"
|
||||
#include "base/net/http/HttpServer.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
|
||||
|
||||
xmrig::HttpServer::HttpServer(const std::shared_ptr<IHttpListener> &listener) :
|
||||
|
@ -52,17 +51,7 @@ void xmrig::HttpServer::onConnection(uv_stream_t *stream, uint16_t)
|
|||
auto ctx = new HttpContext(HTTP_REQUEST, m_listener);
|
||||
uv_accept(stream, ctx->stream());
|
||||
|
||||
uv_read_start(ctx->stream(),
|
||||
[](uv_handle_t *, size_t suggested_size, uv_buf_t *buf)
|
||||
{
|
||||
buf->base = new char[suggested_size];
|
||||
|
||||
# ifdef _WIN32
|
||||
buf->len = static_cast<unsigned int>(suggested_size);
|
||||
# else
|
||||
buf->len = suggested_size;
|
||||
# endif
|
||||
},
|
||||
uv_read_start(ctx->stream(), NetBuffer::onAlloc,
|
||||
[](uv_stream_t *tcp, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
auto ctx = static_cast<HttpContext*>(tcp->data);
|
||||
|
@ -78,6 +67,6 @@ void xmrig::HttpServer::onConnection(uv_stream_t *stream, uint16_t)
|
|||
ctx->close();
|
||||
}
|
||||
|
||||
delete [] buf->base;
|
||||
NetBuffer::release(buf);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/net/http/HttpsClient.h"
|
||||
#include "base/net/https/HttpsClient.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
|
||||
|
@ -49,8 +49,8 @@ xmrig::HttpsClient::HttpsClient(FetchRequest &&req, const std::weak_ptr<IHttpLis
|
|||
return;
|
||||
}
|
||||
|
||||
m_writeBio = BIO_new(BIO_s_mem());
|
||||
m_readBio = BIO_new(BIO_s_mem());
|
||||
m_write = BIO_new(BIO_s_mem());
|
||||
m_read = BIO_new(BIO_s_mem());
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
|
||||
}
|
||||
|
||||
|
@ -89,24 +89,24 @@ void xmrig::HttpsClient::handshake()
|
|||
}
|
||||
|
||||
SSL_set_connect_state(m_ssl);
|
||||
SSL_set_bio(m_ssl, m_readBio, m_writeBio);
|
||||
SSL_set_bio(m_ssl, m_read, m_write);
|
||||
SSL_set_tlsext_host_name(m_ssl, host());
|
||||
|
||||
SSL_do_handshake(m_ssl);
|
||||
|
||||
flush();
|
||||
flush(false);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsClient::read(const char *data, size_t size)
|
||||
{
|
||||
BIO_write(m_readBio, data, size);
|
||||
BIO_write(m_read, data, size);
|
||||
|
||||
if (!SSL_is_init_finished(m_ssl)) {
|
||||
const int rc = SSL_connect(m_ssl);
|
||||
|
||||
if (rc < 0 && SSL_get_error(m_ssl, rc) == SSL_ERROR_WANT_READ) {
|
||||
flush();
|
||||
flush(false);
|
||||
} else if (rc == 1) {
|
||||
X509 *cert = SSL_get_peer_certificate(m_ssl);
|
||||
if (!verify(cert)) {
|
||||
|
@ -123,19 +123,25 @@ void xmrig::HttpsClient::read(const char *data, size_t size)
|
|||
return;
|
||||
}
|
||||
|
||||
int bytes_read = 0;
|
||||
while ((bytes_read = SSL_read(m_ssl, m_buf, sizeof(m_buf))) > 0) {
|
||||
HttpClient::read(m_buf, static_cast<size_t>(bytes_read));
|
||||
static char buf[16384]{};
|
||||
|
||||
int rc = 0;
|
||||
while ((rc = SSL_read(m_ssl, buf, sizeof(buf))) > 0) {
|
||||
HttpClient::read(buf, static_cast<size_t>(rc));
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
close(UV_EOF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsClient::write(const std::string &header)
|
||||
void xmrig::HttpsClient::write(std::string &&data, bool close)
|
||||
{
|
||||
SSL_write(m_ssl, (header + body).c_str(), header.size() + body.size());
|
||||
body.clear();
|
||||
const std::string body = std::move(data);
|
||||
SSL_write(m_ssl, body.data(), body.size());
|
||||
|
||||
flush();
|
||||
flush(close);
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,23 +188,17 @@ bool xmrig::HttpsClient::verifyFingerprint(X509 *cert)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::HttpsClient::flush()
|
||||
void xmrig::HttpsClient::flush(bool close)
|
||||
{
|
||||
uv_buf_t buf;
|
||||
buf.len = BIO_get_mem_data(m_writeBio, &buf.base);
|
||||
|
||||
if (buf.len == 0) {
|
||||
if (uv_is_writable(stream()) != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
if (uv_is_writable(stream())) {
|
||||
result = uv_try_write(stream(), &buf, 1) == static_cast<int>(buf.len);
|
||||
char *data = nullptr;
|
||||
const size_t size = BIO_get_mem_data(m_write, &data);
|
||||
std::string body(data, size);
|
||||
|
||||
if (!result) {
|
||||
close(UV_EIO);
|
||||
}
|
||||
}
|
||||
(void) BIO_reset(m_write);
|
||||
|
||||
(void) BIO_reset(m_writeBio);
|
||||
HttpContext::write(std::move(body), close);
|
||||
}
|
|
@ -55,17 +55,17 @@ public:
|
|||
protected:
|
||||
void handshake() override;
|
||||
void read(const char *data, size_t size) override;
|
||||
void write(const std::string &header) override;
|
||||
|
||||
private:
|
||||
void write(std::string &&data, bool close) override;
|
||||
|
||||
bool verify(X509 *cert);
|
||||
bool verifyFingerprint(X509 *cert);
|
||||
void flush();
|
||||
void flush(bool close);
|
||||
|
||||
BIO *m_readBio = nullptr;
|
||||
BIO *m_writeBio = nullptr;
|
||||
BIO *m_read = nullptr;
|
||||
BIO *m_write = nullptr;
|
||||
bool m_ready = false;
|
||||
char m_buf[1024 * 2]{};
|
||||
char m_fingerprint[32 * 2 + 8]{};
|
||||
SSL *m_ssl = nullptr;
|
||||
SSL_CTX *m_ctx = nullptr;
|
99
src/base/net/https/HttpsContext.cpp
Normal file
99
src/base/net/https/HttpsContext.cpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/https/HttpsContext.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/net/tls/TlsContext.h"
|
||||
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
xmrig::HttpsContext::HttpsContext(TlsContext *tls, const std::weak_ptr<IHttpListener> &listener) :
|
||||
HttpContext(HTTP_REQUEST, listener),
|
||||
ServerTls(tls ? tls->ctx() : nullptr)
|
||||
{
|
||||
if (!tls) {
|
||||
m_mode = TLS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::HttpsContext::~HttpsContext() = default;
|
||||
|
||||
|
||||
void xmrig::HttpsContext::append(char *data, size_t size)
|
||||
{
|
||||
if (m_mode == TLS_AUTO) {
|
||||
m_mode = isTLS(data, size) ? TLS_ON : TLS_OFF;
|
||||
}
|
||||
|
||||
if (m_mode == TLS_ON) {
|
||||
read(data, size);
|
||||
}
|
||||
else {
|
||||
parse(data, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::HttpsContext::write(BIO *bio)
|
||||
{
|
||||
if (uv_is_writable(stream()) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *data = nullptr;
|
||||
const size_t size = BIO_get_mem_data(bio, &data);
|
||||
std::string body(data, size);
|
||||
|
||||
(void) BIO_reset(bio);
|
||||
|
||||
HttpContext::write(std::move(body), m_close);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsContext::parse(char *data, size_t size)
|
||||
{
|
||||
if (HttpContext::parse(data, size) < size) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsContext::shutdown()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsContext::write(std::string &&data, bool close)
|
||||
{
|
||||
m_close = close;
|
||||
|
||||
if (m_mode == TLS_ON) {
|
||||
send(data.data(), data.size());
|
||||
}
|
||||
else {
|
||||
HttpContext::write(std::move(data), close);
|
||||
}
|
||||
}
|
73
src/base/net/https/HttpsContext.h
Normal file
73
src/base/net/https/HttpsContext.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XMRIG_HTTPSCONTEXT_H
|
||||
#define XMRIG_HTTPSCONTEXT_H
|
||||
|
||||
|
||||
using BIO = struct bio_st;
|
||||
using SSL = struct ssl_st;
|
||||
|
||||
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "base/net/tls/ServerTls.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class TlsContext;
|
||||
|
||||
|
||||
class HttpsContext : public HttpContext, public ServerTls
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpsContext)
|
||||
|
||||
HttpsContext(TlsContext *tls, const std::weak_ptr<IHttpListener> &listener);
|
||||
~HttpsContext() override;
|
||||
|
||||
void append(char *data, size_t size);
|
||||
|
||||
protected:
|
||||
// ServerTls
|
||||
bool write(BIO *bio) override;
|
||||
void parse(char *data, size_t size) override;
|
||||
void shutdown() override;
|
||||
|
||||
// HttpContext
|
||||
void write(std::string &&data, bool close) override;
|
||||
|
||||
private:
|
||||
enum TlsMode : uint32_t {
|
||||
TLS_AUTO,
|
||||
TLS_OFF,
|
||||
TLS_ON
|
||||
};
|
||||
|
||||
bool m_close = false;
|
||||
TlsMode m_mode = TLS_AUTO;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif // XMRIG_HTTPSCONTEXT_H
|
||||
|
71
src/base/net/https/HttpsServer.cpp
Normal file
71
src/base/net/https/HttpsServer.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/net/https/HttpsServer.h"
|
||||
#include "base/net/https/HttpsContext.h"
|
||||
#include "base/net/tls/TlsContext.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
|
||||
|
||||
xmrig::HttpsServer::HttpsServer(const std::shared_ptr<IHttpListener> &listener) :
|
||||
m_listener(listener)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::HttpsServer::~HttpsServer()
|
||||
{
|
||||
HttpContext::closeAll();
|
||||
|
||||
delete m_tls;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::HttpsServer::setTls(const TlsConfig &config)
|
||||
{
|
||||
m_tls = TlsContext::create(config);
|
||||
|
||||
return m_tls != nullptr;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsServer::onConnection(uv_stream_t *stream, uint16_t)
|
||||
{
|
||||
auto ctx = new HttpsContext(m_tls, m_listener);
|
||||
uv_accept(stream, ctx->stream());
|
||||
|
||||
uv_read_start(ctx->stream(), NetBuffer::onAlloc, onRead);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpsServer::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
auto ctx = static_cast<HttpsContext*>(stream->data);
|
||||
if (nread >= 0) {
|
||||
ctx->append(buf->base, static_cast<size_t>(nread));
|
||||
}
|
||||
else {
|
||||
ctx->close();
|
||||
}
|
||||
|
||||
NetBuffer::release(buf);
|
||||
}
|
72
src/base/net/https/HttpsServer.h
Normal file
72
src/base/net/https/HttpsServer.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XMRIG_HTTPSSERVER_H
|
||||
#define XMRIG_HTTPSSERVER_H
|
||||
|
||||
|
||||
using uv_tcp_t = struct uv_tcp_s;
|
||||
|
||||
struct http_parser;
|
||||
struct http_parser_settings;
|
||||
struct uv_buf_t;
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/ITcpServerListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IHttpListener;
|
||||
class TlsContext;
|
||||
class TlsConfig;
|
||||
|
||||
|
||||
class HttpsServer : public ITcpServerListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpsServer)
|
||||
|
||||
HttpsServer(const std::shared_ptr<IHttpListener> &listener);
|
||||
~HttpsServer() override;
|
||||
|
||||
bool setTls(const TlsConfig &config);
|
||||
|
||||
protected:
|
||||
void onConnection(uv_stream_t *stream, uint16_t port) override;
|
||||
|
||||
private:
|
||||
static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
|
||||
|
||||
std::weak_ptr<IHttpListener> m_listener;
|
||||
TlsContext *m_tls = nullptr;
|
||||
uv_tcp_t *m_tcp = nullptr;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif // XMRIG_HTTPSSERVER_H
|
||||
|
|
@ -38,13 +38,14 @@
|
|||
#endif
|
||||
|
||||
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/io/json/JsonRequest.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "base/net/stratum/Socks5.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "net/JobResult.h"
|
||||
|
@ -83,6 +84,7 @@ xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
|||
m_agent(agent),
|
||||
m_sendBuf(1024)
|
||||
{
|
||||
m_reader.setListener(this);
|
||||
m_key = m_storage.add(this);
|
||||
m_dns = new Dns(this);
|
||||
}
|
||||
|
@ -542,7 +544,7 @@ int xmrig::Client::resolve(const String &host)
|
|||
{
|
||||
setState(HostLookupState);
|
||||
|
||||
m_recvBuf.reset();
|
||||
m_reader.reset();
|
||||
|
||||
if (m_failures == -1) {
|
||||
m_failures = 0;
|
||||
|
@ -837,14 +839,10 @@ void xmrig::Client::ping()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::Client::read(ssize_t nread)
|
||||
void xmrig::Client::read(ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
const auto size = static_cast<size_t>(nread);
|
||||
|
||||
if (nread > 0 && size > m_recvBuf.available()) {
|
||||
nread = UV_ENOBUFS;
|
||||
}
|
||||
|
||||
if (nread < 0) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("[%s] read error: \"%s\"", url(), uv_strerror(static_cast<int>(nread)));
|
||||
|
@ -859,12 +857,8 @@ void xmrig::Client::read(ssize_t nread)
|
|||
return reconnect();
|
||||
}
|
||||
|
||||
m_recvBuf.nread(size);
|
||||
|
||||
if (m_socks5) {
|
||||
if (m_socks5->read(m_recvBuf.base(), m_recvBuf.pos())) {
|
||||
m_recvBuf.reset();
|
||||
}
|
||||
m_socks5->read(buf->base, size);
|
||||
|
||||
if (m_socks5->isReady()) {
|
||||
delete m_socks5;
|
||||
|
@ -886,13 +880,12 @@ void xmrig::Client::read(ssize_t nread)
|
|||
if (isTLS()) {
|
||||
LOG_DEBUG("[%s] TLS received (%d bytes)", url(), static_cast<int>(nread));
|
||||
|
||||
m_tls->read(m_recvBuf.base(), m_recvBuf.pos());
|
||||
m_recvBuf.reset();
|
||||
m_tls->read(buf->base, size);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
m_recvBuf.getline(this);
|
||||
m_reader.parse(buf->base, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -959,23 +952,6 @@ void xmrig::Client::startTimeout()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::Client::onAllocBuffer(uv_handle_t *handle, size_t, uv_buf_t *buf)
|
||||
{
|
||||
auto client = getClient(handle->data);
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
|
||||
buf->base = client->m_recvBuf.current();
|
||||
|
||||
# ifdef _WIN32
|
||||
buf->len = static_cast<ULONG>(client->m_recvBuf.available());
|
||||
# else
|
||||
buf->len = client->m_recvBuf.available();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::onClose(uv_handle_t *handle)
|
||||
{
|
||||
auto client = getClient(handle->data);
|
||||
|
@ -1027,17 +1003,19 @@ void xmrig::Client::onConnect(uv_connect_t *req, int status)
|
|||
client->m_stream->data = req->data;
|
||||
client->setState(ConnectedState);
|
||||
|
||||
uv_read_start(client->m_stream, onAllocBuffer, onRead);
|
||||
uv_read_start(client->m_stream, NetBuffer::onAlloc, onRead);
|
||||
delete req;
|
||||
|
||||
client->handshake();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *)
|
||||
void xmrig::Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
auto client = getClient(stream->data);
|
||||
if (client) {
|
||||
client->read(nread);
|
||||
client->read(nread, buf);
|
||||
}
|
||||
|
||||
NetBuffer::release(buf);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "base/net/stratum/Job.h"
|
||||
#include "base/net/stratum/Pool.h"
|
||||
#include "base/net/stratum/SubmitResult.h"
|
||||
#include "base/net/tools/RecvBuf.h"
|
||||
#include "base/net/tools/LineReader.h"
|
||||
#include "base/net/tools/Storage.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
@ -61,7 +61,6 @@ public:
|
|||
|
||||
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
||||
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
||||
constexpr static size_t kInputBufferSize = 1024 * 16;
|
||||
constexpr static size_t kMaxSendBufferSize = 1024 * 16;
|
||||
|
||||
Client(int id, const char *agent, IClientListener *listener);
|
||||
|
@ -108,7 +107,7 @@ private:
|
|||
void parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error);
|
||||
void parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error);
|
||||
void ping();
|
||||
void read(ssize_t nread);
|
||||
void read(ssize_t nread, const uv_buf_t *buf);
|
||||
void reconnect();
|
||||
void setState(SocketState state);
|
||||
void startTimeout();
|
||||
|
@ -118,7 +117,6 @@ private:
|
|||
inline void setExtension(Extension ext, bool enable) noexcept { m_extensions.set(ext, enable); }
|
||||
template<Extension ext> inline bool has() const noexcept { return m_extensions.test(ext); }
|
||||
|
||||
static void onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf);
|
||||
static void onClose(uv_handle_t *handle);
|
||||
static void onConnect(uv_connect_t *req, int status);
|
||||
static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
|
||||
|
@ -127,7 +125,7 @@ private:
|
|||
|
||||
const char *m_agent;
|
||||
Dns *m_dns;
|
||||
RecvBuf<kInputBufferSize> m_recvBuf;
|
||||
LineReader m_reader;
|
||||
Socks5 *m_socks5 = nullptr;
|
||||
std::bitset<EXT_MAX> m_extensions;
|
||||
std::vector<char> m_sendBuf;
|
||||
|
|
|
@ -78,7 +78,7 @@ void xmrig::Client::Socks5::connect()
|
|||
|
||||
const auto &host = m_client->pool().host();
|
||||
std::vector<uint8_t> buf;
|
||||
sockaddr_storage addr;
|
||||
sockaddr_storage addr{};
|
||||
|
||||
if (isIPv4(host, &addr)) {
|
||||
buf.resize(10);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,12 +24,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "base/net/stratum/Tls.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "base/net/stratum/Tls.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
|
||||
|
||||
|
@ -38,12 +35,12 @@
|
|||
#endif
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
||||
xmrig::Client::Tls::Tls(Client *client) :
|
||||
m_ready(false),
|
||||
m_buf(),
|
||||
m_fingerprint(),
|
||||
m_client(client),
|
||||
m_ssl(nullptr)
|
||||
m_client(client)
|
||||
{
|
||||
m_ctx = SSL_CTX_new(SSLv23_method());
|
||||
assert(m_ctx != nullptr);
|
||||
|
@ -52,8 +49,8 @@ xmrig::Client::Tls::Tls(Client *client) :
|
|||
return;
|
||||
}
|
||||
|
||||
m_writeBio = BIO_new(BIO_s_mem());
|
||||
m_readBio = BIO_new(BIO_s_mem());
|
||||
m_write = BIO_new(BIO_s_mem());
|
||||
m_read = BIO_new(BIO_s_mem());
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
|
||||
}
|
||||
|
||||
|
@ -80,7 +77,7 @@ bool xmrig::Client::Tls::handshake()
|
|||
}
|
||||
|
||||
SSL_set_connect_state(m_ssl);
|
||||
SSL_set_bio(m_ssl, m_readBio, m_writeBio);
|
||||
SSL_set_bio(m_ssl, m_read, m_write);
|
||||
SSL_do_handshake(m_ssl);
|
||||
|
||||
return send();
|
||||
|
@ -109,7 +106,7 @@ const char *xmrig::Client::Tls::version() const
|
|||
|
||||
void xmrig::Client::Tls::read(const char *data, size_t size)
|
||||
{
|
||||
BIO_write(m_readBio, data, size);
|
||||
BIO_write(m_read, data, size);
|
||||
|
||||
if (!SSL_is_init_finished(m_ssl)) {
|
||||
const int rc = SSL_connect(m_ssl);
|
||||
|
@ -133,17 +130,18 @@ void xmrig::Client::Tls::read(const char *data, size_t size)
|
|||
return;
|
||||
}
|
||||
|
||||
static char buf[16384]{};
|
||||
int bytes_read = 0;
|
||||
while ((bytes_read = SSL_read(m_ssl, m_buf, sizeof(m_buf))) > 0) {
|
||||
m_buf[bytes_read - 1] = '\0';
|
||||
m_client->parse(m_buf, static_cast<size_t>(bytes_read));
|
||||
|
||||
while ((bytes_read = SSL_read(m_ssl, buf, sizeof(buf))) > 0) {
|
||||
m_client->m_reader.parse(buf, static_cast<size_t>(bytes_read));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Client::Tls::send()
|
||||
{
|
||||
return m_client->send(m_writeBio);
|
||||
return m_client->send(m_write);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -26,10 +26,14 @@
|
|||
#define XMRIG_CLIENT_TLS_H
|
||||
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
using BIO = struct bio_st;
|
||||
using SSL = struct ssl_st;
|
||||
using SSL_CTX = struct ssl_ctx_st;
|
||||
using X509 = struct x509_st;
|
||||
|
||||
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -38,6 +42,8 @@ namespace xmrig {
|
|||
class Client::Tls
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Tls)
|
||||
|
||||
Tls(Client *client);
|
||||
~Tls();
|
||||
|
||||
|
@ -52,13 +58,12 @@ private:
|
|||
bool verify(X509 *cert);
|
||||
bool verifyFingerprint(X509 *cert);
|
||||
|
||||
BIO *m_readBio;
|
||||
BIO *m_writeBio;
|
||||
bool m_ready;
|
||||
char m_buf[1024 * 2];
|
||||
char m_fingerprint[32 * 2 + 8];
|
||||
BIO *m_read = nullptr;
|
||||
BIO *m_write = nullptr;
|
||||
bool m_ready = false;
|
||||
char m_fingerprint[32 * 2 + 8]{};
|
||||
Client *m_client;
|
||||
SSL *m_ssl;
|
||||
SSL *m_ssl = nullptr;
|
||||
SSL_CTX *m_ctx;
|
||||
};
|
||||
|
||||
|
|
103
src/base/net/tls/ServerTls.cpp
Normal file
103
src/base/net/tls/ServerTls.cpp
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tls/ServerTls.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
||||
xmrig::ServerTls::ServerTls(SSL_CTX *ctx) :
|
||||
m_ctx(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::ServerTls::~ServerTls()
|
||||
{
|
||||
if (m_ssl) {
|
||||
SSL_free(m_ssl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::ServerTls::isTLS(const char *data, size_t size)
|
||||
{
|
||||
static const uint8_t test[3] = { 0x16, 0x03, 0x01 };
|
||||
|
||||
return size >= sizeof(test) && memcmp(data, test, sizeof(test)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::ServerTls::send(const char *data, size_t size)
|
||||
{
|
||||
SSL_write(m_ssl, data, size);
|
||||
|
||||
return write(m_write);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ServerTls::read(const char *data, size_t size)
|
||||
{
|
||||
if (!m_ssl) {
|
||||
m_ssl = SSL_new(m_ctx);
|
||||
|
||||
m_write = BIO_new(BIO_s_mem());
|
||||
m_read = BIO_new(BIO_s_mem());
|
||||
|
||||
SSL_set_accept_state(m_ssl);
|
||||
SSL_set_bio(m_ssl, m_read, m_write);
|
||||
}
|
||||
|
||||
|
||||
BIO_write(m_read, data, size);
|
||||
|
||||
if (!SSL_is_init_finished(m_ssl)) {
|
||||
const int rc = SSL_do_handshake(m_ssl);
|
||||
|
||||
if (rc < 0 && SSL_get_error(m_ssl, rc) == SSL_ERROR_WANT_READ) {
|
||||
write(m_write);
|
||||
} else if (rc == 1) {
|
||||
write(m_write);
|
||||
|
||||
m_ready = true;
|
||||
read();
|
||||
}
|
||||
else {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
read();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ServerTls::read()
|
||||
{
|
||||
static char buf[16384]{};
|
||||
|
||||
int bytes_read = 0;
|
||||
while ((bytes_read = SSL_read(m_ssl, buf, sizeof(buf))) > 0) {
|
||||
parse(buf, bytes_read);
|
||||
}
|
||||
}
|
68
src/base/net/tls/ServerTls.h
Normal file
68
src/base/net/tls/ServerTls.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XMRIG_SERVERTLS_H
|
||||
#define XMRIG_SERVERTLS_H
|
||||
|
||||
|
||||
using BIO = struct bio_st;
|
||||
using SSL = struct ssl_st;
|
||||
using SSL_CTX = struct ssl_ctx_st;
|
||||
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class ServerTls
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(ServerTls)
|
||||
|
||||
ServerTls(SSL_CTX *ctx);
|
||||
virtual ~ServerTls();
|
||||
|
||||
static bool isTLS(const char *data, size_t size);
|
||||
|
||||
bool send(const char *data, size_t size);
|
||||
void read(const char *data, size_t size);
|
||||
|
||||
protected:
|
||||
virtual bool write(BIO *bio) = 0;
|
||||
virtual void parse(char *data, size_t size) = 0;
|
||||
virtual void shutdown() = 0;
|
||||
|
||||
private:
|
||||
void read();
|
||||
|
||||
BIO *m_read = nullptr;
|
||||
BIO *m_write = nullptr;
|
||||
bool m_ready = false;
|
||||
SSL *m_ssl = nullptr;
|
||||
SSL_CTX *m_ctx;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_SERVERTLS_H */
|
200
src/base/net/tls/TlsConfig.cpp
Normal file
200
src/base/net/tls/TlsConfig.cpp
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tls/TlsConfig.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/tls/TlsGen.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
const char *TlsConfig::kCert = "cert";
|
||||
const char *TlsConfig::kEnabled = "enabled";
|
||||
const char *TlsConfig::kCertKey = "cert_key";
|
||||
const char *TlsConfig::kCiphers = "ciphers";
|
||||
const char *TlsConfig::kCipherSuites = "ciphersuites";
|
||||
const char *TlsConfig::kDhparam = "dhparam";
|
||||
const char *TlsConfig::kGen = "gen";
|
||||
const char *TlsConfig::kProtocols = "protocols";
|
||||
|
||||
static const char *kTLSv1 = "TLSv1";
|
||||
static const char *kTLSv1_1 = "TLSv1.1";
|
||||
static const char *kTLSv1_2 = "TLSv1.2";
|
||||
static const char *kTLSv1_3 = "TLSv1.3";
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
/**
|
||||
* "cert" load TLS certificate chain from file.
|
||||
* "cert_key" load TLS private key from file.
|
||||
* "ciphers" set list of available ciphers (TLSv1.2 and below).
|
||||
* "ciphersuites" set list of available TLSv1.3 ciphersuites.
|
||||
* "dhparam" load DH parameters for DHE ciphers from file.
|
||||
*/
|
||||
xmrig::TlsConfig::TlsConfig(const rapidjson::Value &value)
|
||||
{
|
||||
if (value.IsObject()) {
|
||||
m_enabled = Json::getBool(value, kEnabled, m_enabled);
|
||||
|
||||
setProtocols(Json::getString(value, kProtocols));
|
||||
setCert(Json::getString(value, kCert));
|
||||
setKey(Json::getString(value, kCertKey));
|
||||
setCiphers(Json::getString(value, kCiphers));
|
||||
setCipherSuites(Json::getString(value, kCipherSuites));
|
||||
setDH(Json::getString(value, kDhparam));
|
||||
|
||||
if (m_key.isNull()) {
|
||||
setKey(Json::getString(value, "cert-key"));
|
||||
}
|
||||
|
||||
if (m_enabled && !isValid()) {
|
||||
generate(Json::getString(value, kGen));
|
||||
}
|
||||
}
|
||||
else if (value.IsBool()) {
|
||||
m_enabled = value.GetBool();
|
||||
|
||||
if (m_enabled) {
|
||||
generate();
|
||||
}
|
||||
}
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
else if (value.IsNull()) {
|
||||
generate();
|
||||
}
|
||||
# endif
|
||||
else if (value.IsString()) {
|
||||
generate(value.GetString());
|
||||
}
|
||||
else {
|
||||
m_enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsConfig::generate(const char *commonName)
|
||||
{
|
||||
TlsGen gen;
|
||||
|
||||
try {
|
||||
gen.generate(commonName);
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
LOG_ERR("%s", ex.what());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
setCert(gen.cert());
|
||||
setKey(gen.certKey());
|
||||
|
||||
m_enabled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::TlsConfig::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
auto &allocator = doc.GetAllocator();
|
||||
Value obj(kObjectType);
|
||||
obj.AddMember(StringRef(kEnabled), m_enabled, allocator);
|
||||
|
||||
if (m_protocols > 0) {
|
||||
std::vector<String> protocols;
|
||||
|
||||
if (m_protocols & TLSv1) {
|
||||
protocols.emplace_back(kTLSv1);
|
||||
}
|
||||
|
||||
if (m_protocols & TLSv1_1) {
|
||||
protocols.emplace_back(kTLSv1_1);
|
||||
}
|
||||
|
||||
if (m_protocols & TLSv1_2) {
|
||||
protocols.emplace_back(kTLSv1_2);
|
||||
}
|
||||
|
||||
if (m_protocols & TLSv1_3) {
|
||||
protocols.emplace_back(kTLSv1_3);
|
||||
}
|
||||
|
||||
obj.AddMember(StringRef(kProtocols), String::join(protocols, ' ').toJSON(doc), allocator);
|
||||
}
|
||||
else {
|
||||
obj.AddMember(StringRef(kProtocols), kNullType, allocator);
|
||||
}
|
||||
|
||||
obj.AddMember(StringRef(kCert), m_cert.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kCertKey), m_key.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kCiphers), m_ciphers.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kCipherSuites), m_cipherSuites.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kDhparam), m_dhparam.toJSON(), allocator);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::TlsConfig::setProtocols(const char *protocols)
|
||||
{
|
||||
const std::vector<String> vec = String(protocols).split(' ');
|
||||
|
||||
for (const String &value : vec) {
|
||||
if (value == kTLSv1) {
|
||||
m_protocols |= TLSv1;
|
||||
}
|
||||
else if (value == kTLSv1_1) {
|
||||
m_protocols |= TLSv1_1;
|
||||
}
|
||||
else if (value == kTLSv1_2) {
|
||||
m_protocols |= TLSv1_2;
|
||||
}
|
||||
else if (value == kTLSv1_3) {
|
||||
m_protocols |= TLSv1_3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::TlsConfig::setProtocols(const rapidjson::Value &protocols)
|
||||
{
|
||||
m_protocols = 0;
|
||||
|
||||
if (protocols.IsUint()) {
|
||||
return setProtocols(protocols.GetUint());
|
||||
}
|
||||
|
||||
if (protocols.IsString()) {
|
||||
return setProtocols(protocols.GetString());
|
||||
}
|
||||
}
|
92
src/base/net/tls/TlsConfig.h
Normal file
92
src/base/net/tls/TlsConfig.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_TLSCONFIG_H
|
||||
#define XMRIG_TLSCONFIG_H
|
||||
|
||||
|
||||
#include "base/tools/String.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class TlsConfig
|
||||
{
|
||||
public:
|
||||
static const char *kCert;
|
||||
static const char *kCertKey;
|
||||
static const char *kCiphers;
|
||||
static const char *kCipherSuites;
|
||||
static const char *kDhparam;
|
||||
static const char *kEnabled;
|
||||
static const char *kGen;
|
||||
static const char *kProtocols;
|
||||
|
||||
enum Versions {
|
||||
TLSv1 = 1,
|
||||
TLSv1_1 = 2,
|
||||
TLSv1_2 = 4,
|
||||
TLSv1_3 = 8
|
||||
};
|
||||
|
||||
TlsConfig() = default;
|
||||
TlsConfig(const rapidjson::Value &object);
|
||||
|
||||
inline bool isEnabled() const { return m_enabled && isValid(); }
|
||||
inline bool isValid() const { return !m_cert.isEmpty() && !m_key.isEmpty(); }
|
||||
inline const char *cert() const { return m_cert.data(); }
|
||||
inline const char *ciphers() const { return m_ciphers.isEmpty() ? nullptr : m_ciphers.data(); }
|
||||
inline const char *cipherSuites() const { return m_cipherSuites.isEmpty() ? nullptr : m_cipherSuites.data(); }
|
||||
inline const char *dhparam() const { return m_dhparam.isEmpty() ? nullptr : m_dhparam.data(); }
|
||||
inline const char *key() const { return m_key.data(); }
|
||||
inline uint32_t protocols() const { return m_protocols; }
|
||||
inline void setCert(const char *cert) { m_cert = cert; }
|
||||
inline void setCiphers(const char *ciphers) { m_ciphers = ciphers; }
|
||||
inline void setCipherSuites(const char *ciphers) { m_cipherSuites = ciphers; }
|
||||
inline void setDH(const char *dhparam) { m_dhparam = dhparam; }
|
||||
inline void setKey(const char *key) { m_key = key; }
|
||||
inline void setProtocols(uint32_t protocols) { m_protocols = protocols; }
|
||||
|
||||
bool generate(const char *commonName = nullptr);
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
void setProtocols(const char *protocols);
|
||||
void setProtocols(const rapidjson::Value &protocols);
|
||||
|
||||
private:
|
||||
bool m_enabled = true;
|
||||
uint32_t m_protocols = 0;
|
||||
String m_cert;
|
||||
String m_ciphers;
|
||||
String m_cipherSuites;
|
||||
String m_dhparam;
|
||||
String m_key;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* XMRIG_TLSCONFIG_H */
|
270
src/base/net/tls/TlsContext.cpp
Normal file
270
src/base/net/tls/TlsContext.cpp
Normal file
|
@ -0,0 +1,270 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tls/TlsContext.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/Env.h"
|
||||
#include "base/net/tls/TlsConfig.h"
|
||||
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
|
||||
// https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes#Compatibility_Layer
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
|
||||
{
|
||||
assert(q == nullptr);
|
||||
|
||||
dh->p = p;
|
||||
dh->g = g;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
// https://wiki.openssl.org/index.php/Diffie-Hellman_parameters
|
||||
static DH *get_dh2048()
|
||||
{
|
||||
static unsigned char dhp_2048[] = {
|
||||
0xB2, 0x91, 0xA7, 0x05, 0x31, 0xCE, 0x12, 0x9D, 0x03, 0x43,
|
||||
0xAF, 0x13, 0xAF, 0x4B, 0x8E, 0x4C, 0x04, 0x13, 0x4F, 0x72,
|
||||
0x00, 0x73, 0x2C, 0x67, 0xC3, 0xE0, 0x50, 0xBF, 0x72, 0x5E,
|
||||
0xBE, 0x45, 0x89, 0x4C, 0x01, 0x45, 0xA6, 0x5E, 0xA7, 0xA8,
|
||||
0xDC, 0x2F, 0x1D, 0x91, 0x2D, 0x58, 0x0D, 0x71, 0x97, 0x3D,
|
||||
0xAE, 0xFE, 0x86, 0x29, 0x37, 0x5F, 0x5E, 0x6D, 0x81, 0x56,
|
||||
0x07, 0x83, 0xF2, 0xF8, 0xEC, 0x4E, 0xF8, 0x7A, 0xEC, 0xEA,
|
||||
0xD9, 0xEA, 0x61, 0x3C, 0xAF, 0x51, 0x30, 0xB7, 0xA7, 0x67,
|
||||
0x3F, 0x59, 0xAD, 0x2E, 0x23, 0x57, 0x64, 0xA2, 0x99, 0x15,
|
||||
0xBD, 0xD9, 0x8D, 0xBA, 0xE6, 0x8F, 0xFB, 0xB3, 0x77, 0x3B,
|
||||
0xE6, 0x5C, 0xC1, 0x03, 0xCF, 0x38, 0xD4, 0xF6, 0x2E, 0x0B,
|
||||
0xF3, 0x20, 0xBE, 0xF0, 0xFC, 0x85, 0xEF, 0x5F, 0xCE, 0x0E,
|
||||
0x42, 0x17, 0x3B, 0x72, 0x43, 0x4C, 0x3A, 0xF5, 0xC8, 0xB4,
|
||||
0x40, 0x52, 0x03, 0x72, 0x9A, 0x2C, 0xA4, 0x23, 0x2A, 0xA2,
|
||||
0x52, 0xA3, 0xC2, 0x76, 0x08, 0x1C, 0x2E, 0x60, 0x44, 0xE4,
|
||||
0x12, 0x5D, 0x80, 0x47, 0x6C, 0x7A, 0x5A, 0x8E, 0x18, 0xC9,
|
||||
0x8C, 0x22, 0xC8, 0x07, 0x75, 0xE2, 0x77, 0x3A, 0x90, 0x2E,
|
||||
0x79, 0xC3, 0xF5, 0x4E, 0x4E, 0xDE, 0x14, 0x29, 0xA4, 0x5B,
|
||||
0x32, 0xCC, 0xE5, 0x05, 0x09, 0x2A, 0xC9, 0x1C, 0xB4, 0x8E,
|
||||
0x99, 0xCF, 0x57, 0xF2, 0x1B, 0x5F, 0x18, 0x89, 0x29, 0xF2,
|
||||
0xB0, 0xF3, 0xAC, 0x67, 0x16, 0x90, 0x4A, 0x1D, 0xD6, 0xF5,
|
||||
0x84, 0x71, 0x1D, 0x0E, 0x61, 0x5F, 0xE2, 0x2D, 0x52, 0x87,
|
||||
0x0D, 0x8F, 0x84, 0xCB, 0xFC, 0xF0, 0x5D, 0x4C, 0x9F, 0x59,
|
||||
0xA9, 0xD6, 0x83, 0x70, 0x4B, 0x98, 0x6A, 0xCA, 0x78, 0x53,
|
||||
0x27, 0x32, 0x59, 0x35, 0x0A, 0xB8, 0x29, 0x18, 0xAF, 0x58,
|
||||
0x45, 0x63, 0xEB, 0x43, 0x28, 0x7B
|
||||
};
|
||||
|
||||
static unsigned char dhg_2048[] = { 0x02 };
|
||||
|
||||
auto dh = DH_new();
|
||||
if (dh == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto p = BN_bin2bn(dhp_2048, sizeof(dhp_2048), nullptr);
|
||||
auto g = BN_bin2bn(dhg_2048, sizeof(dhg_2048), nullptr);
|
||||
|
||||
if (p == nullptr || g == nullptr || !DH_set0_pqg(dh, p, nullptr, g)) {
|
||||
DH_free(dh);
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return dh;
|
||||
}
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::TlsContext::~TlsContext()
|
||||
{
|
||||
SSL_CTX_free(m_ctx);
|
||||
}
|
||||
|
||||
|
||||
xmrig::TlsContext *xmrig::TlsContext::create(const TlsConfig &config)
|
||||
{
|
||||
if (!config.isEnabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto tls = new TlsContext();
|
||||
if (!tls->load(config)) {
|
||||
delete tls;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return tls;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsContext::load(const TlsConfig &config)
|
||||
{
|
||||
m_ctx = SSL_CTX_new(SSLv23_server_method());
|
||||
if (m_ctx == nullptr) {
|
||||
LOG_ERR("Unable to create SSL context");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto cert = Env::expand(config.cert());
|
||||
if (SSL_CTX_use_certificate_chain_file(m_ctx, cert) <= 0) {
|
||||
LOG_ERR("SSL_CTX_use_certificate_chain_file(\"%s\") failed.", config.cert());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto key = Env::expand(config.key());
|
||||
if (SSL_CTX_use_PrivateKey_file(m_ctx, key, SSL_FILETYPE_PEM) <= 0) {
|
||||
LOG_ERR("SSL_CTX_use_PrivateKey_file(\"%s\") failed.", config.key());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
|
||||
|
||||
# if OPENSSL_VERSION_NUMBER >= 0x1010100fL
|
||||
SSL_CTX_set_max_early_data(m_ctx, 0);
|
||||
# endif
|
||||
|
||||
setProtocols(config.protocols());
|
||||
|
||||
return setCiphers(config.ciphers()) && setCipherSuites(config.cipherSuites()) && setDH(config.dhparam());
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsContext::setCiphers(const char *ciphers)
|
||||
{
|
||||
if (ciphers == nullptr || SSL_CTX_set_cipher_list(m_ctx, ciphers) == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_ERR("SSL_CTX_set_cipher_list(\"%s\") failed.", ciphers);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsContext::setCipherSuites(const char *ciphersuites)
|
||||
{
|
||||
if (ciphersuites == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
# if OPENSSL_VERSION_NUMBER >= 0x1010100fL
|
||||
if (SSL_CTX_set_ciphersuites(m_ctx, ciphersuites) == 1) {
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
|
||||
LOG_ERR("SSL_CTX_set_ciphersuites(\"%s\") failed.", ciphersuites);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsContext::setDH(const char *dhparam)
|
||||
{
|
||||
DH *dh = nullptr;
|
||||
|
||||
if (dhparam != nullptr) {
|
||||
BIO *bio = BIO_new_file(Env::expand(dhparam), "r");
|
||||
if (bio == nullptr) {
|
||||
LOG_ERR("BIO_new_file(\"%s\") failed.", dhparam);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
dh = PEM_read_bio_DHparams(bio, nullptr, nullptr, nullptr);
|
||||
if (dh == nullptr) {
|
||||
LOG_ERR("PEM_read_bio_DHparams(\"%s\") failed.", dhparam);
|
||||
|
||||
BIO_free(bio);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
}
|
||||
else {
|
||||
dh = get_dh2048();
|
||||
}
|
||||
|
||||
const int rc = SSL_CTX_set_tmp_dh(m_ctx, dh);
|
||||
|
||||
DH_free(dh);
|
||||
|
||||
if (rc == 0) {
|
||||
LOG_ERR("SSL_CTX_set_tmp_dh(\"%s\") failed.", dhparam);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::TlsContext::setProtocols(uint32_t protocols)
|
||||
{
|
||||
if (protocols == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(protocols & TlsConfig::TLSv1)) {
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_TLSv1);
|
||||
}
|
||||
|
||||
# ifdef SSL_OP_NO_TLSv1_1
|
||||
SSL_CTX_clear_options(m_ctx, SSL_OP_NO_TLSv1_1);
|
||||
if (!(protocols & TlsConfig::TLSv1_1)) {
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_TLSv1_1);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef SSL_OP_NO_TLSv1_2
|
||||
SSL_CTX_clear_options(m_ctx, SSL_OP_NO_TLSv1_2);
|
||||
if (!(protocols & TlsConfig::TLSv1_2)) {
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_TLSv1_2);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef SSL_OP_NO_TLSv1_3
|
||||
SSL_CTX_clear_options(m_ctx, SSL_OP_NO_TLSv1_3);
|
||||
if (!(protocols & TlsConfig::TLSv1_3)) {
|
||||
SSL_CTX_set_options(m_ctx, SSL_OP_NO_TLSv1_3);
|
||||
}
|
||||
# endif
|
||||
}
|
71
src/base/net/tls/TlsContext.h
Normal file
71
src/base/net/tls/TlsContext.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_TLSCONTEXT_H
|
||||
#define XMRIG_TLSCONTEXT_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
using SSL_CTX = struct ssl_ctx_st;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class TlsConfig;
|
||||
|
||||
|
||||
class TlsContext
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(TlsContext)
|
||||
|
||||
~TlsContext();
|
||||
|
||||
static TlsContext *create(const TlsConfig &config);
|
||||
|
||||
inline SSL_CTX *ctx() const { return m_ctx; }
|
||||
|
||||
private:
|
||||
TlsContext() = default;
|
||||
|
||||
bool load(const TlsConfig &config);
|
||||
bool setCiphers(const char *ciphers);
|
||||
bool setCipherSuites(const char *ciphersuites);
|
||||
bool setDH(const char *dhparam);
|
||||
void setProtocols(uint32_t protocols);
|
||||
|
||||
SSL_CTX *m_ctx = nullptr;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* XMRIG_TLSCONTEXT_H */
|
144
src/base/net/tls/TlsGen.cpp
Normal file
144
src/base/net/tls/TlsGen.cpp
Normal file
|
@ -0,0 +1,144 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tls/TlsGen.h"
|
||||
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const char *kLocalhost = "localhost";
|
||||
|
||||
|
||||
static EVP_PKEY *generate_pkey()
|
||||
{
|
||||
auto pkey = EVP_PKEY_new();
|
||||
if (!pkey) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto exponent = BN_new();
|
||||
auto rsa = RSA_new();
|
||||
if (!exponent || !rsa || !BN_set_word(exponent, RSA_F4) || !RSA_generate_key_ex(rsa, 2048, exponent, nullptr) || !EVP_PKEY_assign_RSA(pkey, rsa)) {
|
||||
EVP_PKEY_free(pkey);
|
||||
BN_free(exponent);
|
||||
RSA_free(rsa);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BN_free(exponent);
|
||||
|
||||
return pkey;
|
||||
}
|
||||
|
||||
|
||||
bool isFileExist(const char *fileName)
|
||||
{
|
||||
std::ifstream in(fileName);
|
||||
|
||||
return in.good();
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::TlsGen::~TlsGen()
|
||||
{
|
||||
EVP_PKEY_free(m_pkey);
|
||||
X509_free(m_x509);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::TlsGen::generate(const char *commonName)
|
||||
{
|
||||
if (isFileExist(m_cert) && isFileExist(m_certKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pkey = generate_pkey();
|
||||
if (!m_pkey) {
|
||||
throw std::runtime_error("RSA key generation failed.");
|
||||
}
|
||||
|
||||
if (!generate_x509(commonName == nullptr || strlen(commonName) == 0 ? kLocalhost : commonName)) {
|
||||
throw std::runtime_error("x509 certificate generation failed.");
|
||||
}
|
||||
|
||||
if (!write()) {
|
||||
throw std::runtime_error("unable to write certificate to disk.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsGen::generate_x509(const char *commonName)
|
||||
{
|
||||
m_x509 = X509_new();
|
||||
if (!m_x509) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!X509_set_pubkey(m_x509, m_pkey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ASN1_INTEGER_set(X509_get_serialNumber(m_x509), 1);
|
||||
X509_gmtime_adj(X509_get_notBefore(m_x509), 0);
|
||||
X509_gmtime_adj(X509_get_notAfter(m_x509), 315360000L);
|
||||
|
||||
auto name = X509_get_subject_name(m_x509);
|
||||
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast<const uint8_t *>(commonName), -1, -1, 0);
|
||||
|
||||
X509_set_issuer_name(m_x509, name);
|
||||
|
||||
return X509_sign(m_x509, m_pkey, EVP_sha256());
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::TlsGen::write()
|
||||
{
|
||||
auto pkey_file = fopen(m_certKey, "wb");
|
||||
if (!pkey_file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = PEM_write_PrivateKey(pkey_file, m_pkey, nullptr, nullptr, 0, nullptr, nullptr);
|
||||
fclose(pkey_file);
|
||||
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto x509_file = fopen(m_cert, "wb");
|
||||
if (!x509_file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = PEM_write_X509(x509_file, m_x509);
|
||||
fclose(x509_file);
|
||||
|
||||
return ret;
|
||||
}
|
61
src/base/net/tls/TlsGen.h
Normal file
61
src/base/net/tls/TlsGen.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_TLSGEN_H
|
||||
#define XMRIG_TLSGEN_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
using EVP_PKEY = struct evp_pkey_st;
|
||||
using X509 = struct x509_st;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class TlsGen
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(TlsGen)
|
||||
|
||||
TlsGen() : m_cert("cert.pem"), m_certKey("cert_key.pem") {}
|
||||
~TlsGen();
|
||||
|
||||
inline const String &cert() const { return m_cert; }
|
||||
inline const String &certKey() const { return m_certKey; }
|
||||
|
||||
void generate(const char *commonName = nullptr);
|
||||
|
||||
private:
|
||||
bool generate_x509(const char *commonName);
|
||||
bool write();
|
||||
|
||||
const String m_cert;
|
||||
const String m_certKey;
|
||||
EVP_PKEY *m_pkey = nullptr;
|
||||
X509 *m_x509 = nullptr;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_TLSGEN_H */
|
103
src/base/net/tools/LineReader.cpp
Normal file
103
src/base/net/tools/LineReader.cpp
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tools/LineReader.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/kernel/interfaces/ILineListener.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
xmrig::LineReader::~LineReader()
|
||||
{
|
||||
NetBuffer::release(m_buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::LineReader::parse(char *data, size_t size)
|
||||
{
|
||||
assert(m_listener != nullptr && size > 0);
|
||||
if (!m_listener || size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_buf) {
|
||||
return getline(data, size);
|
||||
}
|
||||
|
||||
add(data, size);
|
||||
getline(m_buf, m_pos);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::LineReader::reset()
|
||||
{
|
||||
if (m_buf) {
|
||||
NetBuffer::release(m_buf);
|
||||
m_buf = nullptr;
|
||||
m_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::LineReader::add(const char *data, size_t size)
|
||||
{
|
||||
if (size > NetBuffer::kChunkSize - m_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_buf) {
|
||||
m_buf = NetBuffer::allocate();
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
memcpy(m_buf + m_pos, data, size);
|
||||
m_pos += size;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::LineReader::getline(char *data, size_t size)
|
||||
{
|
||||
char *end = nullptr;
|
||||
char *start = data;
|
||||
size_t remaining = size;
|
||||
|
||||
while ((end = static_cast<char*>(memchr(start, '\n', remaining))) != nullptr) {
|
||||
*end = '\0';
|
||||
|
||||
end++;
|
||||
|
||||
const auto len = static_cast<size_t>(end - start);
|
||||
if (len > 1) {
|
||||
m_listener->onLine(start, len - 1);
|
||||
}
|
||||
|
||||
remaining -= len;
|
||||
start = end;
|
||||
}
|
||||
|
||||
if (remaining == 0) {
|
||||
return reset();
|
||||
}
|
||||
|
||||
if (!m_buf || m_buf != data) {
|
||||
add(start, remaining);
|
||||
}
|
||||
}
|
62
src/base/net/tools/LineReader.h
Normal file
62
src/base/net/tools/LineReader.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_LINEREADER_H
|
||||
#define XMRIG_LINEREADER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class ILineListener;
|
||||
|
||||
|
||||
class LineReader
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(LineReader)
|
||||
|
||||
LineReader() = default;
|
||||
LineReader(ILineListener *listener) : m_listener(listener) {}
|
||||
~LineReader();
|
||||
|
||||
inline void setListener(ILineListener *listener) { m_listener = listener; }
|
||||
|
||||
void parse(char *data, size_t size);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
void add(const char *data, size_t size);
|
||||
void getline(char *data, size_t size);
|
||||
|
||||
char *m_buf = nullptr;
|
||||
ILineListener *m_listener = nullptr;
|
||||
size_t m_pos = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_NETBUFFER_H */
|
96
src/base/net/tools/MemPool.h
Normal file
96
src/base/net/tools/MemPool.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_MEMPOOL_H
|
||||
#define XMRIG_MEMPOOL_H
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template<size_t CHUNK_SIZE, size_t INIT_SIZE>
|
||||
class MemPool
|
||||
{
|
||||
public:
|
||||
MemPool() = default;
|
||||
|
||||
|
||||
constexpr size_t chunkSize() const { return CHUNK_SIZE; }
|
||||
inline size_t freeSize() const { return m_free.size() * CHUNK_SIZE; }
|
||||
inline size_t size() const { return m_data.size() * CHUNK_SIZE * INIT_SIZE; }
|
||||
|
||||
|
||||
inline char *allocate()
|
||||
{
|
||||
if (m_free.empty()) {
|
||||
resize();
|
||||
}
|
||||
|
||||
const size_t i = *m_free.begin();
|
||||
const size_t r = i / INIT_SIZE;
|
||||
|
||||
char *ptr = m_data[r].data() + (i - r * INIT_SIZE) * CHUNK_SIZE;
|
||||
|
||||
m_used.insert({ ptr, i });
|
||||
m_free.erase(i);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
inline void deallocate(const char *ptr)
|
||||
{
|
||||
if (ptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(m_used.count(ptr));
|
||||
|
||||
m_free.emplace(m_used[ptr]);
|
||||
m_used.erase(ptr);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
inline void resize()
|
||||
{
|
||||
const size_t index = m_data.size();
|
||||
m_data[index];
|
||||
|
||||
for (size_t i = 0; i < INIT_SIZE; ++i) {
|
||||
m_free.emplace((index * INIT_SIZE) + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::map<const char *, size_t> m_used;
|
||||
std::map<size_t, std::array<char, CHUNK_SIZE * INIT_SIZE> > m_data;
|
||||
std::set<size_t> m_free;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_MEMPOOL_H */
|
83
src/base/net/tools/NetBuffer.cpp
Normal file
83
src/base/net/tools/NetBuffer.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tools/MemPool.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static constexpr size_t kInitSize = 4;
|
||||
static MemPool<NetBuffer::kChunkSize, kInitSize> *pool = nullptr;
|
||||
|
||||
|
||||
inline MemPool<NetBuffer::kChunkSize, kInitSize> *getPool()
|
||||
{
|
||||
if (!pool) {
|
||||
pool = new MemPool<NetBuffer::kChunkSize, kInitSize>();
|
||||
}
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
char *xmrig::NetBuffer::allocate()
|
||||
{
|
||||
return getPool()->allocate();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::destroy()
|
||||
{
|
||||
if (!pool) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pool->freeSize() == pool->size());
|
||||
|
||||
delete pool;
|
||||
pool = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::onAlloc(uv_handle_t *, size_t, uv_buf_t *buf)
|
||||
{
|
||||
buf->base = getPool()->allocate();
|
||||
buf->len = kChunkSize;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::release(const char *buf)
|
||||
{
|
||||
getPool()->deallocate(buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::release(const uv_buf_t *buf)
|
||||
{
|
||||
getPool()->deallocate(buf->base);
|
||||
}
|
49
src/base/net/tools/NetBuffer.h
Normal file
49
src/base/net/tools/NetBuffer.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_NETBUFFER_H
|
||||
#define XMRIG_NETBUFFER_H
|
||||
|
||||
|
||||
struct uv_buf_t;
|
||||
using uv_handle_t = struct uv_handle_s;
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class NetBuffer
|
||||
{
|
||||
public:
|
||||
static constexpr size_t kChunkSize = 16 * 1024;
|
||||
|
||||
static char *allocate();
|
||||
static void destroy();
|
||||
static void onAlloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf);
|
||||
static void release(const char *buf);
|
||||
static void release(const uv_buf_t *buf);
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_NETBUFFER_H */
|
|
@ -1,99 +0,0 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_RECVBUF_H
|
||||
#define XMRIG_RECVBUF_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/ILineListener.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template<size_t N>
|
||||
class RecvBuf
|
||||
{
|
||||
public:
|
||||
inline RecvBuf() :
|
||||
m_buf(),
|
||||
m_pos(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline char *base() { return m_buf; }
|
||||
inline char *current() { return m_buf + m_pos; }
|
||||
inline const char *base() const { return m_buf; }
|
||||
inline const char *current() const { return m_buf + m_pos; }
|
||||
inline size_t available() const { return N - m_pos; }
|
||||
inline size_t pos() const { return m_pos; }
|
||||
inline void nread(size_t size) { m_pos += size; }
|
||||
inline void reset() { m_pos = 0; }
|
||||
|
||||
constexpr inline size_t size() const { return N; }
|
||||
|
||||
inline void getline(ILineListener *listener)
|
||||
{
|
||||
char *end;
|
||||
char *start = m_buf;
|
||||
size_t remaining = m_pos;
|
||||
|
||||
while ((end = static_cast<char*>(memchr(start, '\n', remaining))) != nullptr) {
|
||||
*end = '\0';
|
||||
|
||||
end++;
|
||||
const size_t len = static_cast<size_t>(end - start);
|
||||
|
||||
listener->onLine(start, len - 1);
|
||||
|
||||
remaining -= len;
|
||||
start = end;
|
||||
}
|
||||
|
||||
if (remaining == 0) {
|
||||
m_pos = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (start == m_buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(m_buf, start, remaining);
|
||||
m_pos = remaining;
|
||||
}
|
||||
|
||||
private:
|
||||
char m_buf[N];
|
||||
size_t m_pos;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_RECVBUF_H */
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -34,11 +34,11 @@ static const xmrig::String kLocalHost("127.0.0.1");
|
|||
|
||||
xmrig::TcpServer::TcpServer(const String &host, uint16_t port, ITcpServerListener *listener) :
|
||||
m_host(host.isNull() ? kLocalHost : host),
|
||||
m_version(0),
|
||||
m_listener(listener),
|
||||
m_addr(),
|
||||
m_port(port)
|
||||
{
|
||||
assert(m_listener != nullptr);
|
||||
|
||||
m_tcp = new uv_tcp_t;
|
||||
uv_tcp_init(uv_default_loop(), m_tcp);
|
||||
m_tcp->data = this;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -29,6 +29,9 @@
|
|||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -39,6 +42,8 @@ class String;
|
|||
class TcpServer
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(TcpServer)
|
||||
|
||||
TcpServer(const String &host, uint16_t port, ITcpServerListener *listener);
|
||||
~TcpServer();
|
||||
|
||||
|
@ -50,9 +55,9 @@ private:
|
|||
static void onConnection(uv_stream_t *stream, int status);
|
||||
|
||||
const String &m_host;
|
||||
int m_version;
|
||||
int m_version = 0;
|
||||
ITcpServerListener *m_listener;
|
||||
sockaddr_storage m_addr;
|
||||
sockaddr_storage m_addr{};
|
||||
uint16_t m_port;
|
||||
uv_tcp_t *m_tcp;
|
||||
};
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -52,6 +52,23 @@ bool xmrig::Arguments::hasArg(const char *name) const
|
|||
}
|
||||
|
||||
|
||||
const char *xmrig::Arguments::value(const char *key) const
|
||||
{
|
||||
const size_t size = m_data.size();
|
||||
if (size < 3) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < size - 1; ++i) {
|
||||
if (m_data[i] == key) {
|
||||
return m_data[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Arguments::add(const char *arg)
|
||||
{
|
||||
if (arg == nullptr) {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -41,6 +41,7 @@ public:
|
|||
Arguments(int argc, char **argv);
|
||||
|
||||
bool hasArg(const char *name) const;
|
||||
const char *value(const char *key) const;
|
||||
|
||||
inline char **argv() const { return m_argv; }
|
||||
inline const std::vector<String> &data() const { return m_data; }
|
||||
|
|
|
@ -79,6 +79,15 @@
|
|||
"retries": 5,
|
||||
"retry-pause": 5,
|
||||
"syslog": false,
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"protocols": null,
|
||||
"cert": null,
|
||||
"cert_key": null,
|
||||
"ciphers": null,
|
||||
"ciphersuites": null,
|
||||
"dhparam": null
|
||||
},
|
||||
"user-agent": null,
|
||||
"verbose": 0,
|
||||
"watch": true
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "core/Miner.h"
|
||||
#include "crypto/common/Nonce.h"
|
||||
#include "crypto/rx/Rx.h"
|
||||
#include "crypto/astrobwt/AstroBWT.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "version.h"
|
||||
|
||||
|
@ -242,6 +243,10 @@ public:
|
|||
# endif
|
||||
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
inline bool initAstroBWT() { return astrobwt::init(job); }
|
||||
# endif
|
||||
|
||||
Algorithm algorithm;
|
||||
Algorithms algorithms;
|
||||
bool active = false;
|
||||
|
@ -454,10 +459,14 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
|
|||
d_ptr->userJobId = job.id();
|
||||
}
|
||||
|
||||
bool ready = true;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
const bool ready = d_ptr->initRX();
|
||||
# else
|
||||
constexpr const bool ready = true;
|
||||
ready &= d_ptr->initRX();
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
ready &= d_ptr->initAstroBWT();
|
||||
# endif
|
||||
|
||||
mutex.unlock();
|
||||
|
|
|
@ -212,7 +212,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value api(kObjectType);
|
||||
api.AddMember(StringRef(kApiId), m_apiId.toJSON(), allocator);
|
||||
api.AddMember(StringRef(kApiId), m_apiId.toJSON(), allocator);
|
||||
api.AddMember(StringRef(kApiWorkerId), m_apiWorkerId.toJSON(), allocator);
|
||||
|
||||
doc.AddMember(StringRef(kApi), api, allocator);
|
||||
|
@ -246,6 +246,11 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
doc.AddMember(StringRef(Pools::kRetries), m_pools.retries(), allocator);
|
||||
doc.AddMember(StringRef(Pools::kRetryPause), m_pools.retryPause(), allocator);
|
||||
doc.AddMember(StringRef(kSyslog), isSyslog(), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
doc.AddMember(StringRef(kTls), m_tls.toJSON(doc), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
||||
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
||||
|
|
|
@ -159,6 +159,9 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
|
|||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
case IConfig::AstroBWTMaxSizeKey: /* --astrobwt-max-size */
|
||||
return set(doc, kCpu, "astrobwt-max-size", static_cast<uint64_t>(strtol(arg, nullptr, 10)));
|
||||
|
||||
case IConfig::AstroBWTAVX2Key: /* --astrobwt-avx2 */
|
||||
return set(doc, kCpu, "astrobwt-avx2", true);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue