mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
feature: Added network proxy support for hex::Net (#562)
* feat(i18n): update Chinese(Simplified) translation * feat: proxy setting * refactor: add hex::Net::setProxy * fix: undefined symbol: hex::Net::m_proxyUrl * style: m_proxyUrl -> s_proxyUrl
This commit is contained in:
@@ -49,6 +49,8 @@ namespace hex {
|
||||
|
||||
void cancel() { this->m_shouldCancel = true; }
|
||||
|
||||
static void setProxy(const std::string &url);
|
||||
|
||||
private:
|
||||
void setCommonSettings(std::string &response, const std::string &url, u32 timeout = 2000, const std::map<std::string, std::string> &extraHeaders = {}, const std::string &body = {});
|
||||
std::optional<i32> execute();
|
||||
@@ -62,6 +64,8 @@ namespace hex {
|
||||
std::mutex m_transmissionActive;
|
||||
float m_progress = 0.0F;
|
||||
bool m_shouldCancel = false;
|
||||
|
||||
static std::string s_proxyUrl;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -113,6 +115,8 @@ namespace hex {
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_SSLCERTTYPE, "PEM");
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_SSL_CTX_FUNCTION, sslCtxFunction);
|
||||
#endif
|
||||
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_PROXY, Net::s_proxyUrl.c_str());
|
||||
}
|
||||
|
||||
std::optional<i32> Net::execute() {
|
||||
@@ -241,4 +245,10 @@ namespace hex {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string Net::s_proxyUrl;
|
||||
|
||||
void Net::setProxy(const std::string &url) {
|
||||
Net::s_proxyUrl = url;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user