Skip to content

Commit 02c494b

Browse files
committed
Downloading the binaries through a proxy if either HTTPS_PROXY or HTTP_PROXY environment variable is set.
closes #48
1 parent 11c6339 commit 02c494b

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rust-version = "1.57"
1010
edition = "2018"
1111

1212
[dependencies]
13-
bitcoincore-rpc = "0.16.0"
13+
bitcoincore-rpc = "0.15.0"
1414
tempfile = "3.1"
1515
log = "0.4"
1616
which = "4.2.5"

build.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,19 @@ fn main() {
103103
);
104104
println!("url:{}", url);
105105
let mut downloaded_bytes = Vec::new();
106-
let resp = ureq::get(&url).call().unwrap();
107-
assert_eq!(resp.status(), 200, "url {} didn't return 200", url);
108106

109-
let _size = resp
107+
let http_proxy = std::env::var("HTTPS_PROXY").or_else(|_| std::env::var("HTTP_PROXY"));
108+
let agent = if let Ok(proxy) = http_proxy {
109+
let proxy = ureq::Proxy::new(proxy).unwrap();
110+
ureq::AgentBuilder::new().proxy(proxy).build()
111+
} else {
112+
ureq::AgentBuilder::new().build()
113+
};
114+
115+
let _size = agent
116+
.get(&url)
117+
.call()
118+
.unwrap()
110119
.into_reader()
111120
.read_to_end(&mut downloaded_bytes)
112121
.unwrap();

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ mod test {
642642

643643
// bob wallet may not be immediately updated
644644
for _ in 0..30 {
645-
if bob.get_balances().unwrap().mine.untrusted_pending.to_sat() > 0 {
645+
if bob.get_balances().unwrap().mine.untrusted_pending.as_sat() > 0 {
646646
break;
647647
}
648648
std::thread::sleep(std::time::Duration::from_millis(100));

0 commit comments

Comments
 (0)