diff --git a/network/src/network.rs b/network/src/network.rs index 5b0d33a2c5..142523345c 100644 --- a/network/src/network.rs +++ b/network/src/network.rs @@ -123,9 +123,8 @@ impl NetworkState { config.peer_store_path(), )); info!("Loaded the peer store."); - if config.proxy_config.enable { - proxy::check_proxy_url(&config.proxy_config.proxy_url) - .map_err(|reason| Error::Config(reason))?; + if let Some(ref proxy_url) = config.proxy_config.proxy_url { + proxy::check_proxy_url(proxy_url).map_err(|reason| Error::Config(reason))?; } let bootnodes = config.bootnodes(); @@ -998,14 +997,13 @@ impl NetworkService { if init.is_ready() { break; } - let proxy_config_enable = config.proxy_config.enable; - - if proxy_config_enable { - let proxy_config = ProxyConfig { - proxy_url: config.proxy_config.proxy_url.clone(), - }; - service_builder = service_builder.tcp_proxy_config(Some(proxy_config)); - } + let proxy_config_enable = config.proxy_config.proxy_url.is_some(); + service_builder = service_builder.tcp_proxy_config( + config + .proxy_config + .proxy_url + .map(|proxy_url| ProxyConfig { proxy_url }), + ); match find_type(multi_addr) { TransportType::Tcp => { diff --git a/util/app-config/src/configs/network.rs b/util/app-config/src/configs/network.rs index 3df0459117..f1965c1f9d 100644 --- a/util/app-config/src/configs/network.rs +++ b/util/app-config/src/configs/network.rs @@ -103,9 +103,8 @@ pub struct Config { /// Proxy related config options #[derive(Clone, Debug, Serialize, Deserialize, Default)] pub struct ProxyConfig { - pub enable: bool, // like: socks5://username:password@127.0.0.1:1080 - pub proxy_url: String, + pub proxy_url: Option, } /// Chain synchronization config options.