Added "/2/config" alias for config API.

This commit is contained in:
XMRig 2019-08-06 13:21:39 +07:00
parent 46f1661fd9
commit 3c5cb142cb

View file

@ -57,6 +57,14 @@
#endif #endif
namespace xmrig {
static const char *kConfigPathV1 = "/1/config";
static const char *kConfigPathV2 = "/2/config";
} // namespace xmrig
class xmrig::BasePrivate class xmrig::BasePrivate
{ {
public: public:
@ -296,7 +304,7 @@ void xmrig::Base::onFileChanged(const String &fileName)
void xmrig::Base::onRequest(IApiRequest &request) void xmrig::Base::onRequest(IApiRequest &request)
{ {
if (request.method() == IApiRequest::METHOD_GET) { if (request.method() == IApiRequest::METHOD_GET) {
if (request.url() == "/1/config") { if (request.url() == kConfigPathV1 || request.url() == kConfigPathV2) {
if (request.isRestricted()) { if (request.isRestricted()) {
return request.done(403); return request.done(403);
} }
@ -306,7 +314,7 @@ void xmrig::Base::onRequest(IApiRequest &request)
} }
} }
else if (request.method() == IApiRequest::METHOD_PUT || request.method() == IApiRequest::METHOD_POST) { else if (request.method() == IApiRequest::METHOD_PUT || request.method() == IApiRequest::METHOD_POST) {
if (request.url() == "/1/config") { if (request.url() == kConfigPathV1 || request.url() == kConfigPathV2) {
request.accept(); request.accept();
if (!reload(request.json())) { if (!reload(request.json())) {