mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-12-02 12:33:56 +01:00
Merge branch 'SChernykh-patch-1' into dev
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifndef CONF_NO_TLS
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
@@ -74,6 +76,8 @@ int main(int argc, char *argv[])
|
||||
OpenSSL_add_all_digests();
|
||||
#endif
|
||||
|
||||
srand(time(0));
|
||||
|
||||
const char* sFilename = "config.txt";
|
||||
bool benchmark_mode = false;
|
||||
|
||||
|
||||
+10
@@ -76,6 +76,16 @@ null,
|
||||
*/
|
||||
"nicehash_nonce" : false,
|
||||
|
||||
/*
|
||||
* Manual hardware AES override
|
||||
*
|
||||
* Some VMs don't report AES capability correctly. You can set this value to true to enforce hardware AES or
|
||||
* to false to force disable AES or null to let the miner decide if AES is used.
|
||||
*
|
||||
* WARNING: setting this to true on a CPU that doesn't support hardware AES will crash the miner.
|
||||
*/
|
||||
"aes_override" : null,
|
||||
|
||||
/*
|
||||
* TLS Settings
|
||||
* If you need real security, make sure tls_secure_algo is enabled (otherwise MITM attack can downgrade encryption
|
||||
|
||||
+77
-29
@@ -24,18 +24,6 @@ const uint64_t keccakf_rndc[24] =
|
||||
0x8000000000008080, 0x0000000080000001, 0x8000000080008008
|
||||
};
|
||||
|
||||
const int keccakf_rotc[24] =
|
||||
{
|
||||
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
|
||||
27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
|
||||
};
|
||||
|
||||
const int keccakf_piln[24] =
|
||||
{
|
||||
10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
|
||||
15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
|
||||
};
|
||||
|
||||
// update the state with given number of rounds
|
||||
|
||||
void keccakf(uint64_t st[25], int rounds)
|
||||
@@ -63,26 +51,86 @@ void keccakf(uint64_t st[25], int rounds)
|
||||
|
||||
// Rho Pi
|
||||
t = st[1];
|
||||
for (i = 0; i < 24; ++i) {
|
||||
bc[0] = st[keccakf_piln[i]];
|
||||
st[keccakf_piln[i]] = ROTL64(t, keccakf_rotc[i]);
|
||||
t = bc[0];
|
||||
}
|
||||
st[ 1] = ROTL64(st[ 6], 44);
|
||||
st[ 6] = ROTL64(st[ 9], 20);
|
||||
st[ 9] = ROTL64(st[22], 61);
|
||||
st[22] = ROTL64(st[14], 39);
|
||||
st[14] = ROTL64(st[20], 18);
|
||||
st[20] = ROTL64(st[ 2], 62);
|
||||
st[ 2] = ROTL64(st[12], 43);
|
||||
st[12] = ROTL64(st[13], 25);
|
||||
st[13] = ROTL64(st[19], 8);
|
||||
st[19] = ROTL64(st[23], 56);
|
||||
st[23] = ROTL64(st[15], 41);
|
||||
st[15] = ROTL64(st[ 4], 27);
|
||||
st[ 4] = ROTL64(st[24], 14);
|
||||
st[24] = ROTL64(st[21], 2);
|
||||
st[21] = ROTL64(st[ 8], 55);
|
||||
st[ 8] = ROTL64(st[16], 45);
|
||||
st[16] = ROTL64(st[ 5], 36);
|
||||
st[ 5] = ROTL64(st[ 3], 28);
|
||||
st[ 3] = ROTL64(st[18], 21);
|
||||
st[18] = ROTL64(st[17], 15);
|
||||
st[17] = ROTL64(st[11], 10);
|
||||
st[11] = ROTL64(st[ 7], 6);
|
||||
st[ 7] = ROTL64(st[10], 3);
|
||||
st[10] = ROTL64(t, 1);
|
||||
|
||||
// Chi
|
||||
for (j = 0; j < 25; j += 5) {
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
bc[2] = st[j + 2];
|
||||
bc[3] = st[j + 3];
|
||||
bc[4] = st[j + 4];
|
||||
st[j ] ^= (~bc[1]) & bc[2];
|
||||
st[j + 1] ^= (~bc[2]) & bc[3];
|
||||
st[j + 2] ^= (~bc[3]) & bc[4];
|
||||
st[j + 3] ^= (~bc[4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
}
|
||||
// unrolled loop, where only last iteration is different
|
||||
j = 0;
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
|
||||
st[j ] ^= (~st[j + 1]) & st[j + 2];
|
||||
st[j + 1] ^= (~st[j + 2]) & st[j + 3];
|
||||
st[j + 2] ^= (~st[j + 3]) & st[j + 4];
|
||||
st[j + 3] ^= (~st[j + 4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
|
||||
j = 5;
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
|
||||
st[j ] ^= (~st[j + 1]) & st[j + 2];
|
||||
st[j + 1] ^= (~st[j + 2]) & st[j + 3];
|
||||
st[j + 2] ^= (~st[j + 3]) & st[j + 4];
|
||||
st[j + 3] ^= (~st[j + 4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
|
||||
j = 10;
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
|
||||
st[j ] ^= (~st[j + 1]) & st[j + 2];
|
||||
st[j + 1] ^= (~st[j + 2]) & st[j + 3];
|
||||
st[j + 2] ^= (~st[j + 3]) & st[j + 4];
|
||||
st[j + 3] ^= (~st[j + 4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
|
||||
j = 15;
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
|
||||
st[j ] ^= (~st[j + 1]) & st[j + 2];
|
||||
st[j + 1] ^= (~st[j + 2]) & st[j + 3];
|
||||
st[j + 2] ^= (~st[j + 3]) & st[j + 4];
|
||||
st[j + 3] ^= (~st[j + 4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
|
||||
j = 20;
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
bc[2] = st[j + 2];
|
||||
bc[3] = st[j + 3];
|
||||
bc[4] = st[j + 4];
|
||||
|
||||
st[j ] ^= (~bc[1]) & bc[2];
|
||||
st[j + 1] ^= (~bc[2]) & bc[3];
|
||||
st[j + 2] ^= (~bc[3]) & bc[4];
|
||||
st[j + 3] ^= (~bc[4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
|
||||
// Iota
|
||||
st[0] ^= keccakf_rndc[round];
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ using namespace rapidjson;
|
||||
/*
|
||||
* This enum needs to match index in oConfigValues, otherwise we will get a runtime error
|
||||
*/
|
||||
enum configEnum { aCpuThreadsConf, sUseSlowMem, bNiceHashMode,
|
||||
enum configEnum { aCpuThreadsConf, sUseSlowMem, bNiceHashMode, bAesOverride,
|
||||
bTlsMode, bTlsSecureAlgo, sTlsFingerprint, sPoolAddr, sWalletAddr, sPoolPwd,
|
||||
iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime,
|
||||
bDaemonMode, sOutputFile, iHttpdPort, bPreferIpv4 };
|
||||
@@ -62,6 +62,7 @@ configVal oConfigValues[] = {
|
||||
{ aCpuThreadsConf, "cpu_threads_conf", kNullType },
|
||||
{ sUseSlowMem, "use_slow_memory", kStringType },
|
||||
{ bNiceHashMode, "nicehash_nonce", kTrueType },
|
||||
{ bAesOverride, "aes_override", kNullType },
|
||||
{ bTlsMode, "use_tls", kTrueType },
|
||||
{ bTlsSecureAlgo, "tls_secure_algo", kTrueType },
|
||||
{ sTlsFingerprint, "tls_fingerprint", kStringType },
|
||||
@@ -453,11 +454,14 @@ bool jconf::parse_config(const char* sFilename)
|
||||
|
||||
printer::inst()->set_verbose_level(prv->configValues[iVerboseLevel]->GetUint64());
|
||||
|
||||
if(!NeedsAutoconf())
|
||||
{
|
||||
if(!bHaveAes)
|
||||
printer::inst()->print_msg(L0, "Your CPU doesn't support hardware AES. Don't expect high hashrates.");
|
||||
}
|
||||
if(NeedsAutoconf())
|
||||
return true;
|
||||
|
||||
if(prv->configValues[bAesOverride]->IsBool())
|
||||
bHaveAes = prv->configValues[bAesOverride]->GetBool();
|
||||
|
||||
if(!bHaveAes)
|
||||
printer::inst()->print_msg(L0, "Your CPU doesn't support hardware AES. Don't expect high hashrates.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+12
-11
@@ -78,33 +78,34 @@ bool plain_socket::set_hostname(const char* sAddr)
|
||||
return pCallback->set_socket_error_strerr("CONNECT error: GetAddrInfo: ", err);
|
||||
|
||||
addrinfo *ptr = pAddrRoot;
|
||||
addrinfo *ipv4 = nullptr, *ipv6 = nullptr;
|
||||
std::vector<addrinfo*> ipv4;
|
||||
std::vector<addrinfo*> ipv6;
|
||||
|
||||
while (ptr != nullptr)
|
||||
{
|
||||
if (ptr->ai_family == AF_INET)
|
||||
ipv4 = ptr;
|
||||
ipv4.push_back(ptr);
|
||||
if (ptr->ai_family == AF_INET6)
|
||||
ipv6 = ptr;
|
||||
ipv6.push_back(ptr);
|
||||
ptr = ptr->ai_next;
|
||||
}
|
||||
|
||||
if (ipv4 == nullptr && ipv6 == nullptr)
|
||||
if (ipv4.empty() && ipv6.empty())
|
||||
{
|
||||
freeaddrinfo(pAddrRoot);
|
||||
pAddrRoot = nullptr;
|
||||
return pCallback->set_socket_error("CONNECT error: I found some DNS records but no IPv4 or IPv6 addresses.");
|
||||
}
|
||||
else if (ipv4 != nullptr && ipv6 == nullptr)
|
||||
pSockAddr = ipv4;
|
||||
else if (ipv4 == nullptr && ipv6 != nullptr)
|
||||
pSockAddr = ipv6;
|
||||
else if (ipv4 != nullptr && ipv6 != nullptr)
|
||||
else if (!ipv4.empty() && ipv6.empty())
|
||||
pSockAddr = ipv4[rand() % ipv4.size()];
|
||||
else if (ipv4.empty() && !ipv6.empty())
|
||||
pSockAddr = ipv6[rand() % ipv6.size()];
|
||||
else if (!ipv4.empty() && !ipv6.empty())
|
||||
{
|
||||
if(jconf::inst()->PreferIpv4())
|
||||
pSockAddr = ipv4;
|
||||
pSockAddr = ipv4[rand() % ipv4.size()];
|
||||
else
|
||||
pSockAddr = ipv6;
|
||||
pSockAddr = ipv6[rand() % ipv6.size()];
|
||||
}
|
||||
|
||||
hSocket = socket(pSockAddr->ai_family, pSockAddr->ai_socktype, pSockAddr->ai_protocol);
|
||||
|
||||
Reference in New Issue
Block a user