/* XMRig * Copyright 2010 Jeff Garzik * Copyright 2012-2014 pooler * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2016-2017 XMRig * Copyright 2017- BenDr0id * * * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __SERVICE_H__ #define __SERVICE_H__ #define CONTENT_TYPE_HTML "text/html" #define CONTENT_TYPE_JSON "application/json" #include #include #include #include #include "Options.h" #include "ClientStatus.h" #include "ControlCommand.h" class Service { public: static bool start(); static void release(); static unsigned handleGET(const Options* options, const std::string& url, const std::string& clientIp, const std::string& clientId, std::string& resp); static unsigned handlePOST(const Options* options, const std::string& url, const std::string& clientIp, const std::string& clientId, const std::string& data, std::string& resp); private: static unsigned getClientConfig(const Options* options, const std::string& clientId, std::string& resp); static unsigned getClientCommand(const std::string& clientId, std::string& resp); static unsigned getClientLog(const std::string& clientId, std::string& resp); static unsigned getClientStatusList(std::string& resp); static unsigned getAdminPage(const Options* options, std::string& resp); static unsigned setClientStatus(const Options* options, const std::string& clientIp, const std::string& clientId, const std::string& data, std::string& resp); static unsigned setClientCommand(const std::string& clientId, const std::string& data, std::string& resp); static unsigned setClientConfig(const Options* options, const std::string &clientId, const std::string &data, std::string &resp); static unsigned resetClientStatusList(const std::string& data, std::string& resp); static void setClientLog(size_t maxRows, const std::string& clientId, const std::string& log); static std::string getClientConfigFileName(const Options *options, const std::string &clientId); private: static int m_currentServerTime; static std::map m_clientStatus; static std::map m_clientCommand; static std::map> m_clientLog; static uv_mutex_t m_mutex; }; #endif /* __SERVICE_H__ */