mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Force close connection if IP address banned.
This commit is contained in:
parent
e049b80f1a
commit
9cb7d727c2
2 changed files with 24 additions and 1 deletions
|
@ -199,6 +199,28 @@ int64_t Client::submit(const JobResult &result)
|
|||
}
|
||||
|
||||
|
||||
bool Client::isCriticalError(const char *message)
|
||||
{
|
||||
if (!message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "Unauthenticated", 15) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "your IP is banned", 17) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "IP Address currently banned", 27) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Client::parseJob(const json_t *params, int *code)
|
||||
{
|
||||
if (!json_is_object(params)) {
|
||||
|
@ -405,7 +427,7 @@ void Client::parseResponse(int64_t id, const json_t *result, const json_t *error
|
|||
LOG_ERR("[%s:%u] error: \"%s\", code: %" PRId64, m_url.host(), m_url.port(), message, json_integer_value(json_object_get(error, "code")));
|
||||
}
|
||||
|
||||
if (id == 1 || (message && strncasecmp(message, "Unauthenticated", 15) == 0)) {
|
||||
if (id == 1 || isCriticalError(message)) {
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
private:
|
||||
constexpr static size_t kRecvBufSize = 4096;
|
||||
|
||||
bool isCriticalError(const char *message);
|
||||
bool parseJob(const json_t *params, int *code);
|
||||
bool parseLogin(const json_t *result, int *code);
|
||||
int resolve(const char *host);
|
||||
|
|
Loading…
Reference in a new issue