From 23296c64366de438024ff9c955297dc1647af328 Mon Sep 17 00:00:00 2001 From: Jacob Kiers Date: Wed, 4 Oct 2023 22:33:11 +0200 Subject: [PATCH] Improve code style Signed-off-by: Jacob Kiers --- src/config.rs | 7 ++----- src/servers/protocol/tcp.rs | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/config.rs b/src/config.rs index d6d9538..cd6a69f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -150,17 +150,14 @@ fn load_config(path: &str) -> Result { } } + let addr = UpstreamAddress::new(format!("{}:{}", upstream_host, upstream_port)); parsed_upstream.insert( name.to_string(), Upstream::Proxy(ProxyToUpstream { name: name.to_string(), addr: format!("{}:{}", upstream_host, upstream_port), protocol: upstream_url.scheme().to_string(), - addresses: Addr(Mutex::new(UpstreamAddress::new(format!( - "{}:{}", - upstream_host, upstream_port - )))), - ..Default::default() + addresses: Addr(Mutex::new(addr)), }), ); } diff --git a/src/servers/protocol/tcp.rs b/src/servers/protocol/tcp.rs index f20929a..43e2987 100644 --- a/src/servers/protocol/tcp.rs +++ b/src/servers/protocol/tcp.rs @@ -77,7 +77,7 @@ async fn accept(inbound: TcpStream, proxy: Arc) -> Result<(), Box Result<(), Box> { match upstream { Upstream::Ban => { - let _ = inbound.shutdown(); + inbound.shutdown().await?; } Upstream::Echo => { let (mut ri, mut wi) = io::split(inbound);