-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
572 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 ¶ms) | ||
{ | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 ¶ms); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -189,7 +189,7 @@ class LogPrivate | |
} | ||
|
||
|
||
char m_buf[4096]{}; | ||
char m_buf[Log::kMaxBufferSize]{}; | ||
std::mutex m_mutex; | ||
std::vector<ILogBackend*> m_backends; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -27,6 +27,7 @@ | |
#define XMRIG_LOG_H | ||
|
||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
|
||
|
@@ -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, ...); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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; | ||
|
@@ -55,7 +55,7 @@ class DnsRecord | |
inline Type type() const { return m_type; } | ||
|
||
private: | ||
Type m_type; | ||
Type m_type = Unknown; | ||
String m_ip; | ||
}; | ||
|
||
|
Oops, something went wrong.