mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Verify authenticity of SSL certificates by default
Added option --unsecure to disable authenticity verification
This commit is contained in:
parent
8b0de12fe4
commit
e27c585ed7
@ -73,7 +73,7 @@ class API
|
|||||||
apiConfig config;
|
apiConfig config;
|
||||||
userDetails user;
|
userDetails user;
|
||||||
|
|
||||||
API(const std::string& token,const std::string& secret, const bool& verbose = false);
|
API(const std::string& token,const std::string& secret, const bool& verbose = false, const bool& bVerifyPeer = true);
|
||||||
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();
|
||||||
|
@ -29,6 +29,7 @@ class Config
|
|||||||
bool bNoExtras;
|
bool bNoExtras;
|
||||||
bool bNoUnicode; // don't use Unicode in console output
|
bool bNoUnicode; // don't use Unicode in console output
|
||||||
bool bNoColor; // don't use colors
|
bool bNoColor; // don't use colors
|
||||||
|
bool bVerifyPeer;
|
||||||
std::string sGameRegex;
|
std::string sGameRegex;
|
||||||
std::string sDirectory;
|
std::string sDirectory;
|
||||||
std::string sXMLFile;
|
std::string sXMLFile;
|
||||||
|
4
main.cpp
4
main.cpp
@ -75,6 +75,7 @@ int main(int argc, char *argv[])
|
|||||||
bpo::options_description config_file_options("Configuration");
|
bpo::options_description config_file_options("Configuration");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
bool bUnsecure = false;
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("help,h", "Print help message")
|
("help,h", "Print help message")
|
||||||
("login", bpo::value<bool>(&config.bLogin)->zero_tokens()->default_value(false), "Login")
|
("login", bpo::value<bool>(&config.bLogin)->zero_tokens()->default_value(false), "Login")
|
||||||
@ -100,6 +101,7 @@ int main(int argc, char *argv[])
|
|||||||
("no-unicode", bpo::value<bool>(&config.bNoUnicode)->zero_tokens()->default_value(false), "Don't use Unicode in the progress bar")
|
("no-unicode", bpo::value<bool>(&config.bNoUnicode)->zero_tokens()->default_value(false), "Don't use Unicode in the progress bar")
|
||||||
("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")
|
||||||
;
|
;
|
||||||
|
|
||||||
bpo::store(bpo::parse_command_line(argc, argv, desc), vm);
|
bpo::store(bpo::parse_command_line(argc, argv, desc), vm);
|
||||||
@ -139,6 +141,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (vm.count("limit-rate"))
|
if (vm.count("limit-rate"))
|
||||||
config.iDownloadRate <<= 10; // Convert download rate from bytes to kilobytes
|
config.iDownloadRate <<= 10; // Convert download rate from bytes to kilobytes
|
||||||
|
|
||||||
|
config.bVerifyPeer = !bUnsecure;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ gameFile::~gameFile()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
API::API(const std::string& token, const std::string& secret, const bool& verbose)
|
API::API(const std::string& token, const std::string& secret, const bool& verbose, const bool& bVerifyPeer)
|
||||||
{
|
{
|
||||||
curlhandle = curl_easy_init();
|
curlhandle = curl_easy_init();
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, verbose);
|
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, verbose);
|
||||||
@ -42,7 +42,7 @@ API::API(const std::string& token, const std::string& secret, const bool& verbos
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, 10);
|
curl_easy_setopt(curlhandle, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
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, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, bVerifyPeer);
|
||||||
|
|
||||||
this->error = false;
|
this->error = false;
|
||||||
this->getAPIConfig();
|
this->getAPIConfig();
|
||||||
|
@ -58,12 +58,12 @@ int Downloader::init()
|
|||||||
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());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_COOKIEJAR, config.sCookiePath.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_COOKIEJAR, config.sCookiePath.c_str());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
||||||
|
|
||||||
if (config.bVerbose)
|
if (config.bVerbose)
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1);
|
||||||
|
|
||||||
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose);
|
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose, config.bVerifyPeer);
|
||||||
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
||||||
|
|
||||||
if (config.bLogin || !gogAPI->init())
|
if (config.bLogin || !gogAPI->init())
|
||||||
@ -313,7 +313,7 @@ void Downloader::repair()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
||||||
#ifndef ENVIRONMENT32
|
#ifndef ENVIRONMENT32
|
||||||
@ -386,7 +386,7 @@ void Downloader::download()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
||||||
#ifndef ENVIRONMENT32
|
#ifndef ENVIRONMENT32
|
||||||
@ -806,7 +806,7 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath,
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, outfile);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, outfile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user