Add HTTP proxy support.

Add support for using a proxy for HTTP requests. Only used for external
requests, such as downloading files or talking to source sites such as
Pixiv or Twitter, not for internal requests, such as talking to IQDB or
Reportbooru.
This commit is contained in:
evazion
2021-08-28 01:17:32 -05:00
parent 349bf14764
commit bb7f24d279
5 changed files with 27 additions and 8 deletions

View File

@@ -117,6 +117,14 @@ module Danbooru
use(cache: { expires_in: expires_in })
end
def proxy(host: Danbooru.config.http_proxy_host, port: Danbooru.config.http_proxy_port.to_i, username: Danbooru.config.http_proxy_username, password: Danbooru.config.http_proxy_password)
return self if host.blank?
dup.tap do |o|
o.http = o.http.via(host, port, username, password)
end
end
# allow requests only to public IPs, not to local or private networks.
def public_only
dup.tap do |o|