bhcli

A TUI for chatting on LE PHP Chats (onion)
git clone https://git.dasho.dev/n0tr1v/bhcli.git
Log | Files | Refs | README

commit 641c7ebec87a5db0749afce0f6203c58dca4326a
parent 75aed7050d6030b4498bc42671e4e116b13f9f56
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 29 Mar 2023 17:27:35 -0700

--no-proxy

Diffstat:
Msrc/main.rs | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -171,6 +171,8 @@ struct Opts { default_value = "socks5h://127.0.0.1:9050" )] socks_proxy_url: String, + #[arg(long)] + no_proxy: bool, #[arg(long, env = "DNMX_USERNAME")] dnmx_username: Option<String>, #[arg(long, env = "DNMX_PASSWORD")] @@ -1815,15 +1817,16 @@ fn get_guest_color(wanted: Option<String>) -> String { .to_owned() } -fn get_tor_client(socks_proxy_url: &str) -> Client { +fn get_tor_client(socks_proxy_url: &str, no_proxy: bool) -> Client { let ua = "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0"; - let proxy = reqwest::Proxy::all(socks_proxy_url).unwrap(); - reqwest::blocking::ClientBuilder::new() + let mut builder = reqwest::blocking::ClientBuilder::new() .cookie_store(true) - .user_agent(ua) - .proxy(proxy) - .build() - .unwrap() + .user_agent(ua); + if !no_proxy { + let proxy = reqwest::Proxy::all(socks_proxy_url).unwrap(); + builder = builder.proxy(proxy); + } + builder.build().unwrap() } fn ask_username(username: Option<String>) -> String { @@ -1948,7 +1951,7 @@ fn main() -> Result<()> { } } - let client = get_tor_client(&opts.socks_proxy_url); + let client = get_tor_client(&opts.socks_proxy_url, opts.no_proxy); // If dnmx username is set, start mail notifier thread if let Some(dnmx_username) = opts.dnmx_username {