mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-21 06:18:34 +02:00
Further httpd integration
This commit is contained in:
+6
-1
@@ -8,6 +8,11 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_library(MHTD NAMES microhttpd)
|
||||
if("${MHTD}" STREQUAL "MHTD-NOTFOUND")
|
||||
message(FATAL_ERROR "libmicrohttpd is required")
|
||||
endif()
|
||||
|
||||
#set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_CONFIGURATION_TYPES "RELEASE;STATIC")
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
@@ -25,6 +30,6 @@ set(EXECUTABLE_OUTPUT_PATH "bin")
|
||||
file(GLOB SOURCES "crypto/*.c" "*.cpp")
|
||||
|
||||
add_executable(xmr-stak-cpu ${SOURCES})
|
||||
target_link_libraries(xmr-stak-cpu pthread)
|
||||
target_link_libraries(xmr-stak-cpu pthread microhttpd)
|
||||
|
||||
|
||||
|
||||
+6
-3
@@ -70,10 +70,13 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!httpd::inst()->start_daemon())
|
||||
if(jconf::inst()->GetHttpdPort() != 0)
|
||||
{
|
||||
win_exit();
|
||||
return 0;
|
||||
if (!httpd::inst()->start_daemon())
|
||||
{
|
||||
win_exit();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
printer::inst()->print_str("-------------------------------------------------------------------\n");
|
||||
|
||||
+10
@@ -109,6 +109,16 @@
|
||||
*/
|
||||
"h_print_time" : 60,
|
||||
|
||||
/*
|
||||
* Built-in web server
|
||||
* I like checking my hashrate on my phone. Don't you?
|
||||
* Keep in mind that you will need to set up port forwarding on your router if you want to access it from
|
||||
* outside of your home network. Ports lower than 1024 on Linux systems will require root.
|
||||
*
|
||||
* httpd_port - Port we should listen on. Default, 0, will switch off the server.
|
||||
*/
|
||||
"httpd_port" : 0,
|
||||
|
||||
/*
|
||||
* prefer_ipv4 - IPv6 preference. If the host is available on both IPv4 and IPv6 net, which one should be choose?
|
||||
* This setting will only be needed in 2020's. No need to worry about it now.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "httpd.h"
|
||||
#include "console.h"
|
||||
#include "executor.h"
|
||||
#include "jconf.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "libmicrohttpd/microhttpd.h"
|
||||
@@ -81,7 +82,7 @@ int httpd::req_handler(void * cls,
|
||||
bool httpd::start_daemon()
|
||||
{
|
||||
d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION,
|
||||
8100, NULL, NULL,
|
||||
jconf::inst()->GetHttpdPort(), NULL, NULL,
|
||||
&httpd::req_handler,
|
||||
NULL, MHD_OPTION_END);
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ using namespace rapidjson;
|
||||
/*
|
||||
* This enum needs to match index in oConfigValues, otherwise we will get a runtime error
|
||||
*/
|
||||
enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, sPoolAddr,
|
||||
sWalletAddr, sPoolPwd, iCallTimeout, iNetRetry, iVerboseLevel, iAutohashTime, bPreferIpv4 };
|
||||
enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, sPoolAddr, sWalletAddr,
|
||||
sPoolPwd, iCallTimeout, iNetRetry, iVerboseLevel, iAutohashTime, iHttpdPort, bPreferIpv4 };
|
||||
|
||||
struct configVal {
|
||||
configEnum iName;
|
||||
@@ -55,6 +55,7 @@ configVal oConfigValues[] = {
|
||||
{ iNetRetry, "retry_time", kNumberType },
|
||||
{ iVerboseLevel, "verbose_level", kNumberType },
|
||||
{ iAutohashTime, "h_print_time", kNumberType },
|
||||
{ iHttpdPort, "httpd_port", kNumberType },
|
||||
{ bPreferIpv4, "prefer_ipv4", kTrueType }
|
||||
};
|
||||
|
||||
@@ -185,6 +186,11 @@ uint64_t jconf::GetAutohashTime()
|
||||
return prv->configValues[iAutohashTime]->GetUint64();
|
||||
}
|
||||
|
||||
uint16_t jconf::GetHttpdPort()
|
||||
{
|
||||
return prv->configValues[iHttpdPort]->GetUint();
|
||||
}
|
||||
|
||||
bool jconf::parse_config(const char* sFilename)
|
||||
{
|
||||
FILE * pFile;
|
||||
@@ -317,6 +323,13 @@ bool jconf::parse_config(const char* sFilename)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!prv->configValues[iHttpdPort]->IsUint() || prv->configValues[iHttpdPort]->GetUint() > 0xFFFF)
|
||||
{
|
||||
printer::inst()->print_msg(L0,
|
||||
"Invalid config file. httpd_port has to be in the range 0 to 65535.");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if(GetSlowMemSetting() == no_mlck)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,9 @@ public:
|
||||
|
||||
uint64_t GetCallTimeout();
|
||||
uint64_t GetNetRetry();
|
||||
|
||||
uint16_t GetHttpdPort();
|
||||
|
||||
bool PreferIpv4();
|
||||
|
||||
private:
|
||||
|
||||
+6
-2
@@ -21,7 +21,6 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add library="pthread" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
@@ -41,7 +40,6 @@
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add library="pthread" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release_test">
|
||||
@@ -67,6 +65,10 @@
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="pthread" />
|
||||
<Add library="libmicrohttpd" />
|
||||
</Linker>
|
||||
<Unit filename="cli-miner.cpp" />
|
||||
<Unit filename="console.cpp" />
|
||||
<Unit filename="console.h" />
|
||||
@@ -104,6 +106,8 @@
|
||||
<Unit filename="donate-level.h" />
|
||||
<Unit filename="executor.cpp" />
|
||||
<Unit filename="executor.h" />
|
||||
<Unit filename="httpd.cpp" />
|
||||
<Unit filename="httpd.h" />
|
||||
<Unit filename="jconf.cpp" />
|
||||
<Unit filename="jconf.h" />
|
||||
<Unit filename="jext.h" />
|
||||
|
||||
Reference in New Issue
Block a user