Add support for client.reconnect method
This commit is contained in:
parent
f5447088cb
commit
2e738509bb
3 changed files with 40 additions and 1 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
|
@ -683,12 +684,48 @@ void xmrig::Client::parse(char *line, size_t len)
|
|||
|
||||
const auto &id = Json::getValue(doc, "id");
|
||||
const auto &error = Json::getValue(doc, "error");
|
||||
const char *method = Json::getString(doc, "method");
|
||||
|
||||
if (method && strcmp(method, "client.reconnect") == 0) {
|
||||
const auto ¶ms = Json::getValue(doc, "params");
|
||||
if (!params.IsArray()) {
|
||||
LOG_ERR("%s " RED("invalid client.reconnect notification: params is not an array"), tag());
|
||||
return;
|
||||
}
|
||||
|
||||
auto arr = params.GetArray();
|
||||
|
||||
if (arr.Empty()) {
|
||||
LOG_ERR("%s " RED("invalid client.reconnect notification: params array is empty"), tag());
|
||||
return;
|
||||
}
|
||||
|
||||
if (arr.Size() != 2) {
|
||||
LOG_ERR("%s " RED("invalid client.reconnect notification: params array has wrong size"), tag());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!arr[0].IsString()) {
|
||||
LOG_ERR("%s " RED("invalid client.reconnect notification: host is not a string"), tag());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!arr[1].IsString()) {
|
||||
LOG_ERR("%s " RED("invalid client.reconnect notification: port is not a string"), tag());
|
||||
return;
|
||||
}
|
||||
|
||||
std::stringstream s;
|
||||
s << arr[0].GetString() << ":" << arr[1].GetString();
|
||||
LOG_WARN("%s " YELLOW("client.reconnect to %s"), tag(), s.str().c_str());
|
||||
setPoolUrl(s.str().c_str());
|
||||
return reconnect();
|
||||
}
|
||||
|
||||
if (id.IsInt64()) {
|
||||
return parseResponse(id.GetInt64(), Json::getValue(doc, "result"), error);
|
||||
}
|
||||
|
||||
const char *method = Json::getString(doc, "method");
|
||||
if (!method) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue