mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-20 06:08:37 +02:00
Merge pull request #701 from fireice-uk/topic-http-cli
Add option to enable web interface from cli
This commit is contained in:
@@ -85,6 +85,9 @@ void help()
|
||||
#ifndef CONF_NO_CUDA
|
||||
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;
|
||||
@@ -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());
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+4
-1
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user