From da0b2ddc2ae47764764e932283d140f6f9508f7d Mon Sep 17 00:00:00 2001 From: Richard Ulrich Date: Wed, 26 Jan 2022 14:56:11 +0100 Subject: [PATCH] Downloading the binaries through a proxy if either HTTPS_PROXY or HTTP_PROXY environment variable is set. closes #29 --- Cargo.toml | 4 ++-- build.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a57f709..862c74a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ license = "MIT" edition = "2018" [dependencies] -bitcoind = { version = "0.27.0" } -electrum-client = { version="0.12.0", default-features = false } +bitcoind = { git = "https://github.com/weareseba/bitcoind", branch = "feature/proxy" } +electrum-client = { version="0.11", default-features = false } nix = { version="0.25.0" } log = "0.4" diff --git a/build.rs b/build.rs index 2be2820..8a45c5d 100644 --- a/build.rs +++ b/build.rs @@ -45,7 +45,16 @@ fn main() { let url = format!("{}/{}", GITHUB_URL, download_filename); let mut downloaded_bytes = Vec::new(); - let _size = ureq::get(&url) + let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY")); + let agent = if let Ok(proxy) = http_proxy { + let proxy = ureq::Proxy::new(proxy).unwrap(); + ureq::AgentBuilder::new().proxy(proxy).build() + } else { + ureq::AgentBuilder::new().build() + }; + + let _size = agent + .get(&url) .call() .unwrap() .into_reader()