mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Added --timeout option to set timeout for connection phase
This commit is contained in:
parent
b1db888094
commit
fe70090b74
@ -73,7 +73,7 @@ class API
|
|||||||
public:
|
public:
|
||||||
userDetails user;
|
userDetails user;
|
||||||
|
|
||||||
API(const std::string& token,const std::string& secret, const bool& verbose = false, const bool& bVerifyPeer = true);
|
API(const std::string& token,const std::string& secret, const bool& verbose = false, const bool& bVerifyPeer = true, const long int& iTimeout = 10);
|
||||||
int init();
|
int init();
|
||||||
int login(const std::string& email, const std::string& password);
|
int login(const std::string& email, const std::string& password);
|
||||||
int getAPIConfig();
|
int getAPIConfig();
|
||||||
|
@ -45,6 +45,7 @@ class Config
|
|||||||
unsigned int iInstallerLanguage;
|
unsigned int iInstallerLanguage;
|
||||||
size_t iChunkSize;
|
size_t iChunkSize;
|
||||||
curl_off_t iDownloadRate;
|
curl_off_t iDownloadRate;
|
||||||
|
long int iTimeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_H__
|
#endif // CONFIG_H__
|
||||||
|
1
main.cpp
1
main.cpp
@ -103,6 +103,7 @@ int main(int argc, char *argv[])
|
|||||||
("no-color", bpo::value<bool>(&config.bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar")
|
("no-color", bpo::value<bool>(&config.bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar")
|
||||||
("verbose", bpo::value<bool>(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information")
|
("verbose", bpo::value<bool>(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information")
|
||||||
("unsecure", bpo::value<bool>(&bUnsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
("unsecure", bpo::value<bool>(&bUnsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
||||||
|
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
||||||
;
|
;
|
||||||
|
|
||||||
bpo::store(bpo::parse_command_line(argc, argv, desc), vm);
|
bpo::store(bpo::parse_command_line(argc, argv, desc), vm);
|
||||||
|
@ -33,13 +33,13 @@ gameFile::~gameFile()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
API::API(const std::string& token, const std::string& secret, const bool& verbose, const bool& bVerifyPeer)
|
API::API(const std::string& token, const std::string& secret, const bool& verbose, const bool& bVerifyPeer, const long int& iTimeout)
|
||||||
{
|
{
|
||||||
curlhandle = curl_easy_init();
|
curlhandle = curl_easy_init();
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, verbose);
|
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, verbose);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, 10);
|
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, iTimeout);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSDATA, this);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSDATA, this);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FAILONERROR, true);
|
curl_easy_setopt(curlhandle, CURLOPT_FAILONERROR, true);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, bVerifyPeer);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, bVerifyPeer);
|
||||||
|
@ -52,7 +52,7 @@ int Downloader::init()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_USERAGENT, config.sVersionString.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_USERAGENT, config.sVersionString.c_str());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, 10);
|
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, config.iTimeout);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSDATA, this);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSDATA, this);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FAILONERROR, true);
|
curl_easy_setopt(curlhandle, CURLOPT_FAILONERROR, true);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_COOKIEFILE, config.sCookiePath.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_COOKIEFILE, config.sCookiePath.c_str());
|
||||||
@ -66,7 +66,7 @@ int Downloader::init()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose, config.bVerifyPeer);
|
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose, config.bVerifyPeer, config.iTimeout);
|
||||||
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
||||||
|
|
||||||
if (config.bLogin || !gogAPI->init())
|
if (config.bLogin || !gogAPI->init())
|
||||||
|
Loading…
Reference in New Issue
Block a user