Initial multiple pools support [2/2].
This commit is contained in:
parent
952017ae7a
commit
c0dcfc2a97
7 changed files with 35 additions and 54 deletions
|
@ -45,7 +45,7 @@ Network::Network(const Options *options) :
|
|||
m_agent = userAgent();
|
||||
|
||||
addPool(std::make_unique<Url>().get());
|
||||
// addPool(m_options->url());
|
||||
addPool(m_options->pools().front());
|
||||
// addPool(m_options->backupUrl());
|
||||
|
||||
m_timer.data = this;
|
||||
|
@ -120,7 +120,7 @@ void Network::onJobResult(const JobResult &result)
|
|||
|
||||
void Network::onLoginCredentialsRequired(Client *client)
|
||||
{
|
||||
// client->login(m_options->user(), m_options->pass(), m_agent);
|
||||
client->login(m_options->pools().front()->password(), m_options->pools().front()->password(), m_agent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@ void Network::addPool(const Url *url)
|
|||
Client *client = new Client(m_pools.size(), this);
|
||||
client->setUrl(url);
|
||||
client->setRetryPause(m_options->retryPause() * 1000);
|
||||
client->setKeepAlive(m_options->keepAlive());
|
||||
// client->setKeepAlive(m_options->keepAlive());
|
||||
|
||||
m_pools.push_back(client);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,24 @@ bool Url::parse(const char *url)
|
|||
}
|
||||
|
||||
|
||||
bool Url::setUserpass(const char *userpass)
|
||||
{
|
||||
const char *p = strchr(userpass, ':');
|
||||
if (!p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
free(m_user);
|
||||
free(m_password);
|
||||
|
||||
m_user = static_cast<char*>(calloc(p - userpass + 1, 1));
|
||||
strncpy(m_user, userpass, p - userpass);
|
||||
m_password = strdup(p + 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Url::setPassword(const char *password, bool force)
|
||||
{
|
||||
if (m_password != nullptr && !force) {
|
||||
|
|
|
@ -51,9 +51,9 @@ public:
|
|||
|
||||
bool isNicehash() const;
|
||||
bool parse(const char *url);
|
||||
bool setUserpass(const char *userpass);
|
||||
void setPassword(const char *password, bool force = true);
|
||||
void setUser(const char *user, bool force = true);
|
||||
|
||||
private:
|
||||
bool m_keepAlive;
|
||||
bool m_nicehash;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue