Skip to content

Commit

Permalink
Merged xmrig-proxy v6.21.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MoneroOcean committed Dec 15, 2023
2 parents 3f66272 + a105609 commit 67209ed
Show file tree
Hide file tree
Showing 20 changed files with 203 additions and 295 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v6.21.0
- [#548](https://github.com/xmrig/xmrig-proxy/pull/548) Sync changes with XMRig.
- [#553](https://github.com/xmrig/xmrig-proxy/pull/553) Fixes for **Zephyr** solo mining.

# v6.20.0
- [#538](https://github.com/xmrig/xmrig-proxy/pull/538) Added [Zephyr](https://www.zephyrprotocol.com/) coin support for solo mining.

# v6.19.2
- [#532](https://github.com/xmrig/xmrig-proxy/pull/532) Added view tag calculation (fixes Wownero solo mining issue).
- Sync with latest XMRig.
Expand Down
19 changes: 17 additions & 2 deletions src/base/api/Api.cpp
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>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand Down Expand Up @@ -123,6 +123,21 @@ void xmrig::Api::stop()
}


void xmrig::Api::tick()
{
# ifdef XMRIG_FEATURE_HTTP
if (m_httpd->isBound() || !m_base->config()->http().isEnabled()) {
return;
}

if (++m_ticks % 10 == 0) {
m_ticks = 0;
m_httpd->start();
}
# endif
}


void xmrig::Api::onConfigChanged(Config *config, Config *previousConfig)
{
if (config->apiId() != previousConfig->apiId()) {
Expand Down
15 changes: 8 additions & 7 deletions src/base/api/Api.h
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>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand All @@ -21,7 +21,6 @@


#include <vector>
#include <cstdint>


#include "base/kernel/interfaces/IBaseListener.h"
Expand All @@ -44,7 +43,7 @@ class Api : public IBaseListener
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Api)

Api(Base *base);
explicit Api(Base *base);
~Api() override;

inline const char *id() const { return m_id; }
Expand All @@ -54,6 +53,7 @@ class Api : public IBaseListener
void request(const HttpData &req);
void start();
void stop();
void tick();

protected:
void onConfigChanged(Config *config, Config *previousConfig) override;
Expand All @@ -65,14 +65,15 @@ class Api : public IBaseListener

Base *m_base;
char m_id[32]{};
String m_workerId;
const uint64_t m_timestamp;
Httpd *m_httpd = nullptr;
Httpd *m_httpd = nullptr;
std::vector<IApiListener *> m_listeners;
String m_workerId;
uint8_t m_ticks = 0;
};


} // namespace xmrig


#endif /* XMRIG_API_H */
#endif // XMRIG_API_H
17 changes: 7 additions & 10 deletions src/base/api/Httpd.h
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>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand All @@ -22,11 +22,6 @@

#include "base/kernel/interfaces/IBaseListener.h"
#include "base/net/http/HttpListener.h"
#include "base/tools/Object.h"


#include <cstdint>
#include <memory>


namespace xmrig {
Expand All @@ -43,9 +38,11 @@ class Httpd : public IBaseListener, public IHttpListener
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Httpd)

Httpd(Base *base);
explicit Httpd(Base *base);
~Httpd() override;

inline bool isBound() const { return m_server != nullptr; }

bool start();
void stop();

Expand All @@ -69,7 +66,7 @@ class Httpd : public IBaseListener, public IHttpListener
};


} /* namespace xmrig */
} // namespace xmrig


#endif /* XMRIG_HTTPD_H */
#endif // XMRIG_HTTPD_H
1 change: 1 addition & 0 deletions src/base/crypto/Coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static const CoinInfo coinInfo[] = {
{ Algorithm::RX_KEVA, "KVA", "Kevacoin", 0, 0, MAGENTA_BG_BOLD(WHITE_BOLD_S " keva ") },
{ Algorithm::KAWPOW_RVN, "RVN", "Ravencoin", 0, 0, BLUE_BG_BOLD( WHITE_BOLD_S " raven ") },
{ Algorithm::RX_WOW, "WOW", "Wownero", 300, 100000000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " wownero ") },
{ Algorithm::RX_0, "ZEPH", "Zephyr", 120, 1000000000000, BLUE_BG_BOLD( WHITE_BOLD_S " zephyr ") },
};


Expand Down
1 change: 1 addition & 0 deletions src/base/crypto/Coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Coin
KEVA,
RAVEN,
WOWNERO,
ZEPHYR,
MAX
};

Expand Down
10 changes: 8 additions & 2 deletions src/base/kernel/Platform.h
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>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand Down Expand Up @@ -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();

Expand Down
15 changes: 7 additions & 8 deletions src/base/kernel/Platform_hwloc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand All @@ -16,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include "base/kernel/Platform.h"
#include "backend/cpu/platform/HwlocCpuInfo.h"
#include "backend/cpu/Cpu.h"


Expand All @@ -29,20 +27,21 @@
#ifndef XMRIG_OS_APPLE
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id)
{
auto cpu = static_cast<HwlocCpuInfo *>(Cpu::info());
hwloc_obj_t pu = hwloc_get_pu_obj_by_os_index(cpu->topology(), static_cast<unsigned>(cpu_id));
auto topology = Cpu::info()->topology();
auto pu = hwloc_get_pu_obj_by_os_index(topology, static_cast<unsigned>(cpu_id));

if (pu == nullptr) {
return false;
}

if (hwloc_set_cpubind(cpu->topology(), pu->cpuset, HWLOC_CPUBIND_THREAD | HWLOC_CPUBIND_STRICT) >= 0) {
if (hwloc_set_cpubind(topology, pu->cpuset, HWLOC_CPUBIND_THREAD | HWLOC_CPUBIND_STRICT) >= 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
return true;
}

const bool result = (hwloc_set_cpubind(cpu->topology(), pu->cpuset, HWLOC_CPUBIND_THREAD) >= 0);
const bool result = (hwloc_set_cpubind(topology, pu->cpuset, HWLOC_CPUBIND_THREAD) >= 0);
std::this_thread::sleep_for(std::chrono::milliseconds(1));

return result;
}
#endif
11 changes: 8 additions & 3 deletions src/base/kernel/Platform_win.cpp
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>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand All @@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include <algorithm>
#include <winsock2.h>
#include <windows.h>
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/base/kernel/config/BaseConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void xmrig::BaseConfig::printVersions()
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
# endif

Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s"), "ABOUT", APP_NAME, APP_VERSION, buf);
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s") WHITE_BOLD(" (built for %s") WHITE_BOLD(" %s,") WHITE_BOLD(" %s)"), "ABOUT", APP_NAME, APP_VERSION, buf, APP_OS, APP_ARCH, APP_BITS);

std::string libs;

Expand Down
1 change: 1 addition & 0 deletions src/base/net/http/HttpResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define XMRIG_HTTPRESPONSE_H


#include <cstdint>
#include <map>
#include <string>

Expand Down
18 changes: 11 additions & 7 deletions src/base/net/stratum/Client.cpp
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>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
Expand Down Expand Up @@ -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"


Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand Down
Loading

0 comments on commit 67209ed

Please sign in to comment.