summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpsychocrypt <psychocryptHPC@gmail.com>2017-12-25 21:41:32 +0100
committerGitHub <noreply@github.com>2017-12-25 21:41:32 +0100
commit046c2589f8903c3fb58e29c43fa409f7d30ce3f2 (patch)
tree153a7c093eb40c1bab3816a572a979b5551ed822
parent52c305796127258f29d119843e86906541ea27b3 (diff)
parent9201a73269ad057d93d7c850aa68336b264f5468 (diff)
downloadxmr-stak-046c2589f8903c3fb58e29c43fa409f7d30ce3f2.zip
xmr-stak-046c2589f8903c3fb58e29c43fa409f7d30ce3f2.tar.gz
Merge pull request #701 from fireice-uk/topic-http-cli
Add option to enable web interface from cli
-rw-r--r--xmrstak/cli/cli-miner.cpp58
-rw-r--r--xmrstak/config.tpl2
-rw-r--r--xmrstak/jconf.cpp5
-rw-r--r--xmrstak/params.hpp4
4 files changed, 64 insertions, 5 deletions
diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp
index b84b783..077d463 100644
--- a/xmrstak/cli/cli-miner.cpp
+++ b/xmrstak/cli/cli-miner.cpp
@@ -86,6 +86,9 @@ void help()
cout<<" --noNVIDIA disable the NVIDIA miner backend"<<endl;
cout<<" --nvidia FILE NVIDIA backend miner config file"<<endl;
#endif
+#ifndef CONF_NO_HTTPD
+ cout<<" -i --httpd HTTP_PORT HTTP interface port"<<endl;
+#endif
cout<<" "<<endl;
cout<<"The following options can be used for automatic start without a guided config,"<<endl;
cout<<"If config exists then this pool will be top priority."<<endl;
@@ -209,6 +212,28 @@ void do_guided_config()
currency = tmp;
}
+ auto& http_port = params::inst().httpd_port;
+ if(http_port == params::httpd_port_unset)
+ {
+#if defined(CONF_NO_HTTPD)
+ http_port = params::httpd_port_disabled;
+#else
+ std::cout<<"- Do you want to use the HTTP interface?" <<std::endl;
+ std::cout<<"Unlike the screen display, browser interface is not affected by the GPU lag." <<std::endl;
+ std::cout<<"If you don't want to use it, please enter 0, otherwise enter port number that the miner should listen on" <<std::endl;
+
+ int32_t port;
+ while(!(std::cin >> port) || port < 0 || port > 65535)
+ {
+ std::cin.clear();
+ std::cin.ignore(INT_MAX, '\n');
+ std::cout << "Invalid port number. Please enter a number between 0 and 65535." << std::endl;
+ }
+
+ http_port = port;
+#endif
+ }
+
auto& pool = params::inst().poolURL;
bool userSetPool = true;
if(pool.empty())
@@ -306,6 +331,7 @@ void do_guided_config()
configTpl.replace("POOLCONF", pool_table);
configTpl.replace("CURRENCY", currency);
+ configTpl.replace("HTTP_PORT", std::to_string(http_port));
configTpl.write(params::inst().configFile);
std::cout<<"Configuration stored in file '"<<params::inst().configFile<<"'"<<std::endl;
}
@@ -504,6 +530,28 @@ int main(int argc, char *argv[])
}
params::inst().configFile = argv[i];
}
+ else if(opName.compare("-i") == 0 || opName.compare("--httpd") == 0)
+ {
+ ++i;
+ if( i >=argc )
+ {
+ printer::inst()->print_msg(L0, "No argument for parameter '-i/--httpd' given");
+ win_exit();
+ return 1;
+ }
+
+ char* endp = nullptr;
+ long int ret = strtol(argv[i], &endp, 10);
+
+ if(endp == nullptr || ret < 0 || ret > 65535)
+ {
+ printer::inst()->print_msg(L0, "Argument for parameter '-i/--httpd' must be a number between 0 and 65535");
+ win_exit();
+ return 1;
+ }
+
+ params::inst().httpd_port = ret;
+ }
else if(opName.compare("--noUAC") == 0)
{
uacDialog = false;
@@ -546,16 +594,20 @@ int main(int argc, char *argv[])
return 1;
}
-#ifndef CONF_NO_HTTPD
- if(jconf::inst()->GetHttpdPort() != 0)
+ if(jconf::inst()->GetHttpdPort() != uint16_t(params::httpd_port_disabled))
{
+#ifdef CONF_NO_HTTPD
+ printer::inst()->print_msg(L0, "HTTPD port is enabled but this binary was compiled without HTTP support!");
+ win_exit();
+ return 1;
+#else
if (!httpd::inst()->start_daemon())
{
win_exit();
return 1;
}
- }
#endif
+ }
printer::inst()->print_str("-------------------------------------------------------------------\n");
printer::inst()->print_str(get_version_str_short().c_str());
diff --git a/xmrstak/config.tpl b/xmrstak/config.tpl
index ae97190..2c7bd41 100644
--- a/xmrstak/config.tpl
+++ b/xmrstak/config.tpl
@@ -159,7 +159,7 @@ POOLCONF],
*
* httpd_port - Port we should listen on. Default, 0, will switch off the server.
*/
-"httpd_port" : 0,
+"httpd_port" : HTTP_PORT,
/*
* HTTP Authentication
diff --git a/xmrstak/jconf.cpp b/xmrstak/jconf.cpp
index f279f52..a1db451 100644
--- a/xmrstak/jconf.cpp
+++ b/xmrstak/jconf.cpp
@@ -242,7 +242,10 @@ uint64_t jconf::GetAutohashTime()
uint16_t jconf::GetHttpdPort()
{
- return prv->configValues[iHttpdPort]->GetUint();
+ if(xmrstak::params::inst().httpd_port == xmrstak::params::httpd_port_unset)
+ return prv->configValues[iHttpdPort]->GetUint();
+ else
+ return uint16_t(xmrstak::params::inst().httpd_port);
}
const char* jconf::GetHttpUsername()
diff --git a/xmrstak/params.hpp b/xmrstak/params.hpp
index bc32612..62cce47 100644
--- a/xmrstak/params.hpp
+++ b/xmrstak/params.hpp
@@ -31,6 +31,10 @@ struct params
std::string poolUsername;
bool nicehashMode = false;
+ static constexpr int32_t httpd_port_unset = -1;
+ static constexpr int32_t httpd_port_disabled = 0;
+ int32_t httpd_port = httpd_port_unset;
+
std::string currency;
std::string configFile;
OpenPOWER on IntegriCloud