http-parser replaced to llhttp.
This commit is contained in:
parent
a11c57226b
commit
b3dbf6e23f
37 changed files with 16281 additions and 3513 deletions
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -21,7 +21,6 @@
|
|||
|
||||
|
||||
#include "base/api/Api.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/api/interfaces/IApiListener.h"
|
||||
#include "base/api/requests/HttpApiRequest.h"
|
||||
#include "base/crypto/keccak.h"
|
||||
|
@ -186,7 +185,7 @@ void xmrig::Api::exec(IApiRequest &request)
|
|||
}
|
||||
}
|
||||
|
||||
request.done(request.isNew() ? HTTP_STATUS_NOT_FOUND : HTTP_STATUS_OK);
|
||||
request.done(request.isNew() ? 404 : 200);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -22,9 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/api/Httpd.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "base/api/Api.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpApiResponse.h"
|
||||
|
@ -155,25 +148,25 @@ void xmrig::Httpd::onHttpData(const HttpData &data)
|
|||
}
|
||||
# endif
|
||||
|
||||
return HttpResponse(data.id(), HTTP_STATUS_NOT_FOUND).end();
|
||||
return HttpResponse(data.id(), 404 /* NOT_FOUND */).end();
|
||||
}
|
||||
|
||||
if (data.method > 4) {
|
||||
return HttpApiResponse(data.id(), HTTP_STATUS_METHOD_NOT_ALLOWED).end();
|
||||
return HttpApiResponse(data.id(), 405 /* METHOD_NOT_ALLOWED */).end();
|
||||
}
|
||||
|
||||
const int status = auth(data);
|
||||
if (status != HTTP_STATUS_OK) {
|
||||
if (status != 200) {
|
||||
return HttpApiResponse(data.id(), status).end();
|
||||
}
|
||||
|
||||
if (data.method != HTTP_GET) {
|
||||
if (m_base->config()->http().isRestricted()) {
|
||||
return HttpApiResponse(data.id(), HTTP_STATUS_FORBIDDEN).end();
|
||||
return HttpApiResponse(data.id(), 403 /* FORBIDDEN */).end();
|
||||
}
|
||||
|
||||
if (!data.headers.count(HttpData::kContentTypeL) || data.headers.at(HttpData::kContentTypeL) != HttpData::kApplicationJson) {
|
||||
return HttpApiResponse(data.id(), HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE).end();
|
||||
return HttpApiResponse(data.id(), 415 /* UNSUPPORTED_MEDIA_TYPE */).end();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,19 +179,19 @@ int xmrig::Httpd::auth(const HttpData &req) const
|
|||
const Http &config = m_base->config()->http();
|
||||
|
||||
if (!req.headers.count(kAuthorization)) {
|
||||
return config.isAuthRequired() ? HTTP_STATUS_UNAUTHORIZED : HTTP_STATUS_OK;
|
||||
return config.isAuthRequired() ? 401 /* UNAUTHORIZED */ : 200;
|
||||
}
|
||||
|
||||
if (config.token().isNull()) {
|
||||
return HTTP_STATUS_UNAUTHORIZED;
|
||||
return 401 /* UNAUTHORIZED */;
|
||||
}
|
||||
|
||||
const std::string &token = req.headers.at(kAuthorization);
|
||||
const size_t size = token.size();
|
||||
|
||||
if (token.size() < 8 || config.token().size() != size - 7 || memcmp("Bearer ", token.c_str(), 7) != 0) {
|
||||
return HTTP_STATUS_FORBIDDEN;
|
||||
return 403 /* FORBIDDEN */;
|
||||
}
|
||||
|
||||
return strncmp(config.token().data(), token.c_str() + 7, config.token().size()) == 0 ? HTTP_STATUS_OK : HTTP_STATUS_FORBIDDEN;
|
||||
return strncmp(config.token().data(), token.c_str() + 7, config.token().size()) == 0 ? 200 : 403 /* FORBIDDEN */;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -24,7 +18,7 @@
|
|||
|
||||
|
||||
#include "base/api/requests/HttpApiRequest.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "3rdparty/rapidjson/error/en.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
|
@ -53,8 +47,8 @@ static inline const char *rpcError(int code) {
|
|||
return "Invalid params";
|
||||
}
|
||||
|
||||
if (code >= HTTP_STATUS_BAD_REQUEST && code <= HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED) {
|
||||
return http_status_str(static_cast<http_status>(code));
|
||||
if (code >= 400 && code < 600) {
|
||||
return HttpData::statusName(code);
|
||||
}
|
||||
|
||||
return "Internal error";
|
||||
|
@ -155,10 +149,10 @@ void xmrig::HttpApiRequest::done(int status)
|
|||
using namespace rapidjson;
|
||||
auto &allocator = doc().GetAllocator();
|
||||
|
||||
m_res.setStatus(HTTP_STATUS_OK);
|
||||
m_res.setStatus(200);
|
||||
|
||||
if (status != HTTP_STATUS_OK) {
|
||||
setRpcError(status == HTTP_STATUS_NOT_FOUND ? RPC_METHOD_NOT_FOUND : status);
|
||||
if (status != 200) {
|
||||
setRpcError(status == 404 /* NOT_FOUND */ ? RPC_METHOD_NOT_FOUND : status);
|
||||
}
|
||||
else if (!reply().HasMember(kResult)) {
|
||||
Value result(kObjectType);
|
||||
|
@ -205,6 +199,6 @@ void xmrig::HttpApiRequest::rpcDone(const char *key, rapidjson::Value &value)
|
|||
reply().AddMember("jsonrpc", "2.0", allocator);
|
||||
reply().AddMember(StringRef(kId), Value().CopyFrom(Json::getValue(m_body, kId), allocator), allocator);
|
||||
|
||||
m_res.setStatus(HTTP_STATUS_OK);
|
||||
m_res.setStatus(200);
|
||||
m_res.end();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -160,7 +160,7 @@ endif()
|
|||
|
||||
if (WITH_HTTP)
|
||||
set(HEADERS_BASE_HTTP
|
||||
src/3rdparty/http-parser/http_parser.h
|
||||
src/3rdparty/llhttp/llhttp.h
|
||||
src/base/api/Api.h
|
||||
src/base/api/Httpd.h
|
||||
src/base/api/interfaces/IApiRequest.h
|
||||
|
@ -181,7 +181,9 @@ if (WITH_HTTP)
|
|||
)
|
||||
|
||||
set(SOURCES_BASE_HTTP
|
||||
src/3rdparty/http-parser/http_parser.c
|
||||
src/3rdparty/llhttp/llhttp.c
|
||||
src/3rdparty/llhttp/api.c
|
||||
src/3rdparty/llhttp/http.c
|
||||
src/base/api/Api.cpp
|
||||
src/base/api/Httpd.cpp
|
||||
src/base/api/requests/ApiRequest.cpp
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -30,7 +30,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16_t port, const String &path, bool tls, bool quiet, const char *data, size_t size, const char *contentType) :
|
||||
xmrig::FetchRequest::FetchRequest(llhttp_method method, const String &host, uint16_t port, const String &path, bool tls, bool quiet, const char *data, size_t size, const char *contentType) :
|
||||
quiet(quiet),
|
||||
tls(tls),
|
||||
method(method),
|
||||
|
@ -44,7 +44,7 @@ xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16
|
|||
}
|
||||
|
||||
|
||||
xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16_t port, const String &path, const rapidjson::Value &value, bool tls, bool quiet) :
|
||||
xmrig::FetchRequest::FetchRequest(llhttp_method method, const String &host, uint16_t port, const String &path, const rapidjson::Value &value, bool tls, bool quiet) :
|
||||
quiet(quiet),
|
||||
tls(tls),
|
||||
method(method),
|
||||
|
@ -99,7 +99,7 @@ void xmrig::fetch(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttp
|
|||
{
|
||||
# ifdef APP_DEBUG
|
||||
LOG_DEBUG(CYAN("http%s://%s:%u ") MAGENTA_BOLD("\"%s %s\"") BLACK_BOLD(" body: ") CYAN_BOLD("%zu") BLACK_BOLD(" bytes"),
|
||||
req.tls ? "s" : "", req.host.data(), req.port, http_method_str(req.method), req.path.data(), req.body.size());
|
||||
req.tls ? "s" : "", req.host.data(), req.port, llhttp_method_name(req.method), req.path.data(), req.body.size());
|
||||
|
||||
if (req.hasBody() && req.body.size() < (Log::kMaxBufferSize - 1024) && req.headers.count(HttpData::kContentType) && req.headers.at(HttpData::kContentType) == HttpData::kApplicationJson) {
|
||||
Log::print(BLUE_BG_BOLD("%s:") BLACK_BOLD_S " %.*s", req.headers.at(HttpData::kContentType).c_str(), static_cast<int>(req.body.size()), req.body.c_str());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -21,7 +21,7 @@
|
|||
#define XMRIG_FETCH_H
|
||||
|
||||
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
@ -41,24 +41,24 @@ class FetchRequest
|
|||
{
|
||||
public:
|
||||
FetchRequest() = default;
|
||||
FetchRequest(http_method method, const String &host, uint16_t port, const String &path, bool tls = false, bool quiet = false, const char *data = nullptr, size_t size = 0, const char *contentType = nullptr);
|
||||
FetchRequest(http_method method, const String &host, uint16_t port, const String &path, const rapidjson::Value &value, bool tls = false, bool quiet = false);
|
||||
FetchRequest(llhttp_method method, const String &host, uint16_t port, const String &path, bool tls = false, bool quiet = false, const char *data = nullptr, size_t size = 0, const char *contentType = nullptr);
|
||||
FetchRequest(llhttp_method method, const String &host, uint16_t port, const String &path, const rapidjson::Value &value, bool tls = false, bool quiet = false);
|
||||
|
||||
void setBody(const char *data, size_t size, const char *contentType = nullptr);
|
||||
void setBody(const rapidjson::Value &value);
|
||||
|
||||
inline bool hasBody() const { return method != HTTP_GET && method != HTTP_HEAD && !body.empty(); }
|
||||
|
||||
bool quiet = false;
|
||||
bool tls = false;
|
||||
http_method method = HTTP_GET;
|
||||
bool quiet = false;
|
||||
bool tls = false;
|
||||
llhttp_method method = HTTP_GET;
|
||||
std::map<const std::string, const std::string> headers;
|
||||
std::string body;
|
||||
String fingerprint;
|
||||
String host;
|
||||
String path;
|
||||
uint16_t port = 0;
|
||||
uint64_t timeout = 0;
|
||||
uint16_t port = 0;
|
||||
uint64_t timeout = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -25,7 +19,6 @@
|
|||
|
||||
|
||||
#include "base/net/http/HttpApiResponse.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/rapidjson/prettywriter.h"
|
||||
#include "3rdparty/rapidjson/stringbuffer.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
|
@ -68,7 +61,7 @@ void xmrig::HttpApiResponse::end()
|
|||
}
|
||||
|
||||
if (!m_doc.HasMember(kError)) {
|
||||
m_doc.AddMember(StringRef(kError), StringRef(http_status_str(static_cast<http_status>(statusCode()))), m_doc.GetAllocator());
|
||||
m_doc.AddMember(StringRef(kError), StringRef(HttpData::statusName(statusCode())), m_doc.GetAllocator());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -23,7 +17,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XMRIG_HTTPAPIRESPONSE_H
|
||||
#define XMRIG_HTTPAPIRESPONSE_H
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
#include "base/net/http/HttpClient.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
|
@ -102,7 +102,7 @@ void xmrig::HttpClient::handshake()
|
|||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << http_method_str(static_cast<http_method>(method)) << " " << url << " HTTP/1.1" << kCRLF;
|
||||
ss << llhttp_method_name(static_cast<llhttp_method>(method)) << " " << url << " HTTP/1.1" << kCRLF;
|
||||
|
||||
for (auto &header : headers) {
|
||||
ss << header.first << ": " << header.second << kCRLF;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/tools/Baton.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
@ -32,7 +32,7 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
static http_parser_settings http_settings;
|
||||
static llhttp_settings_t http_settings;
|
||||
static std::map<uint64_t, HttpContext *> storage;
|
||||
static uint64_t SEQUENCE = 0;
|
||||
|
||||
|
@ -78,13 +78,13 @@ xmrig::HttpContext::HttpContext(int parser_type, const std::weak_ptr<IHttpListen
|
|||
{
|
||||
storage[id()] = this;
|
||||
|
||||
m_parser = new http_parser;
|
||||
m_parser = new llhttp_t;
|
||||
m_tcp = new uv_tcp_t;
|
||||
|
||||
uv_tcp_init(uv_default_loop(), m_tcp);
|
||||
uv_tcp_nodelay(m_tcp, 1);
|
||||
|
||||
http_parser_init(m_parser, static_cast<http_parser_type>(parser_type));
|
||||
llhttp_init(m_parser, static_cast<llhttp_type_t>(parser_type), &http_settings);
|
||||
|
||||
m_parser->data = m_tcp->data = this;
|
||||
|
||||
|
@ -124,7 +124,7 @@ size_t xmrig::HttpContext::parse(const char *data, size_t size)
|
|||
return size;
|
||||
}
|
||||
|
||||
return http_parser_execute(m_parser, &http_settings, data, size);
|
||||
return llhttp_execute(m_parser, data, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,7 +191,7 @@ void xmrig::HttpContext::closeAll()
|
|||
}
|
||||
|
||||
|
||||
int xmrig::HttpContext::onHeaderField(http_parser *parser, const char *at, size_t length)
|
||||
int xmrig::HttpContext::onHeaderField(llhttp_t *parser, const char *at, size_t length)
|
||||
{
|
||||
auto ctx = static_cast<HttpContext*>(parser->data);
|
||||
|
||||
|
@ -210,7 +210,7 @@ int xmrig::HttpContext::onHeaderField(http_parser *parser, const char *at, size_
|
|||
}
|
||||
|
||||
|
||||
int xmrig::HttpContext::onHeaderValue(http_parser *parser, const char *at, size_t length)
|
||||
int xmrig::HttpContext::onHeaderValue(llhttp_t *parser, const char *at, size_t length)
|
||||
{
|
||||
auto ctx = static_cast<HttpContext*>(parser->data);
|
||||
|
||||
|
@ -225,14 +225,14 @@ int xmrig::HttpContext::onHeaderValue(http_parser *parser, const char *at, size_
|
|||
}
|
||||
|
||||
|
||||
void xmrig::HttpContext::attach(http_parser_settings *settings)
|
||||
void xmrig::HttpContext::attach(llhttp_settings_t *settings)
|
||||
{
|
||||
settings->on_message_begin = nullptr;
|
||||
settings->on_status = nullptr;
|
||||
settings->on_chunk_header = nullptr;
|
||||
settings->on_chunk_complete = nullptr;
|
||||
|
||||
settings->on_url = [](http_parser *parser, const char *at, size_t length) -> int
|
||||
settings->on_url = [](llhttp_t *parser, const char *at, size_t length) -> int
|
||||
{
|
||||
static_cast<HttpContext*>(parser->data)->url = std::string(at, length);
|
||||
return 0;
|
||||
|
@ -241,7 +241,7 @@ void xmrig::HttpContext::attach(http_parser_settings *settings)
|
|||
settings->on_header_field = onHeaderField;
|
||||
settings->on_header_value = onHeaderValue;
|
||||
|
||||
settings->on_headers_complete = [](http_parser* parser) -> int {
|
||||
settings->on_headers_complete = [](llhttp_t *parser) -> int {
|
||||
auto ctx = static_cast<HttpContext*>(parser->data);
|
||||
ctx->status = parser->status_code;
|
||||
|
||||
|
@ -256,14 +256,14 @@ void xmrig::HttpContext::attach(http_parser_settings *settings)
|
|||
return 0;
|
||||
};
|
||||
|
||||
settings->on_body = [](http_parser *parser, const char *at, size_t len) -> int
|
||||
settings->on_body = [](llhttp_t *parser, const char *at, size_t len) -> int
|
||||
{
|
||||
static_cast<HttpContext*>(parser->data)->body.append(at, len);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
settings->on_message_complete = [](http_parser *parser) -> int
|
||||
settings->on_message_complete = [](llhttp_t *parser) -> int
|
||||
{
|
||||
auto ctx = static_cast<HttpContext*>(parser->data);
|
||||
auto listener = ctx->httpListener();
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#define XMRIG_HTTPCONTEXT_H
|
||||
|
||||
|
||||
using http_parser = struct http_parser;
|
||||
using http_parser_settings = struct http_parser_settings;
|
||||
using llhttp_settings_t = struct llhttp_settings_s;
|
||||
using llhttp_t = struct llhttp__internal_s;
|
||||
using uv_connect_t = struct uv_connect_s;
|
||||
using uv_handle_t = struct uv_handle_s;
|
||||
using uv_stream_t = struct uv_stream_s;
|
||||
|
@ -76,15 +76,15 @@ protected:
|
|||
private:
|
||||
inline IHttpListener *httpListener() const { return m_listener.expired() ? nullptr : m_listener.lock().get(); }
|
||||
|
||||
static int onHeaderField(http_parser *parser, const char *at, size_t length);
|
||||
static int onHeaderValue(http_parser *parser, const char *at, size_t length);
|
||||
static void attach(http_parser_settings *settings);
|
||||
static int onHeaderField(llhttp_t *parser, const char *at, size_t length);
|
||||
static int onHeaderValue(llhttp_t *parser, const char *at, size_t length);
|
||||
static void attach(llhttp_settings_t *settings);
|
||||
|
||||
void setHeader();
|
||||
|
||||
bool m_wasHeaderValue = false;
|
||||
const uint64_t m_timestamp;
|
||||
http_parser *m_parser;
|
||||
llhttp_t *m_parser;
|
||||
std::string m_lastHeaderField;
|
||||
std::string m_lastHeaderValue;
|
||||
std::weak_ptr<IHttpListener> m_listener;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
#include "base/net/http/HttpData.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "3rdparty/rapidjson/error/en.h"
|
||||
#include "base/io/json/Json.h"
|
||||
|
@ -29,6 +29,76 @@
|
|||
#include <stdexcept>
|
||||
|
||||
|
||||
/* Status Codes */
|
||||
#define HTTP_STATUS_MAP(XX) \
|
||||
XX(100, CONTINUE, Continue) \
|
||||
XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \
|
||||
XX(102, PROCESSING, Processing) \
|
||||
XX(200, OK, OK) \
|
||||
XX(201, CREATED, Created) \
|
||||
XX(202, ACCEPTED, Accepted) \
|
||||
XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \
|
||||
XX(204, NO_CONTENT, No Content) \
|
||||
XX(205, RESET_CONTENT, Reset Content) \
|
||||
XX(206, PARTIAL_CONTENT, Partial Content) \
|
||||
XX(207, MULTI_STATUS, Multi-Status) \
|
||||
XX(208, ALREADY_REPORTED, Already Reported) \
|
||||
XX(226, IM_USED, IM Used) \
|
||||
XX(300, MULTIPLE_CHOICES, Multiple Choices) \
|
||||
XX(301, MOVED_PERMANENTLY, Moved Permanently) \
|
||||
XX(302, FOUND, Found) \
|
||||
XX(303, SEE_OTHER, See Other) \
|
||||
XX(304, NOT_MODIFIED, Not Modified) \
|
||||
XX(305, USE_PROXY, Use Proxy) \
|
||||
XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \
|
||||
XX(308, PERMANENT_REDIRECT, Permanent Redirect) \
|
||||
XX(400, BAD_REQUEST, Bad Request) \
|
||||
XX(401, UNAUTHORIZED, Unauthorized) \
|
||||
XX(402, PAYMENT_REQUIRED, Payment Required) \
|
||||
XX(403, FORBIDDEN, Forbidden) \
|
||||
XX(404, NOT_FOUND, Not Found) \
|
||||
XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \
|
||||
XX(406, NOT_ACCEPTABLE, Not Acceptable) \
|
||||
XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \
|
||||
XX(408, REQUEST_TIMEOUT, Request Timeout) \
|
||||
XX(409, CONFLICT, Conflict) \
|
||||
XX(410, GONE, Gone) \
|
||||
XX(411, LENGTH_REQUIRED, Length Required) \
|
||||
XX(412, PRECONDITION_FAILED, Precondition Failed) \
|
||||
XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \
|
||||
XX(414, URI_TOO_LONG, URI Too Long) \
|
||||
XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \
|
||||
XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \
|
||||
XX(417, EXPECTATION_FAILED, Expectation Failed) \
|
||||
XX(421, MISDIRECTED_REQUEST, Misdirected Request) \
|
||||
XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \
|
||||
XX(423, LOCKED, Locked) \
|
||||
XX(424, FAILED_DEPENDENCY, Failed Dependency) \
|
||||
XX(426, UPGRADE_REQUIRED, Upgrade Required) \
|
||||
XX(428, PRECONDITION_REQUIRED, Precondition Required) \
|
||||
XX(429, TOO_MANY_REQUESTS, Too Many Requests) \
|
||||
XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \
|
||||
XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \
|
||||
XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \
|
||||
XX(501, NOT_IMPLEMENTED, Not Implemented) \
|
||||
XX(502, BAD_GATEWAY, Bad Gateway) \
|
||||
XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \
|
||||
XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \
|
||||
XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \
|
||||
XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \
|
||||
XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \
|
||||
XX(508, LOOP_DETECTED, Loop Detected) \
|
||||
XX(510, NOT_EXTENDED, Not Extended) \
|
||||
XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \
|
||||
|
||||
enum http_status
|
||||
{
|
||||
# define XX(num, name, string) HTTP_STATUS_##name = num,
|
||||
HTTP_STATUS_MAP(XX)
|
||||
# undef XX
|
||||
};
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -38,6 +108,17 @@ const std::string HttpData::kContentTypeL = "content-type";
|
|||
const std::string HttpData::kTextPlain = "text/plain";
|
||||
|
||||
|
||||
static const char *http_status_str(enum http_status s)
|
||||
{
|
||||
switch (s) {
|
||||
# define XX(num, name, string) case HTTP_STATUS_##name: return #string;
|
||||
HTTP_STATUS_MAP(XX)
|
||||
# undef XX
|
||||
default: return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -55,17 +136,7 @@ bool xmrig::HttpData::isJSON() const
|
|||
|
||||
const char *xmrig::HttpData::methodName() const
|
||||
{
|
||||
return http_method_str(static_cast<http_method>(method));
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::HttpData::statusName() const
|
||||
{
|
||||
if (status < 0) {
|
||||
return uv_strerror(status);
|
||||
}
|
||||
|
||||
return http_status_str(static_cast<http_status>(status));
|
||||
return llhttp_method_name(static_cast<llhttp_method>(method));
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,3 +165,13 @@ rapidjson::Document xmrig::HttpData::json() const
|
|||
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::HttpData::statusName(int status)
|
||||
{
|
||||
if (status < 0) {
|
||||
return uv_strerror(status);
|
||||
}
|
||||
|
||||
return http_status_str(static_cast<http_status>(status));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -47,7 +47,8 @@ public:
|
|||
inline HttpData(uint64_t id) : m_id(id) {}
|
||||
virtual ~HttpData() = default;
|
||||
|
||||
inline uint64_t id() const { return m_id; }
|
||||
inline const char *statusName() const { return statusName(status); }
|
||||
inline uint64_t id() const { return m_id; }
|
||||
|
||||
virtual bool isRequest() const = 0;
|
||||
virtual const char *host() const = 0;
|
||||
|
@ -59,9 +60,10 @@ public:
|
|||
|
||||
bool isJSON() const;
|
||||
const char *methodName() const;
|
||||
const char *statusName() const;
|
||||
rapidjson::Document json() const;
|
||||
|
||||
static const char *statusName(int status);
|
||||
|
||||
int method = 0;
|
||||
int status = 0;
|
||||
int userType = 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
|
||||
#include "base/net/http/HttpListener.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
|
||||
|
@ -28,7 +28,7 @@ void xmrig::HttpListener::onHttpData(const HttpData &data)
|
|||
# ifdef APP_DEBUG
|
||||
if (!data.isRequest()) {
|
||||
LOG_DEBUG("%s " CYAN_BOLD("http%s://%s:%u ") MAGENTA_BOLD("\"%s %s\" ") CSI "1;%dm%d" CLEAR BLACK_BOLD(" received: ") CYAN_BOLD("%zu") BLACK_BOLD(" bytes"),
|
||||
m_tag, data.tlsVersion() ? "s" : "", data.host(), data.port(), http_method_str(static_cast<http_method>(data.method)), data.url.data(),
|
||||
m_tag, data.tlsVersion() ? "s" : "", data.host(), data.port(), llhttp_method_name(static_cast<llhttp_method>(data.method)), data.url.data(),
|
||||
(data.status >= 400 || data.status < 0) ? 31 : 32, data.status, data.body.size());
|
||||
|
||||
if (data.body.size() < (Log::kMaxBufferSize - 1024) && data.isJSON()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -25,7 +19,7 @@
|
|||
|
||||
|
||||
#include "base/net/http/HttpResponse.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
|
||||
|
@ -78,7 +72,7 @@ void xmrig::HttpResponse::end(const char *data, size_t size)
|
|||
setHeader("Connection", "close");
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "HTTP/1.1 " << statusCode() << " " << http_status_str(static_cast<http_status>(statusCode())) << kCRLF;
|
||||
ss << "HTTP/1.1 " << statusCode() << " " << HttpData::statusName(statusCode()) << kCRLF;
|
||||
|
||||
for (auto &header : m_headers) {
|
||||
ss << header.first << ": " << header.second << kCRLF;
|
||||
|
@ -97,7 +91,7 @@ void xmrig::HttpResponse::end(const char *data, size_t size)
|
|||
|
||||
Log::print(err ? Log::ERR : Log::INFO, CYAN("%s ") CLEAR MAGENTA_BOLD("%s") WHITE_BOLD(" %s ") CSI "1;%dm%d " CLEAR WHITE_BOLD("%zu ") CYAN_BOLD("%" PRIu64 "ms ") BLACK_BOLD("\"%s\""),
|
||||
ctx->ip().c_str(),
|
||||
http_method_str(static_cast<http_method>(ctx->method)),
|
||||
llhttp_method_name(static_cast<llhttp_method>(ctx->method)),
|
||||
ctx->url.c_str(),
|
||||
err ? 31 : 32,
|
||||
statusCode(),
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -23,7 +17,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XMRIG_HTTPRESPONSE_H
|
||||
#define XMRIG_HTTPRESPONSE_H
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
|
||||
#include "base/net/https/HttpsContext.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/llhttp/llhttp.h"
|
||||
#include "base/net/tls/TlsContext.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
|
||||
#include "base/net/stratum/DaemonClient.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "3rdparty/rapidjson/error/en.h"
|
||||
#include "base/io/json/Json.h"
|
||||
|
@ -151,7 +150,7 @@ void xmrig::DaemonClient::connect(const Pool &pool)
|
|||
|
||||
void xmrig::DaemonClient::onHttpData(const HttpData &data)
|
||||
{
|
||||
if (data.status != HTTP_STATUS_OK) {
|
||||
if (data.status != 200) {
|
||||
return retry();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
|
||||
#include "base/net/stratum/SelfSelectClient.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "3rdparty/rapidjson/error/en.h"
|
||||
#include "base/io/json/Json.h"
|
||||
|
@ -288,7 +287,7 @@ void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result)
|
|||
|
||||
void xmrig::SelfSelectClient::onHttpData(const HttpData &data)
|
||||
{
|
||||
if (data.status != HTTP_STATUS_OK) {
|
||||
if (data.status != 200) {
|
||||
return retry();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue