Skip to content

Commit

Permalink
Merge branch 'evo' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Aug 4, 2019
2 parents ed820e9 + 8564da0 commit 704ffd4
Show file tree
Hide file tree
Showing 91 changed files with 988 additions and 1,551 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.99.0-beta
* [#335](https://github.com/xmrig/xmrig-proxy/issues/335) Added support for unlimited algorithm switching.
* Config files from previous versions NOT compatible, `variant` option replaced to `algo`, global option `algo` removed.
* Command line options also not compatible, `--variant` option replaced to `--algo`.
* Algorithm `cn/msr` renamed to `cn/fast`.
* Algorithm `cn/xtl` removed.

# v2.16.1-beta
- Added RandomXL algorithm for [Loki](https://loki.network/).
- Algorithm name used by proxy is `randomx/loki` or `rx/loki`.
Expand Down
26 changes: 10 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,16 @@ include (src/base/base.cmake)
set(HEADERS
"${HEADERS_BASE}"
"${HEADERS_BASE_HTTP}"
src/3rdparty/align.h
src/App.h
src/common/crypto/keccak.h
src/common/Platform.h
src/common/xmrig.h
src/core/config/Config_platform.h
src/core/config/Config.h
src/core/config/ConfigTransform.h
src/core/config/usage.h
src/core/Controller.h
src/crypto/cn/CnAlgo.h
src/crypto/common/Algorithm.h
src/crypto/common/keccak.h
src/donate.h
src/interfaces/IEvent.h
src/interfaces/IEventListener.h
src/interfaces/ISplitter.h
src/log/AccessLog.h
src/log/ShareLog.h
src/net/JobResult.h
src/net/strategies/DonateStrategy.h
src/proxy/BindHost.h
Expand All @@ -46,6 +39,11 @@ set(HEADERS
src/proxy/events/LoginEvent.h
src/proxy/events/MinerEvent.h
src/proxy/events/SubmitEvent.h
src/proxy/interfaces/IEvent.h
src/proxy/interfaces/IEventListener.h
src/proxy/interfaces/ISplitter.h
src/proxy/log/AccessLog.h
src/proxy/log/ShareLog.h
src/proxy/Login.h
src/proxy/Miner.h
src/proxy/Miners.h
Expand Down Expand Up @@ -74,14 +72,11 @@ set(SOURCES
"${SOURCES_BASE}"
"${SOURCES_BASE_HTTP}"
src/App.cpp
src/common/crypto/keccak.cpp
src/common/Platform.cpp
src/core/config/Config.cpp
src/core/config/ConfigTransform.cpp
src/core/Controller.cpp
src/crypto/common/Algorithm.cpp
src/log/AccessLog.cpp
src/log/ShareLog.cpp
src/crypto/common/keccak.cpp
src/net/JobResult.cpp
src/net/strategies/DonateStrategy.cpp
src/proxy/BindHost.cpp
Expand All @@ -92,6 +87,8 @@ set(SOURCES
src/proxy/events/ConnectionEvent.h
src/proxy/events/Event.cpp
src/proxy/events/MinerEvent.cpp
src/proxy/log/AccessLog.cpp
src/proxy/log/ShareLog.cpp
src/proxy/Login.cpp
src/proxy/Miner.cpp
src/proxy/Miners.cpp
Expand All @@ -118,7 +115,6 @@ if (WIN32)
"${SOURCES_OS}"
res/app.rc
src/App_win.cpp
src/common/Platform_win.cpp
src/proxy/Uuid_win.cpp
)

Expand All @@ -128,7 +124,6 @@ elseif (APPLE)
set(SOURCES_OS
"${SOURCES_OS}"
src/App_unix.cpp
src/common/Platform_mac.cpp
src/proxy/Uuid_mac.cpp
)

Expand All @@ -138,7 +133,6 @@ else()
set(SOURCES_OS
"${SOURCES_OS}"
src/App_unix.cpp
src/common/Platform_unix.cpp
src/proxy/Uuid_unix.cpp
)

Expand Down
33 changes: 0 additions & 33 deletions src/3rdparty/align.h

This file was deleted.

1 change: 0 additions & 1 deletion src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "base/io/Console.h"
#include "base/io/log/Log.h"
#include "base/kernel/Signals.h"
#include "common/Platform.h"
#include "core/config/Config.h"
#include "core/Controller.h"
#include "proxy/Proxy.h"
Expand Down
7 changes: 0 additions & 7 deletions src/Summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ static void print_mode(xmrig::Controller *controller)
}


static void print_algo(xmrig::Controller *controller)
{
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") MAGENTA_BOLD("%s"), "ALGO", controller->config()->algorithm().name());
}


static void print_bind(xmrig::Controller *controller)
{
const xmrig::BindHosts &bind = controller->config()->bind();
Expand Down Expand Up @@ -81,7 +75,6 @@ void Summary::print(xmrig::Controller *controller)
{
controller->config()->printVersions();
print_mode(controller);
print_algo(controller);
controller->config()->pools().print();
print_bind(controller);
print_commands(controller);
Expand Down
37 changes: 31 additions & 6 deletions src/api/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#include "api/v1/ApiRouter.h"
#include "base/kernel/Base.h"
#include "base/tools/Buffer.h"
#include "common/crypto/keccak.h"
#include "core/config/Config.h"
#include "core/Controller.h"
#include "crypto/common/keccak.h"
#include "version.h"


Expand All @@ -53,6 +53,7 @@ xmrig::Api::Api(Base *base) :
m_base(base),
m_id(),
m_workerId(),
m_timestamp(Chrono::currentMSecsSinceEpoch()),
m_httpd(nullptr)
{
base->addListener(this);
Expand Down Expand Up @@ -117,10 +118,34 @@ void xmrig::Api::exec(IApiRequest &request)
{
using namespace rapidjson;

if (request.method() == IApiRequest::METHOD_GET && (request.url() == "/1/summary" || request.url() == "/api.json")) {
if (request.type() == IApiRequest::REQ_SUMMARY) {
auto &allocator = request.doc().GetAllocator();

request.accept();
request.reply().AddMember("id", StringRef(m_id), request.doc().GetAllocator());
request.reply().AddMember("worker_id", StringRef(m_workerId), request.doc().GetAllocator());;
request.reply().AddMember("id", StringRef(m_id), allocator);
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);

Value features(kArrayType);
# ifdef XMRIG_FEATURE_API
features.PushBack("api", allocator);
# endif
# ifdef XMRIG_FEATURE_ASM
features.PushBack("asm", allocator);
# endif
# ifdef XMRIG_FEATURE_HTTP
features.PushBack("http", allocator);
# endif
# ifdef XMRIG_FEATURE_LIBCPUID
features.PushBack("cpuid", allocator);
# endif
# ifdef XMRIG_FEATURE_HWLOC
features.PushBack("hwloc", allocator);
# endif
# ifdef XMRIG_FEATURE_TLS
features.PushBack("tls", allocator);
# endif
request.reply().AddMember("features", features, allocator);
}

for (IApiListener *listener : m_listeners) {
Expand Down Expand Up @@ -163,8 +188,8 @@ void xmrig::Api::genId(const String &id)
memcpy(input + sizeof(uint16_t), interfaces[i].phys_addr, addrSize);
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, strlen(APP_KIND));

xmrig::keccak(input, inSize, hash);
xmrig::Buffer::toHex(hash, 8, m_id);
keccak(input, inSize, hash);
Buffer::toHex(hash, 8, m_id);

delete [] input;
break;
Expand Down
2 changes: 2 additions & 0 deletions src/api/Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


#include <vector>
#include <stdint.h>


#include "base/kernel/interfaces/IBaseListener.h"
Expand Down Expand Up @@ -70,6 +71,7 @@ class Api : public IBaseListener
Base *m_base;
char m_id[32];
char m_workerId[128];
const uint64_t m_timestamp;
Httpd *m_httpd;
std::vector<IApiListener *> m_listeners;
};
Expand Down
2 changes: 2 additions & 0 deletions src/api/interfaces/IApiListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class IApiListener
public:
virtual ~IApiListener() = default;

# ifdef XMRIG_FEATURE_API
virtual void onRequest(IApiRequest &request) = 0;
# endif
};


Expand Down
12 changes: 11 additions & 1 deletion src/api/interfaces/IApiRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[email protected]>
* Copyright 2016-2018 XMRig <[email protected]>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 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
Expand Down Expand Up @@ -50,16 +52,24 @@ class IApiRequest
};


enum RequestType {
REQ_UNKNOWN,
REQ_SUMMARY
};


virtual ~IApiRequest() = default;

virtual bool isDone() const = 0;
virtual bool isNew() const = 0;
virtual bool isRestricted() const = 0;
virtual const rapidjson::Value &json() const = 0;
virtual const String &url() const = 0;
virtual int version() const = 0;
virtual Method method() const = 0;
virtual rapidjson::Document &doc() = 0;
virtual rapidjson::Value &reply() = 0;
virtual RequestType type() const = 0;
virtual Source source() const = 0;
virtual void accept() = 0;
virtual void done(int status) = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/api/requests/ApiRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

xmrig::ApiRequest::ApiRequest(Source source, bool restricted) :
m_restricted(restricted),
m_source(source),
m_state(STATE_NEW)
m_source(source)
{
}

Expand Down
7 changes: 6 additions & 1 deletion src/api/requests/ApiRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ class ApiRequest : public IApiRequest
inline bool isDone() const override { return m_state == STATE_DONE; }
inline bool isNew() const override { return m_state == STATE_NEW; }
inline bool isRestricted() const override { return m_restricted; }
inline int version() const override { return m_version; }
inline RequestType type() const override { return m_type; }
inline Source source() const override { return m_source; }
inline void accept() override { m_state = STATE_ACCEPTED; }
inline void done(int) override { m_state = STATE_DONE; }

int m_version = 1;
RequestType m_type = REQ_UNKNOWN;

private:
enum State {
STATE_NEW,
Expand All @@ -56,7 +61,7 @@ class ApiRequest : public IApiRequest

bool m_restricted;
Source m_source;
State m_state;
State m_state = STATE_NEW;
};


Expand Down
11 changes: 11 additions & 0 deletions src/api/requests/HttpApiRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ xmrig::HttpApiRequest::HttpApiRequest(const HttpData &req, bool restricted) :
m_res(req.id()),
m_url(req.url.c_str())
{
if (method() == METHOD_GET) {
if (url() == "/1/summary" || url() == "/2/summary" || url() == "/api.json") {
m_type = REQ_SUMMARY;
}
}

if (url().size() > 4) {
if (memcmp(url().data(), "/2/", 3) == 0) {
m_version = 2;
}
}
}


Expand Down
Loading

0 comments on commit 704ffd4

Please sign in to comment.