diff --git a/src/lib.rs b/src/lib.rs index 08bfb73..88cdf1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,12 +83,24 @@ pub struct LwsRpcClient { } impl LwsRpcClient { - pub fn new(addr: String) -> Self { - Self { - inner: CallerWrapper(Arc::new(RemoteCaller { - http_client: reqwest::ClientBuilder::new().build().unwrap(), - addr, - })), + pub fn new(addr: String, proxy: Option) -> Self { + if let Some(proxy_address) = proxy { + Self { + inner: CallerWrapper(Arc::new(RemoteCaller { + http_client: reqwest::Client::builder() + .proxy(reqwest::Proxy::all(proxy_address).unwrap()) + .build() + .unwrap(), + addr, + })), + } + } else { + Self { + inner: CallerWrapper(Arc::new(RemoteCaller { + http_client: reqwest::ClientBuilder::new().build().unwrap(), + addr, + })), + } } } diff --git a/tests/rpc.rs b/tests/rpc.rs index f5f7a85..394e28c 100644 --- a/tests/rpc.rs +++ b/tests/rpc.rs @@ -83,6 +83,6 @@ async fn setup_monero() -> ( regtest.generate_blocks(100, address).await.unwrap(); let dhost = env::var("MONERO_DAEMON_HOST").unwrap_or_else(|_| "localhost".into()); - let lws_client = monero_lws::LwsRpcClient::new(format!("http://{}:38884", dhost)); + let lws_client = monero_lws::LwsRpcClient::new(format!("http://{}:38884", dhost), None); (address, viewkey, lws_client, regtest) }