From 034720e888b6d772723916d6f0d040bd20f04c8a Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 28 Mar 2019 22:13:27 +0700 Subject: [PATCH] Use XMRIG_FEATURE_TLS instead of XMRIG_NO_TLS --- cmake/OpenSSL.cmake | 2 -- src/base/kernel/Entry.cpp | 4 ++-- src/base/net/stratum/Client.cpp | 20 ++++++++++---------- src/base/net/stratum/Client.h | 2 +- src/base/net/stratum/Pool.cpp | 2 +- src/common/Platform.cpp | 4 ++-- src/common/config/CommonConfig.cpp | 6 +++--- src/common/config/ConfigLoader.cpp | 10 ---------- 8 files changed, 19 insertions(+), 31 deletions(-) diff --git a/cmake/OpenSSL.cmake b/cmake/OpenSSL.cmake index 219d50b9..bcdea0c6 100644 --- a/cmake/OpenSSL.cmake +++ b/cmake/OpenSSL.cmake @@ -18,12 +18,10 @@ if (WITH_TLS) endif() add_definitions(/DXMRIG_FEATURE_TLS) - remove_definitions(/DXMRIG_NO_TLS) else() set(TLS_SOURCES "") set(OPENSSL_LIBRARIES "") remove_definitions(/DXMRIG_FEATURE_TLS) - add_definitions(/DXMRIG_NO_TLS) set(CMAKE_PROJECT_NAME "${CMAKE_PROJECT_NAME}-notls") endif() diff --git a/src/base/kernel/Entry.cpp b/src/base/kernel/Entry.cpp index 84c4c971..5b335453 100644 --- a/src/base/kernel/Entry.cpp +++ b/src/base/kernel/Entry.cpp @@ -32,7 +32,7 @@ #endif -#ifndef XMRIG_NO_TLS +#ifdef XMRIG_FEATURE_TLS # include #endif @@ -77,7 +77,7 @@ static int showVersion() printf("microhttpd/%s\n", MHD_get_version()); # endif -# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT) +# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT) { constexpr const char *v = OPENSSL_VERSION_TEXT + 8; printf("OpenSSL/%.*s\n", static_cast(strchr(v, ' ') - v), v); diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 88d96871..667dd448 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -30,7 +30,7 @@ #include -#ifndef XMRIG_NO_TLS +#ifdef XMRIG_FEATURE_TLS # include # include # include "base/net/stratum/Tls.h" @@ -107,7 +107,7 @@ xmrig::Client::~Client() void xmrig::Client::connect() { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (m_pool.isTLS()) { m_tls = new Tls(this); } @@ -184,7 +184,7 @@ bool xmrig::Client::disconnect() bool xmrig::Client::isTLS() const { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS return m_pool.isTLS() && m_tls; # else return false; @@ -194,7 +194,7 @@ bool xmrig::Client::isTLS() const const char *xmrig::Client::tlsFingerprint() const { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (isTLS() && m_pool.fingerprint() == nullptr) { return m_tls->fingerprint(); } @@ -206,7 +206,7 @@ const char *xmrig::Client::tlsFingerprint() const const char *xmrig::Client::tlsVersion() const { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (isTLS()) { return m_tls->version(); } @@ -435,7 +435,7 @@ bool xmrig::Client::parseLogin(const rapidjson::Value &result, int *code) bool xmrig::Client::send(BIO *bio) { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS uv_buf_t buf; buf.len = BIO_get_mem_data(bio, &buf.base); @@ -543,7 +543,7 @@ int64_t xmrig::Client::send(size_t size) { LOG_DEBUG("[%s] send (%d bytes): \"%s\"", url(), size, m_sendBuf); -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (isTLS()) { if (!m_tls->send(m_sendBuf, size)) { return -1; @@ -597,7 +597,7 @@ void xmrig::Client::connect(sockaddr *addr) void xmrig::Client::handshake() { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (isTLS()) { m_expire = Chrono::steadyMSecs() + kResponseTimeout; @@ -661,7 +661,7 @@ void xmrig::Client::onClose() m_socket = nullptr; setState(UnconnectedState); -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (m_tls) { delete m_tls; m_tls = nullptr; @@ -858,7 +858,7 @@ void xmrig::Client::read(ssize_t nread) m_recvBuf.nread(size); -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS if (isTLS()) { LOG_DEBUG("[%s] TLS received (%d bytes)", url(), static_cast(nread)); diff --git a/src/base/net/stratum/Client.h b/src/base/net/stratum/Client.h index c0ea8a93..65b44a5b 100644 --- a/src/base/net/stratum/Client.h +++ b/src/base/net/stratum/Client.h @@ -75,7 +75,7 @@ public: constexpr static int kResponseTimeout = 20 * 1000; -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS constexpr static int kInputBufferSize = 1024 * 16; # else constexpr static int kInputBufferSize = 1024 * 2; diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index 64543a95..2c48ab0b 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -178,7 +178,7 @@ bool xmrig::Pool::isCompatible(const Algorithm &algorithm) const bool xmrig::Pool::isEnabled() const { -# ifdef XMRIG_NO_TLS +# ifndef XMRIG_FEATURE_TLS if (isTLS()) { return false; } diff --git a/src/common/Platform.cpp b/src/common/Platform.cpp index 6bd0ac80..a74f1978 100644 --- a/src/common/Platform.cpp +++ b/src/common/Platform.cpp @@ -27,7 +27,7 @@ #include -#ifndef XMRIG_NO_TLS +#ifdef XMRIG_FEATURE_TLS # include # include #endif @@ -41,7 +41,7 @@ xmrig::String Platform::m_userAgent; void Platform::init(const char *userAgent) { -# ifndef XMRIG_NO_TLS +# ifdef XMRIG_FEATURE_TLS SSL_library_init(); SSL_load_error_strings(); ERR_load_BIO_strings(); diff --git a/src/common/config/CommonConfig.cpp b/src/common/config/CommonConfig.cpp index 0de10b1e..94a20f80 100644 --- a/src/common/config/CommonConfig.cpp +++ b/src/common/config/CommonConfig.cpp @@ -35,7 +35,7 @@ #endif -#ifndef XMRIG_NO_TLS +#ifdef XMRIG_FEATURE_TLS # include #endif @@ -131,12 +131,12 @@ void xmrig::CommonConfig::printVersions() # else memset(buf, 0, 16); -# if !defined(XMRIG_NO_HTTPD) || !defined(XMRIG_NO_TLS) +# if !defined(XMRIG_NO_HTTPD) || defined(XMRIG_FEATURE_TLS) int length = 0; # endif # endif -# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT) +# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT) { constexpr const char *v = OPENSSL_VERSION_TEXT + 8; length += snprintf(buf + length, (sizeof buf) - length, "OpenSSL/%.*s ", static_cast(strchr(v, ' ') - v), v); diff --git a/src/common/config/ConfigLoader.cpp b/src/common/config/ConfigLoader.cpp index 26742e5f..4b251fa2 100644 --- a/src/common/config/ConfigLoader.cpp +++ b/src/common/config/ConfigLoader.cpp @@ -29,16 +29,6 @@ #include -#ifndef XMRIG_NO_HTTPD -# include -#endif - - -#ifndef XMRIG_NO_TLS -# include -#endif - - #include "base/io/Json.h" #include "base/kernel/interfaces/IConfigListener.h" #include "base/kernel/Process.h"