From 99409f5c4059633b7e2fa8b9c2e6c110b0f2f64b Mon Sep 17 00:00:00 2001 From: gngpp Date: Sat, 9 Dec 2023 21:34:13 +0800 Subject: [PATCH] fix(client): divide by zero error if DNS returns 0 addrs (#76) --- src/client/legacy/connect/http.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/legacy/connect/http.rs b/src/client/legacy/connect/http.rs index 77dcafe..b08b6d7 100644 --- a/src/client/legacy/connect/http.rs +++ b/src/client/legacy/connect/http.rs @@ -606,7 +606,9 @@ struct ConnectingTcpRemote { impl ConnectingTcpRemote { fn new(addrs: dns::SocketAddrs, connect_timeout: Option) -> Self { - let connect_timeout = connect_timeout.map(|t| t / (addrs.len() as u32)); + let connect_timeout = connect_timeout + .map(|t| t.checked_div(addrs.len() as u32)) + .flatten(); Self { addrs,