Skip to content

Commit

Permalink
Downloading the binaries through a proxy if either HTTPS_PROXY or HTT…
Browse files Browse the repository at this point in the history
…P_PROXY environment variable is set.

closes #48
  • Loading branch information
ulrichard committed Sep 29, 2022
1 parent 4c3af5c commit 5c83cc7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
strategy:
fail-fast: false
matrix:
toolchain: [ "1.41.1", "stable", "nightly" ]
toolchain: [ "1.42", "stable", "nightly" ]

steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation = "https://docs.rs/bitcoind/"
edition = "2018"

[dependencies]
bitcoincore-rpc = "0.16.0"
bitcoincore-rpc = "0.15.0"
tempfile = "3.1"
log = "0.4"
which = "4.2.5"
Expand All @@ -18,14 +18,12 @@ which = "4.2.5"
env_logger = "0.8"

[build-dependencies]
bitcoin_hashes = "0.11"
bitcoin_hashes = "0.10"
ureq = "2.1"
flate2 = "1.0"
tar = "0.4"
zip = "0.5"

# allows to keep MSRV 1.41.1
ureq = "1.0"
filetime = "=0.2.15"
flate2 = "=1.0.22"

[features]
"23_0" = []
Expand Down
15 changes: 12 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,19 @@ fn main() {
);
println!("url:{}", url);
let mut downloaded_bytes = Vec::new();
let resp = ureq::get(&url).call();
assert_eq!(resp.status(), 200, "url {} didn't return 200", url);

let _size = resp
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()
.read_to_end(&mut downloaded_bytes)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ mod test {

// bob wallet may not be immediately updated
for _ in 0..30 {
if bob.get_balances().unwrap().mine.untrusted_pending.to_sat() > 0 {
if bob.get_balances().unwrap().mine.untrusted_pending.as_sat() > 0 {
break;
}
std::thread::sleep(std::time::Duration::from_millis(100));
Expand Down

0 comments on commit 5c83cc7

Please sign in to comment.