Fixed TLS build on Windows GCC/MVSC
Cleanup TLS compile
This commit is contained in:
parent
48493bbbb2
commit
9d0f570577
13 changed files with 66 additions and 51 deletions
|
@ -70,7 +70,7 @@ if (WIN32)
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(/DWIN32)
|
add_definitions(/DWIN32)
|
||||||
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv)
|
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv crypt32)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set(SOURCES_OS
|
set(SOURCES_OS
|
||||||
src/App_unix.cpp
|
src/App_unix.cpp
|
||||||
|
@ -113,7 +113,7 @@ find_package(UV REQUIRED)
|
||||||
include(cmake/flags.cmake)
|
include(cmake/flags.cmake)
|
||||||
|
|
||||||
if (WITH_TLS)
|
if (WITH_TLS)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL)
|
||||||
|
|
||||||
add_definitions(/DCPPHTTPLIB_OPENSSL_SUPPORT)
|
add_definitions(/DCPPHTTPLIB_OPENSSL_SUPPORT)
|
||||||
|
|
||||||
|
@ -218,21 +218,30 @@ endif (WITH_CC_SERVER OR WITH_CC_CLIENT)
|
||||||
|
|
||||||
add_executable(xmrigMiner ${SOURCES} ${SOURCES_CRYPTO} ${HTTPD_SOURCES} ${SOURCES_CC_CLIENT} res/app.rc)
|
add_executable(xmrigMiner ${SOURCES} ${SOURCES_CRYPTO} ${HTTPD_SOURCES} ${SOURCES_CC_CLIENT} res/app.rc)
|
||||||
|
|
||||||
target_link_libraries(xmrigMiner xmrig_tls xmrig_common xmrig_os_dependencies xmrig_cpuid
|
target_link_libraries(xmrigMiner xmrig_common xmrig_os_dependencies xmrig_cpuid
|
||||||
${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB} ${OPENSSL_LIBRARIES})
|
${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||||
|
|
||||||
if (WITH_CC_CLIENT)
|
if (WITH_CC_CLIENT)
|
||||||
target_link_libraries(xmrigMiner xmrig_cc_common)
|
target_link_libraries(xmrigMiner xmrig_cc_common)
|
||||||
endif (WITH_CC_CLIENT)
|
endif (WITH_CC_CLIENT)
|
||||||
|
|
||||||
|
if (WITH_TLS)
|
||||||
|
target_link_libraries(xmrigMiner xmrig_tls OpenSSL::SSL OpenSSL::Crypto)
|
||||||
|
endif (WITH_TLS)
|
||||||
|
|
||||||
add_executable(xmrigDaemon src/cc/XMRigd.cpp res/app.rc)
|
add_executable(xmrigDaemon src/cc/XMRigd.cpp res/app.rc)
|
||||||
|
|
||||||
if (WITH_CC_SERVER AND MHD_FOUND)
|
if (WITH_CC_SERVER AND MHD_FOUND)
|
||||||
add_library(xmrig_common_cc STATIC ${SOURCES_COMMON})
|
add_library(xmrig_common_cc STATIC ${SOURCES_COMMON})
|
||||||
add_executable(xmrigCCServer ${SOURCES_CC_SERVER} res/app.rc)
|
add_executable(xmrigCCServer ${SOURCES_CC_SERVER} res/app.rc)
|
||||||
target_link_libraries(xmrigCCServer
|
target_link_libraries(xmrigCCServer
|
||||||
xmrig_common_cc xmrig_os_dependencies xmrig_cpuid xmrig_cc_common xmrig_tls
|
xmrig_common_cc xmrig_os_dependencies xmrig_cpuid xmrig_cc_common
|
||||||
${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||||
|
|
||||||
|
if (WITH_TLS)
|
||||||
|
target_link_libraries(xmrigCCServer xmrig_tls OpenSSL::SSL OpenSSL::Crypto)
|
||||||
|
endif (WITH_TLS)
|
||||||
|
|
||||||
set_target_properties(xmrig_common_cc PROPERTIES COMPILE_FLAGS "-DXMRIG_CC_SERVER ${SHARED_FLAGS}")
|
set_target_properties(xmrig_common_cc PROPERTIES COMPILE_FLAGS "-DXMRIG_CC_SERVER ${SHARED_FLAGS}")
|
||||||
set_target_properties(xmrigCCServer PROPERTIES COMPILE_FLAGS "-DXMRIG_CC_SERVER ${SHARED_FLAGS}")
|
set_target_properties(xmrigCCServer PROPERTIES COMPILE_FLAGS "-DXMRIG_CC_SERVER ${SHARED_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
5
src/3rdparty/clib-net/deps/buffer/buffer.h
vendored
5
src/3rdparty/clib-net/deps/buffer/buffer.h
vendored
|
@ -10,6 +10,11 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default buffer size.
|
* Default buffer size.
|
||||||
*/
|
*/
|
||||||
|
|
43
src/3rdparty/clib-net/include/net.h
vendored
43
src/3rdparty/clib-net/include/net.h
vendored
|
@ -26,37 +26,22 @@ typedef struct net_s net_t;
|
||||||
typedef struct addrinfo net_ai;
|
typedef struct addrinfo net_ai;
|
||||||
typedef struct sockaddr_in socketPair_t;
|
typedef struct sockaddr_in socketPair_t;
|
||||||
|
|
||||||
#define NET_FIELDS \
|
|
||||||
NET_CONNECTION_FIELDS \
|
|
||||||
NET_UV_FIELDS \
|
|
||||||
NET_TLS_FIELDS \
|
|
||||||
|
|
||||||
#define NET_CONNECTION_FIELDS \
|
|
||||||
char *hostname; \
|
|
||||||
int port; \
|
|
||||||
int connected; \
|
|
||||||
|
|
||||||
|
|
||||||
#define NET_UV_FIELDS \
|
|
||||||
uv_getaddrinfo_t *resolver; \
|
|
||||||
uv_loop_t *loop; \
|
|
||||||
uv_tcp_t *handle; \
|
|
||||||
uv_connect_t *conn; \
|
|
||||||
|
|
||||||
#ifndef XMRIG_NO_TLS
|
|
||||||
#define NET_TLS_FIELDS \
|
|
||||||
int use_ssl; \
|
|
||||||
int tls_established; \
|
|
||||||
tls_t *tls;
|
|
||||||
#else
|
|
||||||
#define NET_TLS_FIELDS \
|
|
||||||
int use_ssl; \
|
|
||||||
int tls_established;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
struct net_s {
|
struct net_s {
|
||||||
NET_FIELDS;
|
char *hostname;
|
||||||
|
int port;
|
||||||
|
int connected;
|
||||||
|
uv_getaddrinfo_t *resolver;
|
||||||
|
uv_loop_t *loop;
|
||||||
|
uv_tcp_t *handle;
|
||||||
|
uv_connect_t *conn;
|
||||||
|
int use_ssl;
|
||||||
|
int tls_established;
|
||||||
|
|
||||||
|
#ifndef XMRIG_NO_TLS
|
||||||
|
tls_t *tls;
|
||||||
|
#endif
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
void (*conn_cb)(net_t*);
|
void (*conn_cb)(net_t*);
|
||||||
void (*read_cb)(net_t*, size_t, char*);
|
void (*read_cb)(net_t*, size_t, char*);
|
||||||
|
|
8
src/3rdparty/clib-net/src/net.c
vendored
8
src/3rdparty/clib-net/src/net.c
vendored
|
@ -213,14 +213,15 @@ net_connect_cb(uv_connect_t *conn, int err) {
|
||||||
do {
|
do {
|
||||||
read = tls_bio_read(net->tls, 0);
|
read = tls_bio_read(net->tls, 0);
|
||||||
if (read > 0) {
|
if (read > 0) {
|
||||||
char buf[read];
|
char* buf = (char *) calloc(read, 1);
|
||||||
uv_write_t * req = malloc(sizeof(uv_write_t));
|
uv_write_t * req = malloc(sizeof(uv_write_t));
|
||||||
req->data = net;
|
req->data = net;
|
||||||
memset(buf, 0, read);
|
memset(buf, 0, read);
|
||||||
memcpy(buf, net->tls->buf, read);
|
memcpy(buf, net->tls->buf, read);
|
||||||
uv_buf_t uvbuf = uv_buf_init(buf, read);
|
uv_buf_t uvbuf = uv_buf_init(buf, read);
|
||||||
uv_write(req, (uv_stream_t*)net->handle, &uvbuf, 1, net_write_cb);
|
uv_write(req, (uv_stream_t*)net->handle, &uvbuf, 1, net_write_cb);
|
||||||
}
|
free(buf);
|
||||||
|
}
|
||||||
} while (read > 0);
|
} while (read > 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -267,13 +268,14 @@ net_read(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
||||||
do {
|
do {
|
||||||
read = tls_bio_read(net->tls, 0);
|
read = tls_bio_read(net->tls, 0);
|
||||||
if (read > 0) {
|
if (read > 0) {
|
||||||
char buf2[read];
|
char* buf2 = (char *) calloc(read, 1);
|
||||||
uv_write_t * req = malloc(sizeof(uv_write_t));
|
uv_write_t * req = malloc(sizeof(uv_write_t));
|
||||||
req->data = net;
|
req->data = net;
|
||||||
memset(buf2, 0, read);
|
memset(buf2, 0, read);
|
||||||
memcpy(buf2, net->tls->buf, read);
|
memcpy(buf2, net->tls->buf, read);
|
||||||
uv_buf_t uvbuf = uv_buf_init(buf2, read);
|
uv_buf_t uvbuf = uv_buf_init(buf2, read);
|
||||||
uv_write(req, (uv_stream_t*)net->handle, &uvbuf, 1, net_write_cb);
|
uv_write(req, (uv_stream_t*)net->handle, &uvbuf, 1, net_write_cb);
|
||||||
|
free(buf2);
|
||||||
}
|
}
|
||||||
} while (read > 0);
|
} while (read > 0);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ void CpuImpl::setAffinity(int id, uint64_t mask)
|
||||||
|
|
||||||
int threadCount = 0;
|
int threadCount = 0;
|
||||||
|
|
||||||
for (int i = 0; i < m_totalThreads; i++) {
|
for (size_t i = 0; i < m_totalThreads; i++) {
|
||||||
if (threadAffinityMask.test(i)) {
|
if (threadAffinityMask.test(i)) {
|
||||||
if (threadCount == id) {
|
if (threadCount == id) {
|
||||||
SetThreadAffinityMask(GetCurrentThread(), 1ULL << i);
|
SetThreadAffinityMask(GetCurrentThread(), 1ULL << i);
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool Mem::allocate(const Options* options)
|
||||||
m_memorySize = 0;
|
m_memorySize = 0;
|
||||||
|
|
||||||
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE;
|
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE;
|
||||||
for (int i=0; i < m_threads; i++) {
|
for (size_t i=0; i < m_threads; i++) {
|
||||||
m_memorySize += sizeof(cryptonight_ctx);
|
m_memorySize += sizeof(cryptonight_ctx);
|
||||||
m_memorySize += scratchPadSize * getThreadHashFactor(i);
|
m_memorySize += scratchPadSize * getThreadHashFactor(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,10 +91,10 @@ Options:\n"
|
||||||
# ifndef XMRIG_NO_CC
|
# ifndef XMRIG_NO_CC
|
||||||
"\
|
"\
|
||||||
--cc-url=URL url of the CC Server\n\
|
--cc-url=URL url of the CC Server\n\
|
||||||
--cc-use-tls enable tls encryption for CC communication\
|
--cc-use-tls enable tls encryption for CC communication\n\
|
||||||
--cc-access-token=T access token for CC Server\n\
|
--cc-access-token=T access token for CC Server\n\
|
||||||
--cc-worker-id=ID custom worker-id for CC Server\n\
|
--cc-worker-id=ID custom worker-id for CC Server\n\
|
||||||
--cc-update-interval-s status update interval in seconds (default: 10 min: 1)\n"
|
--cc-update-interval-s=N status update interval in seconds (default: 10 min: 1)\n"
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ Options:\n"
|
||||||
--cc-pass=PASSWORD CC Server admin pass\n\
|
--cc-pass=PASSWORD CC Server admin pass\n\
|
||||||
--cc-access-token=T CC Server access token for CC Client\n\
|
--cc-access-token=T CC Server access token for CC Client\n\
|
||||||
--cc-port=N CC Server port\n\
|
--cc-port=N CC Server port\n\
|
||||||
--cc-use-tls enable tls encryption for CC communication \
|
--cc-use-tls enable tls encryption for CC communication\n\
|
||||||
--cc-cert-file=FILE when tls is turned on, use this to point to the right cert file (default: server.pem) \
|
--cc-cert-file=FILE when tls is turned on, use this to point to the right cert file (default: server.pem) \n\
|
||||||
--cc-key-file when tls is turned on, use this to point to the right key file (default: server.key) \
|
--cc-key-file=FILE when tls is turned on, use this to point to the right key file (default: server.key) \n\
|
||||||
--cc-client-config-folder=FOLDER Folder contains the client config files\n\
|
--cc-client-config-folder=FOLDER Folder contains the client config files\n\
|
||||||
--cc-custom-dashboard=FILE loads a custom dashboard and serve it to '/'\n"
|
--cc-custom-dashboard=FILE loads a custom dashboard and serve it to '/'\n"
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool Httpd::start()
|
||||||
m_keyPem = readFile(m_options->ccKeyFile());
|
m_keyPem = readFile(m_options->ccKeyFile());
|
||||||
m_certPem = readFile(m_options->ccCertFile());
|
m_certPem = readFile(m_options->ccCertFile());
|
||||||
|
|
||||||
if (m_keyPem.length() == 0 || m_certPem.length() == 0) {
|
if (m_keyPem.empty() || m_certPem.empty()) {
|
||||||
LOG_ERR("HTTPS Daemon failed to start. Unable to load Key/Cert.");
|
LOG_ERR("HTTPS Daemon failed to start. Unable to load Key/Cert.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,8 @@ static void print_versions()
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mVERSIONS: \x1B[01;36m%s/%s\x1B[01;37m libuv/%s%s \x1B[01;36m(%s)" : " * VERSIONS: %s/%s libuv/%s%s (%s)",
|
||||||
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mVERSIONS: \x1B[01;36m%s/%s\x1B[01;37m libuv/%s%s" : " * VERSIONS: %s/%s libuv/%s%s",
|
APP_NAME, APP_VERSION, uv_version_string(), buf, BUILD_TYPE);
|
||||||
APP_NAME, APP_VERSION, uv_version_string(), buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_commands()
|
static void print_commands()
|
||||||
|
|
|
@ -282,7 +282,7 @@ void Client::onRead(net_t *net, size_t size, char *buf)
|
||||||
{
|
{
|
||||||
auto client = getClient(net->data);
|
auto client = getClient(net->data);
|
||||||
|
|
||||||
if (size < 0) {
|
if (size == 0) {
|
||||||
if (size != UV_EOF && !client->m_quiet) {
|
if (size != UV_EOF && !client->m_quiet) {
|
||||||
LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror((int) size));
|
LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror((int) size));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,20 @@
|
||||||
#include "net/Url.h"
|
#include "net/Url.h"
|
||||||
#include "rapidjson/fwd.h"
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#ifndef XMRIG_NO_TLS
|
#ifndef XMRIG_NO_TLS
|
||||||
#include "tls.h"
|
#include "tls.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
class IClientListener;
|
class IClientListener;
|
||||||
class JobResult;
|
class JobResult;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
Url::Url() :
|
Url::Url() :
|
||||||
|
m_useTls(false),
|
||||||
m_keepAlive(false),
|
m_keepAlive(false),
|
||||||
m_nicehash(false),
|
m_nicehash(false),
|
||||||
m_host(nullptr),
|
m_host(nullptr),
|
||||||
|
|
|
@ -47,9 +47,17 @@
|
||||||
#define APP_VER_REV 0
|
#define APP_VER_REV 0
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define BUILD_TYPE "DEBUG"
|
#ifndef XMRIG_NO_TLS
|
||||||
|
#define BUILD_TYPE "DEBUG with TLS"
|
||||||
|
#else
|
||||||
|
#define BUILD_TYPE "DEBUG"
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define BUILD_TYPE "RELEASE"
|
#ifndef XMRIG_NO_TLS
|
||||||
|
#define BUILD_TYPE "RELEASE with TLS"
|
||||||
|
#else
|
||||||
|
#define BUILD_TYPE "RELEASE"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue