Prevent unnecessary clone

This also ensures that the address resolver actually keeps state.
Otherwise it was cloned before each resolution, resulting in it never
keeping the resolved addresses.

Signed-off-by: Jacob Kiers <code@kiers.eu>
This commit is contained in:
Jacob Kiers 2023-08-25 22:52:46 +02:00
parent cd35859c9b
commit 6349fc6502

View File

@ -72,21 +72,17 @@ async fn accept(inbound: TcpStream, proxy: Arc<Proxy>) -> Result<(), Box<dyn std
"No upstream named {:?} on server {:?}", "No upstream named {:?} on server {:?}",
proxy.default_action, proxy.name proxy.default_action, proxy.name
); );
return process( return process(inbound, proxy.upstream.get(&proxy.default_action).unwrap()).await;
inbound,
proxy.upstream.get(&proxy.default_action).unwrap().clone(),
)
.await;
// ToDo: Remove unwrap and check default option // ToDo: Remove unwrap and check default option
} }
}; };
return process(inbound, upstream.clone()).await; return process(inbound, &upstream).await;
} }
async fn process( async fn process(
mut inbound: TcpStream, mut inbound: TcpStream,
upstream: Upstream, upstream: &Upstream,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
match upstream { match upstream {
Upstream::Ban => { Upstream::Ban => {