فهرست منبع

rpc/jsonrpc: minor change

ghassmo 4 سال پیش
والد
کامیت
573b858e67
1فایلهای تغییر یافته به همراه5 افزوده شده و 7 حذف شده
  1. 5 7
      src/rpc/jsonrpc.rs

+ 5 - 7
src/rpc/jsonrpc.rs

@@ -180,8 +180,6 @@ pub async fn send_request(uri: &Url, data: Value, socks_url: Option<Url>) -> Res
         "tor" | "nym" => {
         "tor" | "nym" => {
             use fast_socks5::client::{Config, Socks5Stream};
             use fast_socks5::client::{Config, Socks5Stream};
 
 
-            let mut stream;
-
             if socks_url.is_none() {
             if socks_url.is_none() {
                 return Err(Error::NoSocks5UrlFound)
                 return Err(Error::NoSocks5UrlFound)
             }
             }
@@ -199,8 +197,8 @@ pub async fn send_request(uri: &Url, data: Value, socks_url: Option<Url>) -> Res
                 .next()
                 .next()
                 .ok_or(Error::NoSocks5UrlFound)?;
                 .ok_or(Error::NoSocks5UrlFound)?;
 
 
-            if !socks_url.username().is_empty() && socks_url.password().is_some() {
-                stream = Socks5Stream::connect_with_password(
+            let mut stream = if !socks_url.username().is_empty() && socks_url.password().is_some() {
+                Socks5Stream::connect_with_password(
                     socks_url_str,
                     socks_url_str,
                     host,
                     host,
                     port,
                     port,
@@ -208,10 +206,10 @@ pub async fn send_request(uri: &Url, data: Value, socks_url: Option<Url>) -> Res
                     socks_url.password().unwrap().to_string(),
                     socks_url.password().unwrap().to_string(),
                     config,
                     config,
                 )
                 )
-                .await?;
+                .await?
             } else {
             } else {
-                stream = Socks5Stream::connect(socks_url_str, host, port, config).await?;
-            }
+                Socks5Stream::connect(socks_url_str, host, port, config).await?
+            };
 
 
             get_reply(&mut stream, data_str).await
             get_reply(&mut stream, data_str).await
         }
         }