mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-04-25 03:16:59 -04:00
window_launcher: use id instead of hash for RL
This commit is contained in:
@@ -98,17 +98,17 @@ Browser::Launcher::Launcher(
|
||||
this->runelite_path = data_dir;
|
||||
this->runelite_path.append("runelite.jar");
|
||||
|
||||
this->runelite_hash_path = data_dir;
|
||||
this->runelite_hash_path.append("runelite.jar.sha256");
|
||||
this->runelite_id_path = data_dir;
|
||||
this->runelite_id_path.append("runelite_id.bin");
|
||||
|
||||
std::ifstream rs_deb_hashfile(this->rs3_hash_path.c_str(), std::ios::in | std::ios::binary);
|
||||
if (!rs_deb_hashfile.fail()) {
|
||||
url << "&rs3_linux_installed_hash=" << rs_deb_hashfile.rdbuf();
|
||||
}
|
||||
|
||||
std::ifstream rl_hashfile(this->runelite_hash_path.c_str(), std::ios::in | std::ios::binary);
|
||||
std::ifstream rl_hashfile(this->runelite_id_path.c_str(), std::ios::in | std::ios::binary);
|
||||
if (!rl_hashfile.fail()) {
|
||||
url << "&runelite_installed_hash=" << rl_hashfile.rdbuf();
|
||||
url << "&runelite_installed_id=" << rl_hashfile.rdbuf();
|
||||
}
|
||||
|
||||
std::ifstream creds_file(this->creds_path.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Browser {
|
||||
std::filesystem::path rs3_path;
|
||||
std::filesystem::path rs3_hash_path;
|
||||
std::filesystem::path runelite_path;
|
||||
std::filesystem::path runelite_hash_path;
|
||||
std::filesystem::path runelite_id_path;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ CefRefPtr<CefResourceRequestHandler> Browser::Launcher::LaunchRuneliteJar(CefRef
|
||||
|
||||
// array of structures for keeping track of which environment variables we want to set and have already set
|
||||
EnvQueryParam rl_path_param = {.should_set = false, .key = "jar_path"};
|
||||
EnvQueryParam hash_param = {.should_set = false, .key = "hash"};
|
||||
EnvQueryParam id_param = {.should_set = false, .key = "id"};
|
||||
EnvQueryParam scale_param = {.should_set = false, .key = "scale"};
|
||||
EnvQueryParam env_params[] = {
|
||||
{.should_set = false, .prepend_env_key = true, .env_key = "JX_ACCESS_TOKEN=", .key = "jx_access_token"},
|
||||
@@ -380,7 +380,7 @@ CefRefPtr<CefResourceRequestHandler> Browser::Launcher::LaunchRuneliteJar(CefRef
|
||||
for (EnvQueryParam& param: env_params) {
|
||||
param.CheckAndUpdate(key, value);
|
||||
}
|
||||
hash_param.CheckAndUpdate(key, value);
|
||||
id_param.CheckAndUpdate(key, value);
|
||||
scale_param.CheckAndUpdate(key, value);
|
||||
rl_path_param.CheckAndUpdate(key, value);
|
||||
|
||||
@@ -398,8 +398,8 @@ CefRefPtr<CefResourceRequestHandler> Browser::Launcher::LaunchRuneliteJar(CefRef
|
||||
} else {
|
||||
jar_path = this->runelite_path;
|
||||
|
||||
// if there was a "hash" in the query string, we need to save the new jar and hash
|
||||
if (hash_param.should_set) {
|
||||
// if there was an "id" in the query string, we need to save the new jar and hash
|
||||
if (id_param.should_set) {
|
||||
if (post_data == nullptr || post_data->GetElementCount() != 1) {
|
||||
// hash param must be accompanied by POST data containing the file it's a hash of,
|
||||
// so hash but no POST is a bad request
|
||||
@@ -517,15 +517,15 @@ CefRefPtr<CefResourceRequestHandler> Browser::Launcher::LaunchRuneliteJar(CefRef
|
||||
if (r == 0) {
|
||||
fmt::print("[B] Successfully spawned game process with pid {}\n", pid);
|
||||
|
||||
if (hash_param.should_set) {
|
||||
if (id_param.should_set) {
|
||||
size_t written = 0;
|
||||
int file = open(this->runelite_hash_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
int file = open(this->runelite_id_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (file == -1) {
|
||||
const char* data = "OK, but unable to save hash file\n";
|
||||
const char* data = "OK, but unable to save ID file\n";
|
||||
return new ResourceHandler(reinterpret_cast<const unsigned char*>(data), strlen(data), 200, "text/plain");
|
||||
}
|
||||
while (written < hash_param.value.size()) {
|
||||
written += write(file, hash_param.value.c_str() + written, hash_param.value.size() - written);
|
||||
while (written < id_param.value.size()) {
|
||||
written += write(file, id_param.value.c_str() + written, id_param.value.size() - written);
|
||||
}
|
||||
close(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user