46 lines
893 B
C++
46 lines
893 B
C++
|
#include "STDInclude.hpp"
|
||
|
|
||
|
namespace Utils
|
||
|
{
|
||
|
const char* Cache::urls[] =
|
||
|
{
|
||
|
"https://iw4xcachep26muba.onion.to"/*,
|
||
|
"https://iw4xcachejnetuln.onion.to",
|
||
|
"https://iw4xcachedjodc4y.onion.to",
|
||
|
*/
|
||
|
};
|
||
|
std::string Cache::validUrl;
|
||
|
|
||
|
Cache::Cache(std::string path)
|
||
|
{
|
||
|
this->Path = path;
|
||
|
}
|
||
|
|
||
|
std::string Cache::GetUrl()
|
||
|
{
|
||
|
if (Cache::validUrl.empty())
|
||
|
return Cache::urls[0] + this->Path;
|
||
|
else
|
||
|
return Cache::validUrl + this->Path;
|
||
|
}
|
||
|
|
||
|
std::string Cache::GetUrl(std::string url, std::string path)
|
||
|
{
|
||
|
return url + path;
|
||
|
}
|
||
|
|
||
|
std::string Cache::GetFile(int timeout, std::string useragent)
|
||
|
{
|
||
|
for (int i = 0; i < ARRAY_SIZE(Cache::urls); i++)
|
||
|
{
|
||
|
std::string result = Utils::WebIO(useragent, this->GetUrl(Cache::urls[i], this->Path)).setTimeout(timeout)->get();
|
||
|
if (!result.empty())
|
||
|
{
|
||
|
Cache::validUrl = Cache::urls[i];
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
return "";
|
||
|
}
|
||
|
}
|