mirror of
https://github.com/transmission/transmission
synced 2025-03-12 23:23:54 +00:00
feat: proxy support for web-connections (#5038)
* feature: proxy support for web-connections * forgotten changes * fix code-styles * Documentation for new setting "proxy-url" * Create property proxyUrl for class tr_web. Lazy creation of tr_web object in tr_session after loaded settings from file * Update docs/Editing-Configuration-Files.md Simplify the documentation text Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com> * Fix merge error * Fix merge error. * Simplify tr_web's lifecycle. Fix error. Rename quark to sneak_case-style * Fix parameter value test --------- Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
7b83c7d625
commit
2c5b7f94d1
7 changed files with 22 additions and 0 deletions
|
@ -81,6 +81,7 @@ Here is a sample of the three basic types: respectively Boolean, Number and Stri
|
|||
* **message-level:** Number (0 = None, 1 = Critical, 2 = Error, 3 = Warn, 4 = Info, 5 = Debug, 6 = Trace; default = 4) Set verbosity of Transmission's log messages.
|
||||
* **pex-enabled:** Boolean (default = true) Enable [Peer Exchange (PEX)](https://en.wikipedia.org/wiki/Peer_exchange).
|
||||
* **pidfile:** String Path to file in which daemon PID will be stored (_transmission-daemon only_)
|
||||
* **proxy_url:** String (default = "") Proxy for HTTP(S) requests (for example, requests to tracker). Format `[scheme]://[host]:[port]`, where `scheme` is one of: `http`, `https`, `socks4`, `socks4h`, `socks5`, `socks5h`. If unspecified, or empty, no proxy is used. For more information see [curl proxy documentation](https://curl.se/libcurl/c/CURLOPT_PROXY.html)
|
||||
* **scrape-paused-torrents-enabled:** Boolean (default = true)
|
||||
* **script-torrent-added-enabled:** Boolean (default = false) Run a script when a torrent is added to Transmission. Environmental variables are passed in as detailed on the [Scripts](./Scripts.md) page.
|
||||
* **script-torrent-added-filename:** String (default = "") Path to script.
|
||||
|
|
|
@ -263,6 +263,7 @@ auto constexpr MyStatic = std::array<std::string_view, TR_N_KEYS>{
|
|||
"private"sv,
|
||||
"progress"sv,
|
||||
"prompt-before-exit"sv,
|
||||
"proxy_url"sv,
|
||||
"queue-move-bottom"sv,
|
||||
"queue-move-down"sv,
|
||||
"queue-move-top"sv,
|
||||
|
|
|
@ -265,6 +265,7 @@ enum
|
|||
TR_KEY_private,
|
||||
TR_KEY_progress,
|
||||
TR_KEY_prompt_before_exit,
|
||||
TR_KEY_proxy_url,
|
||||
TR_KEY_queue_move_bottom,
|
||||
TR_KEY_queue_move_down,
|
||||
TR_KEY_queue_move_top,
|
||||
|
|
|
@ -349,6 +349,11 @@ size_t tr_session::WebMediator::clamp(int torrent_id, size_t byte_count) const
|
|||
return tor == nullptr ? 0U : tor->bandwidth().clamp(TR_DOWN, byte_count);
|
||||
}
|
||||
|
||||
std::optional<std::string_view> tr_session::WebMediator::proxyUrl() const
|
||||
{
|
||||
return session_->settings_.proxy_url;
|
||||
}
|
||||
|
||||
void tr_session::WebMediator::run(tr_web::FetchDoneFunc&& func, tr_web::FetchResponse&& response) const
|
||||
{
|
||||
session_->run_in_session_thread(std::move(func), std::move(response));
|
||||
|
|
|
@ -263,6 +263,7 @@ private:
|
|||
[[nodiscard]] std::optional<std::string> bind_address_V6() const override;
|
||||
[[nodiscard]] std::optional<std::string_view> userAgent() const override;
|
||||
[[nodiscard]] size_t clamp(int torrent_id, size_t byte_count) const override;
|
||||
[[nodiscard]] std::optional<std::string_view> proxyUrl() const override;
|
||||
[[nodiscard]] time_t now() const override;
|
||||
// runs the tr_web::fetch response callback in the libtransmission thread
|
||||
void run(tr_web::FetchDoneFunc&& func, tr_web::FetchResponse&& response) const override;
|
||||
|
@ -436,6 +437,7 @@ public:
|
|||
std::string script_torrent_added_filename;
|
||||
std::string script_torrent_done_filename;
|
||||
std::string script_torrent_done_seeding_filename;
|
||||
std::string proxy_url;
|
||||
tr_encryption_mode encryption_mode = TR_ENCRYPTION_PREFERRED;
|
||||
tr_log_level log_level = TR_LOG_INFO;
|
||||
tr_mode_t umask = 022;
|
||||
|
@ -481,6 +483,7 @@ public:
|
|||
{ TR_KEY_port_forwarding_enabled, &port_forwarding_enabled },
|
||||
{ TR_KEY_preallocation, &preallocation_mode },
|
||||
{ TR_KEY_preferred_transport, &preferred_transport },
|
||||
{ TR_KEY_proxy_url, &proxy_url },
|
||||
{ TR_KEY_queue_stalled_enabled, &queue_stalled_enabled },
|
||||
{ TR_KEY_queue_stalled_minutes, &queue_stalled_minutes },
|
||||
{ TR_KEY_ratio_limit, &ratio_limit },
|
||||
|
|
|
@ -621,6 +621,11 @@ public:
|
|||
(void)curl_easy_setopt(e, CURLOPT_COOKIEFILE, file.c_str());
|
||||
}
|
||||
|
||||
if (auto const& proxyUrl = mediator.proxyUrl().value_or(""); !std::empty(proxyUrl))
|
||||
{
|
||||
(void)curl_easy_setopt(e, CURLOPT_PROXY, proxyUrl.data());
|
||||
}
|
||||
|
||||
if (auto const& range = task.range(); range)
|
||||
{
|
||||
/* don't bother asking the server to compress webseed fragments */
|
||||
|
|
|
@ -149,6 +149,12 @@ public:
|
|||
return byte_count;
|
||||
}
|
||||
|
||||
// Return the preferred proxy url
|
||||
[[nodiscard]] virtual std::optional<std::string_view> proxyUrl() const
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Invoke the user-provided fetch callback
|
||||
virtual void run(FetchDoneFunc&& func, FetchResponse&& response) const
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue