forked from xmrig/xmrig
-
Notifications
You must be signed in to change notification settings - Fork 0
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
18 changed files
with
979 additions
and
750 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 | ||
|
@@ -49,6 +49,12 @@ class Platform | |
static inline bool isUserActive(uint64_t ms) { return idleTime() < ms; } | ||
static inline const String &userAgent() { return m_userAgent; } | ||
|
||
# ifdef XMRIG_OS_WIN | ||
static bool hasKeepalive(); | ||
# else | ||
static constexpr bool hasKeepalive() { return true; } | ||
# endif | ||
|
||
static bool isOnBatteryPower(); | ||
static uint64_t idleTime(); | ||
|
||
|
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 <algorithm> | ||
#include <winsock2.h> | ||
#include <windows.h> | ||
|
@@ -70,6 +69,12 @@ char *xmrig::Platform::createUserAgent() | |
} | ||
|
||
|
||
bool xmrig::Platform::hasKeepalive() | ||
{ | ||
return winOsVersion().dwMajorVersion >= 6; | ||
} | ||
|
||
|
||
#ifndef XMRIG_FEATURE_HWLOC | ||
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) | ||
{ | ||
|
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) 2019 jtgrassie <https://github.com/jtgrassie> | ||
* 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 | ||
|
@@ -42,13 +42,14 @@ | |
#include "base/io/json/JsonRequest.h" | ||
#include "base/io/log/Log.h" | ||
#include "base/kernel/interfaces/IClientListener.h" | ||
#include "base/kernel/Platform.h" | ||
#include "base/net/dns/Dns.h" | ||
#include "base/net/dns/DnsRecords.h" | ||
#include "base/net/stratum/Socks5.h" | ||
#include "base/net/tools/NetBuffer.h" | ||
#include "base/tools/Chrono.h" | ||
#include "base/tools/Cvt.h" | ||
#include "base/tools/cryptonote/BlobReader.h" | ||
#include "base/tools/Cvt.h" | ||
#include "net/JobResult.h" | ||
|
||
|
||
|
@@ -343,6 +344,9 @@ bool xmrig::Client::close() | |
setState(ClosingState); | ||
|
||
if (uv_is_closing(reinterpret_cast<uv_handle_t*>(m_socket)) == 0) { | ||
if (Platform::hasKeepalive()) { | ||
uv_tcp_keepalive(m_socket, 0, 60); | ||
} | ||
uv_close(reinterpret_cast<uv_handle_t*>(m_socket), Client::onClose); | ||
} | ||
|
||
|
@@ -567,9 +571,9 @@ void xmrig::Client::connect(const sockaddr *addr) | |
uv_tcp_init(uv_default_loop(), m_socket); | ||
uv_tcp_nodelay(m_socket, 1); | ||
|
||
# ifndef WIN32 | ||
uv_tcp_keepalive(m_socket, 1, 60); | ||
# endif | ||
if (Platform::hasKeepalive()) { | ||
uv_tcp_keepalive(m_socket, 1, 60); | ||
} | ||
|
||
uv_tcp_connect(req, m_socket, addr, onConnect); | ||
} | ||
|
@@ -585,7 +589,7 @@ void xmrig::Client::handshake() | |
if (isTLS()) { | ||
m_expire = Chrono::steadyMSecs() + kResponseTimeout; | ||
|
||
m_tls->handshake(); | ||
m_tls->handshake(m_pool.isSNI() ? m_pool.host().data() : nullptr); | ||
} | ||
else | ||
# 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,13 +1,13 @@ | ||
/* XMRig | ||
* Copyright 2010 Jeff Garzik <[email protected]> | ||
* Copyright 2012-2014 pooler <[email protected]> | ||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones> | ||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> | ||
* Copyright 2016 Jay D Dee <[email protected]> | ||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> | ||
* Copyright 2019 Howard Chu <https://github.com/hyc> | ||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2010 Jeff Garzik <[email protected]> | ||
* Copyright (c) 2012-2014 pooler <[email protected]> | ||
* Copyright (c) 2014 Lucas Jones <https://github.com/lucasjones> | ||
* Copyright (c) 2014-2016 Wolf9466 <https://github.com/OhGodAPet> | ||
* Copyright (c) 2016 Jay D Dee <[email protected]> | ||
* Copyright (c) 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> | ||
* Copyright (c) 2019 Howard Chu <https://github.com/hyc> | ||
* 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 | ||
|
@@ -23,7 +23,6 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include <uv.h> | ||
|
||
|
||
|
@@ -34,6 +33,7 @@ | |
#include "base/io/json/JsonRequest.h" | ||
#include "base/io/log/Log.h" | ||
#include "base/kernel/interfaces/IClientListener.h" | ||
#include "base/kernel/Platform.h" | ||
#include "base/net/dns/Dns.h" | ||
#include "base/net/dns/DnsRecords.h" | ||
#include "base/net/http/Fetch.h" | ||
|
@@ -42,9 +42,9 @@ | |
#include "base/net/stratum/SubmitResult.h" | ||
#include "base/net/tools/NetBuffer.h" | ||
#include "base/tools/bswap_64.h" | ||
#include "base/tools/cryptonote/Signatures.h" | ||
#include "base/tools/Cvt.h" | ||
#include "base/tools/Timer.h" | ||
#include "base/tools/cryptonote/Signatures.h" | ||
#include "net/JobResult.h" | ||
|
||
|
||
|
@@ -358,9 +358,9 @@ void xmrig::DaemonClient::onResolved(const DnsRecords &records, int status, cons | |
uv_tcp_init(uv_default_loop(), s); | ||
uv_tcp_nodelay(s, 1); | ||
|
||
# ifndef WIN32 | ||
uv_tcp_keepalive(s, 1, 60); | ||
# endif | ||
if (Platform::hasKeepalive()) { | ||
uv_tcp_keepalive(s, 1, 60); | ||
} | ||
|
||
if (m_pool.zmq_port() > 0) { | ||
delete m_ZMQSocket; | ||
|
@@ -589,6 +589,9 @@ void xmrig::DaemonClient::retry() | |
} | ||
|
||
if ((m_ZMQConnectionState != ZMQ_NOT_CONNECTED) && (m_ZMQConnectionState != ZMQ_DISCONNECTING)) { | ||
if (Platform::hasKeepalive()) { | ||
uv_tcp_keepalive(m_ZMQSocket, 0, 60); | ||
} | ||
uv_close(reinterpret_cast<uv_handle_t*>(m_ZMQSocket), onZMQClose); | ||
} | ||
|
||
|
@@ -916,6 +919,9 @@ bool xmrig::DaemonClient::ZMQClose(bool shutdown) | |
m_ZMQConnectionState = ZMQ_DISCONNECTING; | ||
|
||
if (uv_is_closing(reinterpret_cast<uv_handle_t*>(m_ZMQSocket)) == 0) { | ||
if (Platform::hasKeepalive()) { | ||
uv_tcp_keepalive(m_ZMQSocket, 0, 60); | ||
} | ||
uv_close(reinterpret_cast<uv_handle_t*>(m_ZMQSocket), shutdown ? onZMQShutdown : onZMQClose); | ||
if (!shutdown) { | ||
retry(); | ||
|
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
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
Oops, something went wrong.