-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
167 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -16,7 +16,6 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include "base/kernel/Platform.h" | ||
|
||
|
||
|
@@ -42,9 +41,12 @@ void xmrig::Platform::init(const char *userAgent) | |
# ifdef XMRIG_FEATURE_TLS | ||
SSL_library_init(); | ||
SSL_load_error_strings(); | ||
|
||
# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) | ||
ERR_load_BIO_strings(); | ||
ERR_load_crypto_strings(); | ||
SSL_load_error_strings(); | ||
# endif | ||
|
||
OpenSSL_add_all_digests(); | ||
# endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -46,11 +46,11 @@ xmrig::String xmrig::DnsRecord::ip() const | |
|
||
if (m_type == AAAA) { | ||
buf = new char[45](); | ||
uv_ip6_name(reinterpret_cast<sockaddr_in6*>(m_data), buf, 45); | ||
uv_ip6_name(reinterpret_cast<const sockaddr_in6*>(m_data), buf, 45); | ||
} | ||
else { | ||
buf = new char[16](); | ||
uv_ip4_name(reinterpret_cast<sockaddr_in*>(m_data), buf, 16); | ||
uv_ip4_name(reinterpret_cast<const sockaddr_in*>(m_data), buf, 16); | ||
} | ||
|
||
return buf; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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,18 +28,19 @@ | |
|
||
namespace xmrig { | ||
|
||
static Storage<DnsUvBackend>* storage = nullptr; | ||
|
||
Storage<DnsUvBackend>& DnsUvBackend::getStorage() | ||
static Storage<DnsUvBackend> *storage = nullptr; | ||
|
||
|
||
Storage<DnsUvBackend> &DnsUvBackend::getStorage() | ||
{ | ||
if (storage == nullptr) storage = new Storage<DnsUvBackend>(); | ||
if (storage == nullptr) { | ||
storage = new Storage<DnsUvBackend>(); | ||
} | ||
|
||
return *storage; | ||
} | ||
|
||
void DnsUvBackend::releaseStorage() | ||
{ | ||
delete storage; | ||
} | ||
|
||
static addrinfo hints{}; | ||
|
||
|
@@ -61,8 +62,14 @@ xmrig::DnsUvBackend::DnsUvBackend() | |
|
||
xmrig::DnsUvBackend::~DnsUvBackend() | ||
{ | ||
getStorage().release(m_key); | ||
releaseStorage(); | ||
assert(storage); | ||
|
||
storage->release(m_key); | ||
|
||
if (storage->isEmpty()) { | ||
delete storage; | ||
storage = nullptr; | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* XMRig | ||
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -45,6 +45,7 @@ namespace xmrig { | |
|
||
|
||
// https://wiki.openssl.org/index.php/Diffie-Hellman_parameters | ||
#if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) | ||
static DH *get_dh2048() | ||
{ | ||
static unsigned char dhp_2048[] = { | ||
|
@@ -96,6 +97,8 @@ static DH *get_dh2048() | |
|
||
return dh; | ||
} | ||
#endif | ||
|
||
|
||
} // namespace xmrig | ||
|
||
|
@@ -191,6 +194,7 @@ bool xmrig::TlsContext::setCipherSuites(const char *ciphersuites) | |
|
||
bool xmrig::TlsContext::setDH(const char *dhparam) | ||
{ | ||
# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) | ||
DH *dh = nullptr; | ||
|
||
if (dhparam != nullptr) { | ||
|
@@ -225,6 +229,34 @@ bool xmrig::TlsContext::setDH(const char *dhparam) | |
|
||
return false; | ||
} | ||
# else | ||
if (dhparam != nullptr) { | ||
EVP_PKEY *dh = nullptr; | ||
BIO *bio = BIO_new_file(Env::expand(dhparam), "r"); | ||
|
||
if (bio) { | ||
dh = PEM_read_bio_Parameters(bio, nullptr); | ||
BIO_free(bio); | ||
} | ||
|
||
if (!dh) { | ||
LOG_ERR("PEM_read_bio_Parameters(\"%s\") failed.", dhparam); | ||
|
||
return false; | ||
} | ||
|
||
if (SSL_CTX_set0_tmp_dh_pkey(m_ctx, dh) != 1) { | ||
EVP_PKEY_free(dh); | ||
|
||
LOG_ERR("SSL_CTX_set0_tmp_dh_pkey(\"%s\") failed.", dhparam); | ||
|
||
return false; | ||
} | ||
} | ||
else { | ||
SSL_CTX_set_dh_auto(m_ctx, 1); | ||
} | ||
# endif | ||
|
||
return true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* XMRig | ||
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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,9 +24,6 @@ | |
#include "base/tools/Object.h" | ||
|
||
|
||
#include <cstdint> | ||
|
||
|
||
using SSL_CTX = struct ssl_ctx_st; | ||
|
||
|
||
|
@@ -60,6 +57,7 @@ class TlsContext | |
}; | ||
|
||
|
||
} /* namespace xmrig */ | ||
} // namespace xmrig | ||
|
||
|
||
#endif /* XMRIG_TLSCONTEXT_H */ | ||
#endif // XMRIG_TLSCONTEXT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -33,6 +33,7 @@ static const char *kLocalhost = "localhost"; | |
|
||
static EVP_PKEY *generate_pkey() | ||
{ | ||
# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) | ||
auto pkey = EVP_PKEY_new(); | ||
if (!pkey) { | ||
return nullptr; | ||
|
@@ -53,6 +54,9 @@ static EVP_PKEY *generate_pkey() | |
BN_free(exponent); | ||
|
||
return pkey; | ||
# else | ||
return EVP_RSA_gen(2048); | ||
# endif | ||
} | ||
|
||
|
||
|
Oops, something went wrong.