mirror of
https://github.com/xmrig/xmrig.git
synced 2026-01-19 05:25:40 -05:00
Merge xmrig v6.11.0 into master
This commit is contained in:
@@ -48,10 +48,11 @@
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IClientListener.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/Cvt.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "net/JobResult.h"
|
||||
|
||||
|
||||
@@ -86,13 +87,11 @@ xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||
{
|
||||
m_reader.setListener(this);
|
||||
m_key = m_storage.add(this);
|
||||
m_dns = new Dns(this);
|
||||
}
|
||||
|
||||
|
||||
xmrig::Client::~Client()
|
||||
{
|
||||
delete m_dns;
|
||||
delete m_socket;
|
||||
}
|
||||
|
||||
@@ -297,22 +296,24 @@ void xmrig::Client::tick(uint64_t now)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::onResolved(const Dns &dns, int status)
|
||||
void xmrig::Client::onResolved(const DnsRecords &records, int status, const char *error)
|
||||
{
|
||||
m_dns.reset();
|
||||
|
||||
assert(m_listener != nullptr);
|
||||
if (!m_listener) {
|
||||
return reconnect();
|
||||
}
|
||||
|
||||
if (status < 0 && dns.isEmpty()) {
|
||||
if (status < 0 && records.isEmpty()) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), uv_strerror(status));
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), error);
|
||||
}
|
||||
|
||||
return reconnect();
|
||||
}
|
||||
|
||||
const auto &record = dns.get();
|
||||
const auto &record = records.get();
|
||||
m_ip = record.ip();
|
||||
|
||||
connect(record.addr(m_socks5 ? m_pool.proxy().port() : m_pool.port()));
|
||||
@@ -379,6 +380,14 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *algo = Json::getString(params, "algo");
|
||||
if (algo) {
|
||||
job.setAlgorithm(algo);
|
||||
}
|
||||
else if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (m_pool.mode() == Pool::MODE_SELF_SELECT) {
|
||||
job.setExtraNonce(Json::getString(params, "extra_nonce"));
|
||||
@@ -403,14 +412,6 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *algo = Json::getString(params, "algo");
|
||||
if (algo) {
|
||||
job.setAlgorithm(algo);
|
||||
}
|
||||
else if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
job.setHeight(Json::getUint64(params, "height"));
|
||||
|
||||
if (!verifyAlgorithm(job.algorithm(), algo)) {
|
||||
@@ -526,13 +527,7 @@ int xmrig::Client::resolve(const String &host)
|
||||
m_failures = 0;
|
||||
}
|
||||
|
||||
if (!m_dns->resolve(host)) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("getaddrinfo error: ") RED_BOLD("\"%s\""), tag(), uv_strerror(m_dns->status()));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
m_dns = Dns::resolve(host, this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -568,7 +563,7 @@ int64_t xmrig::Client::send(size_t size)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::connect(sockaddr *addr)
|
||||
void xmrig::Client::connect(const sockaddr *addr)
|
||||
{
|
||||
setState(ConnectingState);
|
||||
|
||||
@@ -586,8 +581,6 @@ void xmrig::Client::connect(sockaddr *addr)
|
||||
# endif
|
||||
|
||||
uv_tcp_connect(req, m_socket, addr, onConnect);
|
||||
|
||||
delete addr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ using BIO = struct bio_st;
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsRequest;
|
||||
class IClientListener;
|
||||
class JobResult;
|
||||
|
||||
@@ -79,7 +80,7 @@ protected:
|
||||
void deleteLater() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
void onResolved(const DnsRecords &records, int status, const char *error) override;
|
||||
|
||||
inline bool hasExtension(Extension extension) const noexcept override { return m_extensions.test(extension); }
|
||||
inline const char *mode() const override { return "pool"; }
|
||||
@@ -108,7 +109,7 @@ private:
|
||||
bool write(const uv_buf_t &buf);
|
||||
int resolve(const String &host);
|
||||
int64_t send(size_t size);
|
||||
void connect(sockaddr *addr);
|
||||
void connect(const sockaddr *addr);
|
||||
void handshake();
|
||||
void parse(char *line, size_t len);
|
||||
void parseExtensions(const rapidjson::Value &result);
|
||||
@@ -131,10 +132,10 @@ private:
|
||||
static inline Client *getClient(void *data) { return m_storage.get(data); }
|
||||
|
||||
const char *m_agent;
|
||||
Dns *m_dns;
|
||||
LineReader m_reader;
|
||||
Socks5 *m_socks5 = nullptr;
|
||||
std::bitset<EXT_MAX> m_extensions;
|
||||
std::shared_ptr<DnsRequest> m_dns;
|
||||
std::vector<char> m_sendBuf;
|
||||
String m_rpcId;
|
||||
Tls *m_tls = nullptr;
|
||||
|
||||
@@ -247,6 +247,10 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
Cvt::toHex(m_blockhashingblob.data() + offset * 2, kBlobReserveSize * 2, Cvt::randomBytes(kBlobReserveSize).data(), kBlobReserveSize);
|
||||
}
|
||||
|
||||
if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
if (blocktemplate.isNull() || !job.setBlob(m_blockhashingblob)) {
|
||||
*code = 4;
|
||||
return false;
|
||||
@@ -257,10 +261,6 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
job.setDiff(Json::getUint64(params, "difficulty"));
|
||||
job.setId(blocktemplate.data() + blocktemplate.size() - 32);
|
||||
|
||||
if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
m_job = std::move(job);
|
||||
m_blocktemplate = std::move(blocktemplate);
|
||||
m_prevHash = Json::getString(params, "prev_hash");
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/dns/DnsRecords.h"
|
||||
#include "base/net/http/Fetch.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpListener.h"
|
||||
@@ -47,8 +48,8 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
|
||||
std::vector<char> blob(112 * 2 + 1, '0');
|
||||
blob.back() = '\0';
|
||||
|
||||
m_job.setBlob(blob.data());
|
||||
m_job.setAlgorithm(m_benchmark->algorithm());
|
||||
m_job.setBlob(blob.data());
|
||||
m_job.setDiff(std::numeric_limits<uint64_t>::max());
|
||||
m_job.setHeight(1);
|
||||
m_job.setId("00000000");
|
||||
@@ -185,16 +186,18 @@ void xmrig::BenchClient::onHttpData(const HttpData &data)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onResolved(const Dns &dns, int status)
|
||||
void xmrig::BenchClient::onResolved(const DnsRecords &records, int status, const char *error)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
assert(!m_httpListener);
|
||||
|
||||
m_dns.reset();
|
||||
|
||||
if (status < 0) {
|
||||
return setError(dns.error(), "DNS error");
|
||||
return setError(error, "DNS error");
|
||||
}
|
||||
|
||||
m_ip = dns.get().ip();
|
||||
m_ip = records.get().ip();
|
||||
m_httpListener = std::make_shared<HttpListener>(this, tag());
|
||||
|
||||
if (m_mode == ONLINE_BENCH) {
|
||||
@@ -307,11 +310,7 @@ void xmrig::BenchClient::onGetReply(const rapidjson::Value &value)
|
||||
|
||||
void xmrig::BenchClient::resolve()
|
||||
{
|
||||
m_dns = std::make_shared<Dns>(this);
|
||||
|
||||
if (!m_dns->resolve(BenchConfig::kApiHost)) {
|
||||
setError(m_dns->error(), "getaddrinfo error");
|
||||
}
|
||||
m_dns = Dns::resolve(BenchConfig::kApiHost, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ protected:
|
||||
void onBenchDone(uint64_t result, uint64_t diff, uint64_t ts) override;
|
||||
void onBenchReady(uint64_t ts, uint32_t threads, const IBackend *backend) override;
|
||||
void onHttpData(const HttpData &data) override;
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
void onResolved(const DnsRecords &records, int status, const char *error) override;
|
||||
|
||||
private:
|
||||
enum Mode : uint32_t {
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
Pool m_pool;
|
||||
Request m_request = NO_REQUEST;
|
||||
std::shared_ptr<BenchConfig> m_benchmark;
|
||||
std::shared_ptr<Dns> m_dns;
|
||||
std::shared_ptr<DnsRequest> m_dns;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
String m_ip;
|
||||
String m_token;
|
||||
|
||||
Reference in New Issue
Block a user