Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Mar 8, 2020
2 parents 448c2d5 + 006c131 commit 896673c
Show file tree
Hide file tree
Showing 37 changed files with 572 additions and 282 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v5.9.0
- [#1578](https://github.com/xmrig/xmrig/pull/1578) Added new RandomKEVA algorithm for upcoming Kevacoin fork, as `"algo": "rx/keva"` or `"coin": "keva"`.

# v5.8.1
- [#1575](https://github.com/xmrig/xmrig/pull/1575) Fixed new block detection for DERO solo mining.

Expand Down
5 changes: 2 additions & 3 deletions src/base/api/Httpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
namespace xmrig {

static const char *kAuthorization = "authorization";
static const char *kContentType = "content-type";

#ifdef _WIN32
static const char *favicon = nullptr;
Expand Down Expand Up @@ -138,7 +137,7 @@ void xmrig::Httpd::onHttpData(const HttpData &data)
# ifdef _WIN32
if (favicon != nullptr) {
HttpResponse response(data.id());
response.setHeader("Content-Type", "image/x-icon");
response.setHeader(HttpData::kContentType, "image/x-icon");

return response.end(favicon, faviconSize);
}
Expand All @@ -161,7 +160,7 @@ void xmrig::Httpd::onHttpData(const HttpData &data)
return HttpApiResponse(data.id(), HTTP_STATUS_FORBIDDEN).end();
}

if (!data.headers.count(kContentType) || data.headers.at(kContentType) != "application/json") {
if (!data.headers.count(HttpData::kContentTypeL) || data.headers.at(HttpData::kContentTypeL) != HttpData::kApplicationJson) {
return HttpApiResponse(data.id(), HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE).end();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/base/base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ if (WITH_HTTP)
src/base/kernel/interfaces/IHttpListener.h
src/base/kernel/interfaces/IJsonReader.h
src/base/kernel/interfaces/ITcpServerListener.h
src/base/net/http/Fetch.h
src/base/net/http/HttpApiResponse.h
src/base/net/http/HttpClient.h
src/base/net/http/HttpContext.h
Expand All @@ -161,9 +162,12 @@ if (WITH_HTTP)
src/base/api/Httpd.cpp
src/base/api/requests/ApiRequest.cpp
src/base/api/requests/HttpApiRequest.cpp
src/base/net/http/Fetch.cpp
src/base/net/http/HttpApiResponse.cpp
src/base/net/http/HttpClient.cpp
src/base/net/http/HttpContext.cpp
src/base/net/http/HttpData.cpp
src/base/net/http/HttpListener.cpp
src/base/net/http/HttpResponse.cpp
src/base/net/http/HttpServer.cpp
src/base/net/stratum/DaemonClient.cpp
Expand Down
40 changes: 34 additions & 6 deletions src/base/io/json/JsonRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[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]>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 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 All @@ -27,12 +27,40 @@
#include "rapidjson/document.h"


namespace xmrig {


static const char *k2_0 = "2.0";
static const char *kId = "id";
static const char *kJsonRPC = "jsonrpc";
static const char *kMethod = "method";
const char *JsonRequest::kParams = "params";


} // namespace xmrig


rapidjson::Document xmrig::JsonRequest::create(int64_t id, const char *method)
{
using namespace rapidjson;
Document doc(kObjectType);
auto &allocator = doc.GetAllocator();

doc.AddMember(StringRef(kId), id, allocator);
doc.AddMember(StringRef(kJsonRPC), StringRef(k2_0), allocator);
doc.AddMember(StringRef(kMethod), StringRef(method), allocator);

return doc;
}


void xmrig::JsonRequest::create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value &params)
{
using namespace rapidjson;
auto &allocator = doc.GetAllocator();

doc.AddMember("id", id, allocator);
doc.AddMember("jsonrpc", "2.0", allocator);
doc.AddMember("method", rapidjson::StringRef(method), allocator);
doc.AddMember("params", params, allocator);
doc.AddMember(StringRef(kId), id, allocator);
doc.AddMember(StringRef(kJsonRPC), StringRef(k2_0), allocator);
doc.AddMember(StringRef(kMethod), StringRef(method), allocator);
doc.AddMember(StringRef(kParams), params, allocator);
}
7 changes: 5 additions & 2 deletions src/base/io/json/JsonRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[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]>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 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 @@ -35,6 +35,9 @@ namespace xmrig {
class JsonRequest
{
public:
static const char *kParams;

static rapidjson::Document create(int64_t id, const char *method);
static void create(rapidjson::Document &doc, int64_t id, const char *method, rapidjson::Value &params);
};

Expand Down
41 changes: 36 additions & 5 deletions src/base/io/log/FileLogWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@
#include <uv.h>


namespace xmrig {


static void fsWriteCallback(uv_fs_t *req)
{
delete [] static_cast<char *>(req->data);

uv_fs_req_cleanup(req);
delete req;
}


static const char *kNewLine = "\n";


} // namespace xmrig


bool xmrig::FileLogWriter::open(const char *fileName)
{
assert(fileName != nullptr);
Expand Down Expand Up @@ -52,12 +70,25 @@ bool xmrig::FileLogWriter::write(const char *data, size_t size)
auto req = new uv_fs_t;
req->data = buf.base;

uv_fs_write(uv_default_loop(), req, m_file, &buf, 1, -1, [](uv_fs_t *req) {
delete [] static_cast<char *>(req->data);
uv_fs_write(uv_default_loop(), req, m_file, &buf, 1, -1, fsWriteCallback);

return true;
}


bool xmrig::FileLogWriter::writeLine(const char *data, size_t size)
{
uv_buf_t buf[2] = {
uv_buf_init(new char[size], size),
uv_buf_init(const_cast<char *>(kNewLine), 1)
};

memcpy(buf[0].base, data, size);

auto req = new uv_fs_t;
req->data = buf[0].base;

uv_fs_req_cleanup(req);
delete req;
});
uv_fs_write(uv_default_loop(), req, m_file, buf, 2, -1, fsWriteCallback);

return true;
}
1 change: 1 addition & 0 deletions src/base/io/log/FileLogWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FileLogWriter

bool open(const char *fileName);
bool write(const char *data, size_t size);
bool writeLine(const char *data, size_t size);

private:
int m_file = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/base/io/log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <[email protected]>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <[email protected]>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 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 @@ -189,7 +189,7 @@ class LogPrivate
}


char m_buf[4096]{};
char m_buf[Log::kMaxBufferSize]{};
std::mutex m_mutex;
std::vector<ILogBackend*> m_backends;
};
Expand Down
7 changes: 5 additions & 2 deletions src/base/io/log/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <[email protected]>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2019 Spudz76 <https://github.com/Spudz76>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <[email protected]>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 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 All @@ -27,6 +27,7 @@
#define XMRIG_LOG_H


#include <cstddef>
#include <cstdint>


Expand All @@ -52,6 +53,8 @@ class Log
DEBUG, // debug-level messages
};

constexpr static size_t kMaxBufferSize = 16384;

static void add(ILogBackend *backend);
static void destroy();
static void print(const char *fmt, ...);
Expand Down
1 change: 1 addition & 0 deletions src/base/kernel/interfaces/IConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class IConfig
CPUMaxThreadsKey = 1026,
MemoryPoolKey = 1027,
YieldKey = 1030,
AstroBWTMaxSizeKey = 1034,

// xmrig amd
OclPlatformKey = 1400,
Expand Down
11 changes: 6 additions & 5 deletions src/base/net/dns/DnsRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[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]>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 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,13 +50,14 @@ xmrig::DnsRecord::DnsRecord(const addrinfo *addr) :
sockaddr *xmrig::DnsRecord::addr(uint16_t port) const
{
if (m_type == A) {
sockaddr_in *addr = new sockaddr_in();
auto addr = new sockaddr_in();
uv_ip4_addr(m_ip.data(), port, addr);

return reinterpret_cast<sockaddr *>(addr);
}
else if (m_type == AAAA) {
sockaddr_in6 *addr = new sockaddr_in6();

if (m_type == AAAA) {
auto addr = new sockaddr_in6();
uv_ip6_addr(m_ip.data(), port, addr);

return reinterpret_cast<sockaddr *>(addr);
Expand Down
8 changes: 4 additions & 4 deletions src/base/net/dns/DnsRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[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]>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 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 @@ -45,7 +45,7 @@ class DnsRecord
AAAA
};

inline DnsRecord() : m_type(Unknown) {}
DnsRecord() = default;
DnsRecord(const addrinfo *addr);

sockaddr *addr(uint16_t port = 0) const;
Expand All @@ -55,7 +55,7 @@ class DnsRecord
inline Type type() const { return m_type; }

private:
Type m_type;
Type m_type = Unknown;
String m_ip;
};

Expand Down
Loading

0 comments on commit 896673c

Please sign in to comment.