Added support for rigId extension.

This commit is contained in:
XMRig
2018-04-24 02:42:43 +07:00
parent ff39153552
commit badef517c3
11 changed files with 29 additions and 95 deletions

View File

@@ -112,7 +112,6 @@ set(SOURCES
src/proxy/events/ConnectionEvent.h
src/proxy/events/Event.cpp
src/proxy/events/MinerEvent.cpp
src/proxy/LoginRequest.cpp
src/proxy/Miner.cpp
src/proxy/Miners.cpp
src/proxy/Proxy.cpp

View File

@@ -4,8 +4,8 @@
IDI_ICON1 ICON DISCARDABLE "app.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_BUILD,APP_VER_REV
PRODUCTVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_BUILD,APP_VER_REV
FILEVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0
PRODUCTVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG

View File

@@ -7,7 +7,6 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 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
* the Free Software Foundation, either version 3 of the License, or

View File

@@ -1,59 +0,0 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2017 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include "proxy/LoginRequest.h"
LoginRequest::LoginRequest(int64_t id, const char *login, const char *pass, const char *agent) :
m_agent(agent),
m_login(login),
m_pass(pass),
m_id(id)
{
m_clientType = detectClient();
}
LoginRequest::ClientTypes LoginRequest::detectClient() const
{
if (!m_agent || strlen(m_agent) < 32) {
return OtherClient;
}
if (memcmp(m_agent, "XMRig/2.0.", 10) == 0) {
return XMRig20Client;
}
if (memcmp(m_agent, "XMRig/", 6) == 0) {
return XMRigClient;
}
if (memcmp(m_agent, "xmrig-proxy/", 13) == 0) {
return XMRigProxyClient;
}
return OtherClient;
}

View File

@@ -4,8 +4,8 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2017 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 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
@@ -31,36 +31,32 @@
class LoginRequest
{
public:
enum ClientTypes {
OtherClient,
XMRigClient,
XMRig20Client, // In versions 2.0.1 and 2.0.2 nicehash not explicitly enabled for donations.
XMRigProxyClient // Proxy does not support nicehash for upstream.
};
inline LoginRequest() :
m_clientType(OtherClient),
m_agent(nullptr),
m_login(nullptr),
m_pass(nullptr),
m_id(0)
{}
LoginRequest(int64_t id, const char *login, const char *pass, const char *agent);
inline LoginRequest(int64_t id, const char *login, const char *pass, const char *agent, const char *rigId) :
m_agent(agent),
m_login(login),
m_pass(pass),
m_rigId(rigId),
m_id(id)
{}
inline const char *agent() const { return m_agent; }
inline const char *login() const { return m_login; }
inline const char *pass() const { return m_pass; }
inline const char *rigId() const { return m_rigId ? m_rigId : m_login; }
inline int64_t id() const { return m_id; }
inline ClientTypes clientType() const { return m_clientType; }
private:
ClientTypes detectClient() const;
ClientTypes m_clientType;
const char *m_agent;
const char *m_login;
const char *m_pass;
const char *m_rigId;
const int64_t m_id;
};

View File

@@ -168,7 +168,7 @@ bool Miner::parseRequest(int64_t id, const char *method, const rapidjson::Value
setState(WaitReadyState);
m_loginId = id;
LoginEvent::create(this, id, params["login"].GetString(), params["pass"].GetString(), params["agent"].GetString())->start();
LoginEvent::create(this, id, params["login"].GetString(), params["pass"].GetString(), params["agent"].GetString(), params["rigid"].GetString())->start();
return true;
}

View File

@@ -32,9 +32,9 @@
class LoginEvent : public MinerEvent
{
public:
static inline LoginEvent *create(Miner *miner, int64_t id, const char *login, const char *pass, const char *agent)
static inline LoginEvent *create(Miner *miner, int64_t id, const char *login, const char *pass, const char *agent, const char *rigId)
{
return new (m_buf) LoginEvent(miner, id, login, pass, agent);
return new (m_buf) LoginEvent(miner, id, login, pass, agent, rigId);
}
@@ -42,9 +42,9 @@ public:
protected:
inline LoginEvent(Miner *miner, int64_t id, const char *login, const char *pass, const char *agent)
inline LoginEvent(Miner *miner, int64_t id, const char *login, const char *pass, const char *agent, const char *rigId)
: MinerEvent(LoginType, miner),
request(id, login, pass, agent)
request(id, login, pass, agent, rigId)
{}
};

View File

@@ -46,7 +46,7 @@ NonceStorage::~NonceStorage()
bool NonceStorage::add(Miner *miner, const LoginRequest &request)
{
const int index = nextIndex(request.clientType() == LoginRequest::XMRig20Client ? 1 : 0);
const int index = nextIndex(0);
if (index == -1) {
return false;
}

View File

@@ -4,8 +4,8 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2018 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 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
@@ -178,7 +178,7 @@ void Workers::accept(const AcceptEvent *event)
void Workers::login(const LoginEvent *event)
{
const std::string name(event->request.login());
const std::string name(event->request.rigId());
if (m_map.count(name) == 0) {
const size_t id = m_workers.size();

View File

@@ -4,8 +4,8 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2018 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 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

View File

@@ -4,8 +4,8 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2018 XMRig <support@xmrig.com>
*
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 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
@@ -27,16 +27,15 @@
#define APP_ID "xmrig-proxy"
#define APP_NAME "xmrig-proxy"
#define APP_DESC "XMRig Stratum proxy"
#define APP_VERSION "2.5.3"
#define APP_VERSION "2.6.0-dev"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2018 xmrig.com"
#define APP_KIND "proxy"
#define APP_VER_MAJOR 2
#define APP_VER_MINOR 5
#define APP_VER_BUILD 3
#define APP_VER_REV 0
#define APP_VER_MINOR 6
#define APP_VER_PATCH 0
#ifdef _MSC_VER
# if (_MSC_VER >= 1910)