mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-21 06:18:34 +02:00
Merge pull request #1062 from fireice-uk/topic-rigid
Add rig identifier
This commit is contained in:
@@ -95,6 +95,7 @@ void help()
|
||||
cout<<" -o, --url URL pool url and port, e.g. pool.usxmrpool.com:3333"<<endl;
|
||||
cout<<" -O, --tls-url URL TLS pool url and port, e.g. pool.usxmrpool.com:10443"<<endl;
|
||||
cout<<" -u, --user USERNAME pool user name or wallet address"<<endl;
|
||||
cout<<" -r, --rigid RIGID rig identifier for pool-side statistics (needs pool support)"<<endl;
|
||||
cout<<" -p, --pass PASSWD pool password, in the most cases x or empty \"\""<<endl;
|
||||
cout<<" --use-nicehash the pool should run in nicehash mode"<<endl;
|
||||
cout<<" \n"<<endl;
|
||||
@@ -146,6 +147,11 @@ std::string get_multipool_entry(bool& final)
|
||||
std::cin.clear(); std::cin.ignore(INT_MAX,'\n');
|
||||
std::cout<<"- Password (mostly empty or x):"<<std::endl;
|
||||
getline(std::cin, passwd);
|
||||
|
||||
std::string rigid;
|
||||
std::cin.clear(); std::cin.ignore(INT_MAX,'\n');
|
||||
std::cout<<"- Rig identifier for pool-side statistics (needs pool support). Can be empty:"<<std::endl;
|
||||
getline(std::cin, rigid);
|
||||
|
||||
#ifdef CONF_NO_TLS
|
||||
bool tls = false;
|
||||
@@ -165,9 +171,9 @@ std::string get_multipool_entry(bool& final)
|
||||
|
||||
final = !read_yes_no("- Do you want to add another pool? (y/n)");
|
||||
|
||||
return "\t{\"pool_address\" : \"" + pool +"\", \"wallet_address\" : \"" + userName + "\", \"pool_password\" : \"" +
|
||||
passwd + "\", \"use_nicehash\" : " + bool_to_str(nicehash) + ", \"use_tls\" : " + bool_to_str(tls) +
|
||||
", \"tls_fingerprint\" : \"\", \"pool_weight\" : " + std::to_string(pool_weight) + " },\n";
|
||||
return "\t{\"pool_address\" : \"" + pool +"\", \"wallet_address\" : \"" + userName + "\", \"rig_id\" : \"" + rigid +
|
||||
"\", \"pool_password\" : \"" + passwd + "\", \"use_nicehash\" : " + bool_to_str(nicehash) + ", \"use_tls\" : " +
|
||||
bool_to_str(tls) + ", \"tls_fingerprint\" : \"\", \"pool_weight\" : " + std::to_string(pool_weight) + " },\n";
|
||||
}
|
||||
|
||||
inline void prompt_once(bool& prompted)
|
||||
@@ -268,6 +274,17 @@ void do_guided_config()
|
||||
getline(std::cin, passwd);
|
||||
}
|
||||
|
||||
auto& rigid = params::inst().poolRigid;
|
||||
if(rigid.empty() && !params::inst().userSetRigid)
|
||||
{
|
||||
prompt_once(prompted);
|
||||
|
||||
// clear everything from stdin to allow an empty rigid
|
||||
std::cin.clear(); std::cin.ignore(INT_MAX,'\n');
|
||||
std::cout<<"- Rig identifier for pool-side statistics (needs pool support). Can be empty:"<<std::endl;
|
||||
getline(std::cin, rigid);
|
||||
}
|
||||
|
||||
bool tls;
|
||||
#ifdef CONF_NO_TLS
|
||||
tls = false;
|
||||
@@ -315,9 +332,9 @@ void do_guided_config()
|
||||
pool_weight = 1;
|
||||
|
||||
std::string pool_table;
|
||||
pool_table += "\t{\"pool_address\" : \"" + pool +"\", \"wallet_address\" : \"" + userName + "\", \"pool_password\" : \"" +
|
||||
passwd + "\", \"use_nicehash\" : " + bool_to_str(nicehash) + ", \"use_tls\" : " + bool_to_str(tls) +
|
||||
", \"tls_fingerprint\" : \"\", \"pool_weight\" : " + std::to_string(pool_weight) + " },\n";
|
||||
pool_table += "\t{\"pool_address\" : \"" + pool +"\", \"wallet_address\" : \"" + userName + "\", \"rig_id\" : \"" + rigid +
|
||||
"\", \"pool_password\" : \"" + passwd + "\", \"use_nicehash\" : " + bool_to_str(nicehash) + ", \"use_tls\" : " +
|
||||
bool_to_str(tls) + ", \"tls_fingerprint\" : \"\", \"pool_weight\" : " + std::to_string(pool_weight) + " },\n";
|
||||
|
||||
if(multipool)
|
||||
{
|
||||
@@ -522,6 +539,26 @@ int main(int argc, char *argv[])
|
||||
params::inst().userSetPwd = true;
|
||||
params::inst().poolPasswd = argv[i];
|
||||
}
|
||||
else if(opName.compare("-r") == 0 || opName.compare("--rigid") == 0)
|
||||
{
|
||||
if(!pool_url_set)
|
||||
{
|
||||
printer::inst()->print_msg(L0, "Pool address has to be set if you want to specify rigid.");
|
||||
win_exit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
++i;
|
||||
if( i >=argc )
|
||||
{
|
||||
printer::inst()->print_msg(L0, "No argument for parameter '-r/--rigid' given");
|
||||
win_exit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
params::inst().userSetRigid = true;
|
||||
params::inst().poolRigid = argv[i];
|
||||
}
|
||||
else if(opName.compare("--use-nicehash") == 0)
|
||||
{
|
||||
params::inst().nicehashMode = true;
|
||||
|
||||
@@ -2,6 +2,7 @@ R"===(
|
||||
/*
|
||||
* pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported.
|
||||
* wallet_address - Your wallet, or pool login.
|
||||
* rig_id - Rig identifier for pool-side statistics (needs pool support).
|
||||
* pool_password - Can be empty in most cases or "x".
|
||||
* use_nicehash - Limit the nonce to 3 bytes as required by nicehash.
|
||||
* use_tls - This option will make us connect using Transport Layer Security.
|
||||
|
||||
+5
-3
@@ -129,12 +129,13 @@ bool jconf::GetPoolConfig(size_t id, pool_cfg& cfg)
|
||||
return false;
|
||||
|
||||
typedef const Value* cval;
|
||||
cval jaddr, jlogin, jpasswd, jnicehash, jtls, jtlsfp, jwt;
|
||||
cval jaddr, jlogin, jrigid, jpasswd, jnicehash, jtls, jtlsfp, jwt;
|
||||
const Value& oThdConf = prv->configValues[aPoolList]->GetArray()[id];
|
||||
|
||||
/* We already checked presence and types */
|
||||
jaddr = GetObjectMember(oThdConf, "pool_address");
|
||||
jlogin = GetObjectMember(oThdConf, "wallet_address");
|
||||
jrigid = GetObjectMember(oThdConf, "rig_id");
|
||||
jpasswd = GetObjectMember(oThdConf, "pool_password");
|
||||
jnicehash = GetObjectMember(oThdConf, "use_nicehash");
|
||||
jtls = GetObjectMember(oThdConf, "use_tls");
|
||||
@@ -143,6 +144,7 @@ bool jconf::GetPoolConfig(size_t id, pool_cfg& cfg)
|
||||
|
||||
cfg.sPoolAddr = jaddr->GetString();
|
||||
cfg.sWalletAddr = jlogin->GetString();
|
||||
cfg.sRigId = jrigid->GetString();
|
||||
cfg.sPasswd = jpasswd->GetString();
|
||||
cfg.nicehash = jnicehash->GetBool();
|
||||
cfg.tls = jtls->GetBool();
|
||||
@@ -420,8 +422,8 @@ bool jconf::parse_config(const char* sFilename)
|
||||
std::vector<size_t> pool_weights;
|
||||
pool_weights.reserve(pool_cnt);
|
||||
|
||||
const char* aPoolValues[] = { "pool_address", "wallet_address", "pool_password", "use_nicehash", "use_tls", "tls_fingerprint", "pool_weight" };
|
||||
Type poolValTypes[] = { kStringType, kStringType, kStringType, kTrueType, kTrueType, kStringType, kNumberType };
|
||||
const char* aPoolValues[] = { "pool_address", "wallet_address", "rig_id", "pool_password", "use_nicehash", "use_tls", "tls_fingerprint", "pool_weight" };
|
||||
Type poolValTypes[] = { kStringType, kStringType, kStringType, kStringType, kTrueType, kTrueType, kStringType, kNumberType };
|
||||
|
||||
constexpr size_t pvcnt = sizeof(aPoolValues)/sizeof(aPoolValues[0]);
|
||||
for(uint32_t i=0; i < pool_cnt; i++)
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
struct pool_cfg {
|
||||
const char* sPoolAddr;
|
||||
const char* sWalletAddr;
|
||||
const char* sRigId;
|
||||
const char* sPasswd;
|
||||
bool nicehash;
|
||||
bool tls;
|
||||
|
||||
@@ -518,13 +518,14 @@ void executor::ex_main()
|
||||
already_have_cli_pool = true;
|
||||
|
||||
const char* wallet = params.poolUsername.empty() ? cfg.sWalletAddr : params.poolUsername.c_str();
|
||||
const char* rigid = params.userSetRigid ? params.poolRigid.c_str() : cfg.sRigId;
|
||||
const char* pwd = params.userSetPwd ? params.poolPasswd.c_str() : cfg.sPasswd;
|
||||
bool nicehash = cfg.nicehash || params.nicehashMode;
|
||||
|
||||
pools.emplace_back(i+1, cfg.sPoolAddr, wallet, pwd, 9.9, false, params.poolUseTls, cfg.tls_fingerprint, nicehash);
|
||||
pools.emplace_back(i+1, cfg.sPoolAddr, wallet, rigid, pwd, 9.9, false, params.poolUseTls, cfg.tls_fingerprint, nicehash);
|
||||
}
|
||||
else
|
||||
pools.emplace_back(i+1, cfg.sPoolAddr, cfg.sWalletAddr, cfg.sPasswd, cfg.weight, false, cfg.tls, cfg.tls_fingerprint, cfg.nicehash);
|
||||
pools.emplace_back(i+1, cfg.sPoolAddr, cfg.sWalletAddr, cfg.sRigId, cfg.sPasswd, cfg.weight, false, cfg.tls, cfg.tls_fingerprint, cfg.nicehash);
|
||||
}
|
||||
|
||||
if(!xmrstak::params::inst().poolURL.empty() && !already_have_cli_pool)
|
||||
@@ -536,22 +537,22 @@ void executor::ex_main()
|
||||
win_exit();
|
||||
}
|
||||
|
||||
pools.emplace_back(i+1, params.poolURL.c_str(), params.poolUsername.c_str(), params.poolPasswd.c_str(), 9.9, false, params.poolUseTls, "", params.nicehashMode);
|
||||
pools.emplace_back(i+1, params.poolURL.c_str(), params.poolUsername.c_str(), params.poolRigid.c_str(), params.poolPasswd.c_str(), 9.9, false, params.poolUseTls, "", params.nicehashMode);
|
||||
}
|
||||
|
||||
if(jconf::inst()->IsCurrencyMonero())
|
||||
{
|
||||
if(dev_tls)
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:6666", "", "", 0.0, true, true, "", false);
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:6666", "", "", "", 0.0, true, true, "", false);
|
||||
else
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:3333", "", "", 0.0, true, false, "", false);
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:3333", "", "", "", 0.0, true, false, "", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dev_tls)
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:7777", "", "", 0.0, true, true, "", true);
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:7777", "", "", "", 0.0, true, true, "", true);
|
||||
else
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", 0.0, true, false, "", true);
|
||||
pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", "", 0.0, true, false, "", true);
|
||||
}
|
||||
|
||||
ex_event ev;
|
||||
|
||||
@@ -92,8 +92,8 @@ struct jpsock::opq_json_val
|
||||
opq_json_val(const Value* val) : val(val) {}
|
||||
};
|
||||
|
||||
jpsock::jpsock(size_t id, const char* sAddr, const char* sLogin, const char* sPassword, double pool_weight, bool dev_pool, bool tls, const char* tls_fp, bool nicehash) :
|
||||
net_addr(sAddr), usr_login(sLogin), usr_pass(sPassword), tls_fp(tls_fp), pool_id(id), pool_weight(pool_weight), pool(dev_pool), nicehash(nicehash),
|
||||
jpsock::jpsock(size_t id, const char* sAddr, const char* sLogin, const char* sRigId, const char* sPassword, double pool_weight, bool dev_pool, bool tls, const char* tls_fp, bool nicehash) :
|
||||
net_addr(sAddr), usr_login(sLogin), usr_rigid(sRigId), usr_pass(sPassword), tls_fp(tls_fp), pool_id(id), pool_weight(pool_weight), pool(dev_pool), nicehash(nicehash),
|
||||
connect_time(0), connect_attempts(0), disconnect_time(0), quiet_close(false)
|
||||
{
|
||||
sock_init();
|
||||
@@ -523,8 +523,8 @@ bool jpsock::cmd_login()
|
||||
{
|
||||
char cmd_buffer[1024];
|
||||
|
||||
snprintf(cmd_buffer, sizeof(cmd_buffer), "{\"method\":\"login\",\"params\":{\"login\":\"%s\",\"pass\":\"%s\",\"agent\":\"%s\"},\"id\":1}\n",
|
||||
usr_login.c_str(), usr_pass.c_str(), get_version_str().c_str());
|
||||
snprintf(cmd_buffer, sizeof(cmd_buffer), "{\"method\":\"login\",\"params\":{\"login\":\"%s\",\"pass\":\"%s\",\"rigid\":\"%s\",\"agent\":\"%s\"},\"id\":1}\n",
|
||||
usr_login.c_str(), usr_pass.c_str(), usr_rigid.c_str(), get_version_str().c_str());
|
||||
|
||||
opq_json_val oResult(nullptr);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class base_socket;
|
||||
class jpsock
|
||||
{
|
||||
public:
|
||||
jpsock(size_t id, const char* sAddr, const char* sLogin, const char* sPassword, double pool_weight, bool dev_pool, bool tls, const char* tls_fp, bool nicehash);
|
||||
jpsock(size_t id, const char* sAddr, const char* sLogin, const char* sRigId, const char* sPassword, double pool_weight, bool dev_pool, bool tls, const char* tls_fp, bool nicehash);
|
||||
~jpsock();
|
||||
|
||||
bool connect(std::string& sConnectError);
|
||||
@@ -82,6 +82,7 @@ public:
|
||||
private:
|
||||
std::string net_addr;
|
||||
std::string usr_login;
|
||||
std::string usr_rigid;
|
||||
std::string usr_pass;
|
||||
std::string tls_fp;
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ struct params
|
||||
std::string poolURL;
|
||||
bool userSetPwd = false;
|
||||
std::string poolPasswd;
|
||||
bool userSetRigid = false;
|
||||
std::string poolRigid;
|
||||
std::string poolUsername;
|
||||
bool nicehashMode = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user