From 5f05a74856d626c25a6cd767c44d56260c9c718b Mon Sep 17 00:00:00 2001 From: Feliciss <10203-feliciss@users.noreply.0xacab.org> Date: Mon, 19 Aug 2024 04:47:06 +0900 Subject: [PATCH] [gh-2385] add https_proxy and all_proxy to env file. --- crates/rooch/build.rs | 8 ++++++++ crates/rooch/src/commands/rpc/commands/request.rs | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/rooch/build.rs b/crates/rooch/build.rs index 47a550518e..a5a0bfc945 100644 --- a/crates/rooch/build.rs +++ b/crates/rooch/build.rs @@ -1,6 +1,8 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 +use std::env; + use anyhow::Result; use vergen_git2::{BuildBuilder, CargoBuilder, Emitter, Git2Builder, RustcBuilder}; @@ -11,5 +13,11 @@ fn main() -> Result<()> { .add_instructions(&Git2Builder::all_git()?)? .add_instructions(&RustcBuilder::all_rustc()?)? .emit()?; + read_proxy_from_env(); Ok(()) } + +fn read_proxy_from_env() { + println!("cargo:rerun-if-env-changed=https_proxy"); + println!("cargo:rerun-if-env-changed=all_proxy"); +} diff --git a/crates/rooch/src/commands/rpc/commands/request.rs b/crates/rooch/src/commands/rpc/commands/request.rs index 0ae7c0d1aa..1ef0d22bfd 100644 --- a/crates/rooch/src/commands/rpc/commands/request.rs +++ b/crates/rooch/src/commands/rpc/commands/request.rs @@ -5,6 +5,7 @@ use crate::cli_types::{CommandAction, WalletContextOptions}; use async_trait::async_trait; use clap::Parser; use rooch_types::error::RoochResult; +use std::env; use rooch_rpc_api::jsonrpc_types::{ HumanReadableDisplay, IndexerObjectStatePageView, ObjectStateView, @@ -27,7 +28,6 @@ pub struct RequestCommand { #[clap(flatten)] pub(crate) context_options: WalletContextOptions, - /// Return command outputs in json format #[clap(long, default_value = "false")] json: bool, @@ -36,6 +36,11 @@ pub struct RequestCommand { #[async_trait] impl CommandAction for RequestCommand { async fn execute(self) -> RoochResult { + let https_proxy = env::var("https_proxy").ok(); + let all_proxy = env::var("all_proxy").ok(); + // TODO: proxy url + let proxy_url = https_proxy.or(all_proxy); + let client = self.context_options.build()?.get_client().await?; let params = match self.params { Some(serde_json::Value::Array(array)) => array,