feat: handle kiseki.loc/asset redirects
This commit is contained in:
parent
73e6fe9c75
commit
d73e035dc4
|
|
@ -29,5 +29,6 @@ public:
|
|||
static std::string getModulePath();
|
||||
static std::string getISOTimestamp();
|
||||
static std::pair<bool, std::map<std::string, std::string>> parseURL(const std::string url);
|
||||
static std::string getRedirectURL(const std::string url);
|
||||
static std::pair<bool, std::string> httpGet(const std::string url);
|
||||
};
|
||||
|
|
@ -138,6 +138,51 @@ std::string Helpers::getISOTimestamp()
|
|||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::string Helpers::getRedirectURL(const std::string url)
|
||||
{
|
||||
CURL* curl = curl_easy_init();
|
||||
CURLcode result;
|
||||
|
||||
if (!curl)
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
||||
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
if (result != CURLE_OK)
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
long response = 0;
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
|
||||
|
||||
if (response != 301 && response != 302)
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
char* redirectURL;
|
||||
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectURL);
|
||||
|
||||
std::string location = redirectURL ? std::string(redirectURL) : "";
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if (location.empty())
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
std::pair<bool, std::map<std::string, std::string>> Helpers::parseURL(const std::string url)
|
||||
{
|
||||
CURLU* curl = curl_url();
|
||||
|
|
|
|||
|
|
@ -23,11 +23,21 @@ void __fastcall Http__httpGetPostWinInet_hook(Http* _this, void*, bool isPost, i
|
|||
{
|
||||
url["path"] = Helpers::toLower(url["path"]);
|
||||
|
||||
if (url["host"] == "roblox.com" || url["host"] == "www.roblox.com")
|
||||
// TODO: This is a weird hack.
|
||||
if (url["host"] == "kiseki.lol" || url["host"] == "www.kiseki.lol" || url["host"] == "kiseki.loc" || url["host"] == "www.kiseki.loc")
|
||||
{
|
||||
if (url["path"] == "/asset" || url["path"] == "/asset/")
|
||||
{
|
||||
std::string location = Helpers::getRedirectURL(url["scheme"] + "://" + url["host"] + "/asset?" + url["query"]);
|
||||
_this = &_changed;
|
||||
}
|
||||
}
|
||||
else if (url["host"] == "roblox.com" || url["host"] == "www.roblox.com")
|
||||
{
|
||||
if (url["path"] == "/game/tools/insertasset.ashx")
|
||||
{
|
||||
_changed.url = "https://sets.pizzaboxer.xyz/" + url["path"] + "?" + url["query"];
|
||||
_this = &_changed;
|
||||
}
|
||||
else if (url["path"] == "/asset" || url["path"] == "/asset/" || url["path"] == "/asset/default.ashx")
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue