aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-12-20 02:37:18 +0100
committerdec05eba <dec05eba@protonmail.com>2019-12-20 02:37:18 +0100
commitad23cbf1343c744eded60736c98370d2ed99f753 (patch)
tree8146799f89aa1678c9e472bdfb5e8c73c4462b71
parent5ef35784af24e5fcaa0f8570c23299d01b46412a (diff)
Fix tor not used for all connections when enabled
-rw-r--r--include/DownloadUtils.hpp2
-rw-r--r--src/Body.cpp2
-rw-r--r--src/Program.c4
-rw-r--r--src/QuickMedia.cpp2
-rw-r--r--src/plugins/Fourchan.cpp6
-rw-r--r--src/plugins/Manganelo.cpp6
-rw-r--r--src/plugins/Pornhub.cpp4
-rw-r--r--src/plugins/Youtube.cpp4
8 files changed, 15 insertions, 15 deletions
diff --git a/include/DownloadUtils.hpp b/include/DownloadUtils.hpp
index 78fc859..0411236 100644
--- a/include/DownloadUtils.hpp
+++ b/include/DownloadUtils.hpp
@@ -20,6 +20,6 @@ namespace QuickMedia {
std::string value;
};
- DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args = {}, bool use_tor = false);
+ DownloadResult download_to_string(const std::string &url, std::string &result, const std::vector<CommandArg> &additional_args, bool use_tor);
std::vector<CommandArg> create_command_args_from_form_data(const std::vector<FormData> &form_data);
} \ No newline at end of file
diff --git a/src/Body.cpp b/src/Body.cpp
index 50d46ce..c892c4e 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -112,7 +112,7 @@ namespace QuickMedia {
loading_thumbnail = true;
thumbnail_load_thread = std::thread([this, result, url]() {
std::string texture_data;
- if(download_to_string(url, texture_data) == DownloadResult::OK) {
+ if(download_to_string(url, texture_data, {}, program->get_current_plugin()->use_tor) == DownloadResult::OK) {
if(result->loadFromMemory(texture_data.data(), texture_data.size())) {
//result->generateMipmap();
}
diff --git a/src/Program.c b/src/Program.c
index 8d20d43..3246d54 100644
--- a/src/Program.c
+++ b/src/Program.c
@@ -55,7 +55,7 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void
break;
}
- if(waitpid(pid, &status, WUNTRACED) == -1) {
+ if(waitpid(pid, &status, 0) == -1) {
perror("waitpid failed");
result = -5;
goto cleanup;
@@ -89,7 +89,7 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void
int wait_program(pid_t process_id) {
int status;
- if(waitpid(process_id, &status, WUNTRACED) == -1) {
+ if(waitpid(process_id, &status, 0) == -1) {
perror("waitpid failed");
return -errno;
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 5fcfc73..557370a 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1049,7 +1049,7 @@ namespace QuickMedia {
return true;
std::string image_content;
- if(download_to_string(url, image_content) != DownloadResult::OK) {
+ if(download_to_string(url, image_content, {}, current_plugin->use_tor) != DownloadResult::OK) {
show_notification("Manganelo", "Failed to download image: " + url, Urgency::CRITICAL);
return false;
}
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index c571ef8..438dc3b 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -13,7 +13,7 @@ static const std::string fourchan_image_url = "https://i.4cdn.org/";
namespace QuickMedia {
PluginResult Fourchan::get_front_page(BodyItems &result_items) {
std::string server_response;
- if(download_to_string(fourchan_url + "boards.json", server_response) != DownloadResult::OK)
+ if(download_to_string(fourchan_url + "boards.json", server_response, {}, use_tor) != DownloadResult::OK)
return PluginResult::NET_ERR;
Json::Value json_root;
@@ -153,7 +153,7 @@ namespace QuickMedia {
PluginResult Fourchan::get_threads(const std::string &url, BodyItems &result_items) {
std::string server_response;
- if(download_to_string(fourchan_url + url + "/catalog.json", server_response) != DownloadResult::OK)
+ if(download_to_string(fourchan_url + url + "/catalog.json", server_response, {}, use_tor) != DownloadResult::OK)
return PluginResult::NET_ERR;
Json::Value json_root;
@@ -281,7 +281,7 @@ namespace QuickMedia {
PluginResult Fourchan::get_thread_comments(const std::string &list_url, const std::string &url, BodyItems &result_items) {
std::string server_response;
- if(download_to_string(fourchan_url + list_url + "/thread/" + url + ".json", server_response) != DownloadResult::OK)
+ if(download_to_string(fourchan_url + list_url + "/thread/" + url + ".json", server_response, {}, use_tor) != DownloadResult::OK)
return PluginResult::NET_ERR;
Json::Value json_root;
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp
index 7af35a6..a7ed4bc 100644
--- a/src/plugins/Manganelo.cpp
+++ b/src/plugins/Manganelo.cpp
@@ -5,7 +5,7 @@
namespace QuickMedia {
SearchResult Manganelo::search(const std::string &url, BodyItems &result_items) {
std::string website_data;
- if(download_to_string(url, website_data) != DownloadResult::OK)
+ if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK)
return SearchResult::NET_ERR;
QuickMediaHtmlSearch html_search;
@@ -57,7 +57,7 @@ namespace QuickMedia {
CommandArg data_arg = { "--data", std::move(search_term) };
std::string server_response;
- if(download_to_string(url, server_response, {data_arg}) != DownloadResult::OK)
+ if(download_to_string(url, server_response, {data_arg}, use_tor) != DownloadResult::OK)
return SuggestionResult::NET_ERR;
if(server_response.empty())
@@ -111,7 +111,7 @@ namespace QuickMedia {
last_chapter_image_urls.clear();
std::string website_data;
- if(download_to_string(url, website_data) != DownloadResult::OK)
+ if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK)
return ImageResult::NET_ERR;
QuickMediaHtmlSearch html_search;
diff --git a/src/plugins/Pornhub.cpp b/src/plugins/Pornhub.cpp
index 4955efd..c94532b 100644
--- a/src/plugins/Pornhub.cpp
+++ b/src/plugins/Pornhub.cpp
@@ -31,7 +31,7 @@ namespace QuickMedia {
url += url_param_encode(text);
std::string website_data;
- if(download_to_string(url, website_data) != DownloadResult::OK)
+ if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK)
return SuggestionResult::NET_ERR;
struct ItemData {
@@ -86,7 +86,7 @@ namespace QuickMedia {
BodyItems result_items;
std::string website_data;
- if(download_to_string(url, website_data) != DownloadResult::OK)
+ if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK)
return result_items;
struct ItemData {
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 0f0ca05..3660810 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -75,7 +75,7 @@ namespace QuickMedia {
url += url_param_encode(text);
std::string website_data;
- if(download_to_string(url, website_data) != DownloadResult::OK)
+ if(download_to_string(url, website_data, {}, use_tor) != DownloadResult::OK)
return SuggestionResult::NET_ERR;
struct ItemData {
@@ -164,7 +164,7 @@ namespace QuickMedia {
}
std::string website_data;
- if(download_to_string(modified_url, website_data) != DownloadResult::OK)
+ if(download_to_string(modified_url, website_data, {}, use_tor) != DownloadResult::OK)
return result_items;
QuickMediaHtmlSearch html_search;