2016-11-21 04:50:55 -05:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
|
|
|
namespace Utils
|
|
|
|
{
|
2016-11-21 14:49:33 -05:00
|
|
|
const char* Cache::Urls[] =
|
2016-11-21 04:50:55 -05:00
|
|
|
{
|
2018-11-24 20:42:12 -05:00
|
|
|
"https://iw4xcachep26muba.onion.to",
|
|
|
|
"https://iw4xcachep26muba.tor2web.xyz",
|
|
|
|
"https://iw4xcachep26muba.onion.ws",
|
|
|
|
"https://iw4xcachep26muba.onion.sh",
|
|
|
|
"https://iw4xcachep26muba.onion.pet",
|
|
|
|
|
|
|
|
// Links below are dead
|
|
|
|
// Still, let's keep them in case they come back
|
2017-03-10 08:59:33 -05:00
|
|
|
"https://iw4xcachep26muba.onion.rip",
|
2017-06-04 14:51:05 -04:00
|
|
|
"https://iw4xcachep26muba.onion.nu",
|
|
|
|
"https://iw4xcachep26muba.onion.guide",
|
|
|
|
"https://iw4xcachep26muba.onion.casa",
|
|
|
|
"https://iw4xcachep26muba.hiddenservice.net",
|
2018-11-24 20:42:12 -05:00
|
|
|
"https://iw4xcachep26muba.onion.cab",
|
|
|
|
"https://iw4xcachep26muba.onion.link",
|
2017-06-04 14:51:05 -04:00
|
|
|
|
|
|
|
// Not registered yet
|
|
|
|
//"https://iw4xcachejnetuln.onion.to",
|
|
|
|
//"https://iw4xcachedjodc4y.onion.to",
|
2016-11-21 04:50:55 -05:00
|
|
|
};
|
2016-11-21 14:49:33 -05:00
|
|
|
std::string Cache::ValidUrl;
|
2016-11-21 05:09:42 -05:00
|
|
|
std::mutex Cache::CacheMutex;
|
2016-11-21 04:50:55 -05:00
|
|
|
|
2016-11-25 08:16:07 -05:00
|
|
|
std::string Cache::GetStaticUrl(std::string path)
|
2016-11-21 04:50:55 -05:00
|
|
|
{
|
2016-11-25 08:16:07 -05:00
|
|
|
return Cache::Urls[0] + path;
|
2016-11-21 04:50:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Cache::GetUrl(std::string url, std::string path)
|
|
|
|
{
|
|
|
|
return url + path;
|
|
|
|
}
|
|
|
|
|
2016-11-21 14:49:33 -05:00
|
|
|
std::string Cache::GetFile(std::string path, int timeout, std::string useragent)
|
2016-11-21 04:50:55 -05:00
|
|
|
{
|
2016-11-21 14:49:33 -05:00
|
|
|
std::lock_guard<std::mutex> _(Cache::CacheMutex);
|
|
|
|
|
|
|
|
if (Cache::ValidUrl.empty())
|
2016-11-21 04:50:55 -05:00
|
|
|
{
|
2017-06-04 14:51:05 -04:00
|
|
|
InternetSetCookieA("https://onion.casa", "disclaimer_accepted", "1");
|
|
|
|
InternetSetCookieA("https://hiddenservice.net", "disclaimer_accepted", "1");
|
|
|
|
|
2017-04-24 16:33:13 -04:00
|
|
|
for (int i = 0; i < ARRAYSIZE(Cache::Urls); ++i)
|
2016-11-21 04:50:55 -05:00
|
|
|
{
|
2016-11-21 14:49:33 -05:00
|
|
|
std::string result = Utils::WebIO(useragent, Cache::GetUrl(Cache::Urls[i], path)).setTimeout(timeout)->get();
|
|
|
|
|
2016-11-21 05:09:42 -05:00
|
|
|
if (!result.empty())
|
|
|
|
{
|
2016-11-21 14:49:33 -05:00
|
|
|
Cache::ValidUrl = Cache::Urls[i];
|
2016-11-21 05:09:42 -05:00
|
|
|
return result;
|
|
|
|
}
|
2016-11-21 04:50:55 -05:00
|
|
|
}
|
2016-11-21 14:49:33 -05:00
|
|
|
|
|
|
|
return "";
|
2016-11-21 04:50:55 -05:00
|
|
|
}
|
2016-11-21 05:09:42 -05:00
|
|
|
else
|
|
|
|
{
|
2016-11-21 14:49:33 -05:00
|
|
|
return Utils::WebIO(useragent, Cache::GetUrl(Cache::ValidUrl, path)).setTimeout(timeout)->get();
|
2016-11-21 05:09:42 -05:00
|
|
|
}
|
2016-11-21 04:50:55 -05:00
|
|
|
}
|
2017-01-22 14:12:36 -05:00
|
|
|
|
|
|
|
void Cache::Uninitialize()
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> _(Cache::CacheMutex);
|
|
|
|
Cache::ValidUrl.clear();
|
|
|
|
}
|
2016-11-21 04:50:55 -05:00
|
|
|
}
|