mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-22 10:45:06 +00:00
Added ENV support for "user", "pass" and "rig-id" fields.
This commit is contained in:
parent
356e666e61
commit
5bd6a1c028
6 changed files with 33 additions and 13 deletions
|
@ -26,11 +26,6 @@
|
|||
#include <uv.h>
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "base/api/Api.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/api/interfaces/IApiListener.h"
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
#include <uv.h>
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef UV_MAXHOSTNAMESIZE
|
||||
# ifdef MAXHOSTNAMELEN
|
||||
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
|
||||
|
|
|
@ -23,16 +23,19 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/stratum/BaseClient.h"
|
||||
#include "base/kernel/Env.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/stratum/SubmitResult.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
int64_t BaseClient::m_sequence = 1;
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
|
@ -43,6 +46,19 @@ xmrig::BaseClient::BaseClient(int id, IClientListener *listener) :
|
|||
}
|
||||
|
||||
|
||||
void xmrig::BaseClient::setPool(const Pool &pool)
|
||||
{
|
||||
if (!pool.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pool = pool;
|
||||
m_user = Env::expand(pool.user());
|
||||
m_password = Env::expand(pool.password());
|
||||
m_rigId = Env::expand(pool.rigId());
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::BaseClient::handleResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
||||
{
|
||||
if (id == 1) {
|
||||
|
|
|
@ -56,11 +56,12 @@ protected:
|
|||
inline int64_t sequence() const override { return m_sequence; }
|
||||
inline void setAlgo(const Algorithm &algo) override { m_pool.setAlgo(algo); }
|
||||
inline void setEnabled(bool enabled) override { m_enabled = enabled; }
|
||||
inline void setPool(const Pool &pool) override { if (pool.isValid()) { m_pool = pool; } }
|
||||
inline void setQuiet(bool quiet) override { m_quiet = quiet; }
|
||||
inline void setRetries(int retries) override { m_retries = retries; }
|
||||
inline void setRetryPause(uint64_t ms) override { m_retryPause = ms; }
|
||||
|
||||
void setPool(const Pool &pool) override;
|
||||
|
||||
protected:
|
||||
enum SocketState {
|
||||
UnconnectedState,
|
||||
|
@ -95,6 +96,9 @@ protected:
|
|||
std::map<int64_t, SendResult> m_callbacks;
|
||||
std::map<int64_t, SubmitResult> m_results;
|
||||
String m_ip;
|
||||
String m_password;
|
||||
String m_rigId;
|
||||
String m_user;
|
||||
uint64_t m_retryPause = 5000;
|
||||
|
||||
static int64_t m_sequence;
|
||||
|
|
|
@ -624,12 +624,12 @@ void xmrig::Client::login()
|
|||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value params(kObjectType);
|
||||
params.AddMember("login", m_pool.user().toJSON(), allocator);
|
||||
params.AddMember("pass", m_pool.password().toJSON(), allocator);
|
||||
params.AddMember("login", m_user.toJSON(), allocator);
|
||||
params.AddMember("pass", m_password.toJSON(), allocator);
|
||||
params.AddMember("agent", StringRef(m_agent), allocator);
|
||||
|
||||
if (!m_pool.rigId().isNull()) {
|
||||
params.AddMember("rigid", m_pool.rigId().toJSON(), allocator);
|
||||
if (!m_rigId.isNull()) {
|
||||
params.AddMember("rigid", m_rigId.toJSON(), allocator);
|
||||
}
|
||||
|
||||
m_listener->onLogin(this, doc, params);
|
||||
|
|
|
@ -284,8 +284,8 @@ int64_t xmrig::DaemonClient::getBlockTemplate()
|
|||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value params(kObjectType);
|
||||
params.AddMember("wallet_address", m_pool.user().toJSON(), allocator);
|
||||
params.AddMember("reserve_size", 8, allocator);
|
||||
params.AddMember("wallet_address", m_user.toJSON(), allocator);
|
||||
params.AddMember("reserve_size", 8, allocator);
|
||||
|
||||
JsonRequest::create(doc, m_sequence, "getblocktemplate", params);
|
||||
|
||||
|
|
Loading…
Reference in a new issue