summaryrefslogtreecommitdiffstats
path: root/xmrstak/cli
diff options
context:
space:
mode:
authorfireice-uk <fireice-uk@users.noreply.github.com>2017-12-25 14:54:30 +0000
committerfireice-uk <fireice-uk@users.noreply.github.com>2017-12-25 15:23:43 +0000
commit9201a73269ad057d93d7c850aa68336b264f5468 (patch)
tree153a7c093eb40c1bab3816a572a979b5551ed822 /xmrstak/cli
parent52c305796127258f29d119843e86906541ea27b3 (diff)
downloadxmr-stak-9201a73269ad057d93d7c850aa68336b264f5468.zip
xmr-stak-9201a73269ad057d93d7c850aa68336b264f5468.tar.gz
Add option to enable web interface from cli
Diffstat (limited to 'xmrstak/cli')
-rw-r--r--xmrstak/cli/cli-miner.cpp58
1 files changed, 55 insertions, 3 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());
OpenPOWER on IntegriCloud