From e31cf4773bf7e3f269ebff49726f8979592a1f15 Mon Sep 17 00:00:00 2001 From: valued mammal Date: Sat, 25 Oct 2025 15:03:54 -0400 Subject: [PATCH 1/2] feat!: Change ConfigBuilder::timeout to accept Option --- src/client.rs | 4 +++- src/config.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index 1ed336b..7e4e626 100644 --- a/src/client.rs +++ b/src/client.rs @@ -448,7 +448,9 @@ mod tests { let now = Instant::now(); let client = Client::from_config( &endpoint, - crate::config::ConfigBuilder::new().timeout(Some(5)).build(), + crate::config::ConfigBuilder::new() + .timeout(Some(Duration::from_secs(5))) + .build(), ); let elapsed = now.elapsed(); diff --git a/src/config.rs b/src/config.rs index 47da1f9..e4c5770 100644 --- a/src/config.rs +++ b/src/config.rs @@ -55,8 +55,8 @@ impl ConfigBuilder { } /// Sets the timeout - pub fn timeout(mut self, timeout: Option) -> Self { - self.config.timeout = timeout.map(|t| Duration::from_secs(t as u64)); + pub fn timeout(mut self, timeout: Option) -> Self { + self.config.timeout = timeout; self } From 5dc4bb6360f1ff3f4b848a9b755c0c30a2e7e01b Mon Sep 17 00:00:00 2001 From: valued mammal Date: Sat, 25 Oct 2025 15:31:01 -0400 Subject: [PATCH 2/2] ci: bump clippy to 1.90.0 - Fixed hidden lifetime in `Batch::iter` - Use `io::Error::other` in place of `io::Error::new` when the error kind is `ErrorKind::Other`. --- .github/workflows/cont_integration.yml | 9 ++--- src/batch.rs | 2 +- src/socks/v4.rs | 7 +--- src/socks/v5.rs | 50 +++++++------------------- 4 files changed, 17 insertions(+), 51 deletions(-) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 01a95f3..38a1af9 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -62,13 +62,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@v1 with: - toolchain: 1.84.0 + toolchain: 1.90.0 components: clippy - name: Rust Cache uses: Swatinem/rust-cache@v2.2.1 - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features --all-targets -- -D warnings + - run: cargo clippy --all-features --all-targets -- -D warnings diff --git a/src/batch.rs b/src/batch.rs index b13d72f..75932a5 100644 --- a/src/batch.rs +++ b/src/batch.rs @@ -88,7 +88,7 @@ impl Batch { } /// Returns an iterator on the batch - pub fn iter(&self) -> BatchIter { + pub fn iter(&self) -> BatchIter<'_> { BatchIter { batch: self, index: 0, diff --git a/src/socks/v4.rs b/src/socks/v4.rs index 9d0fc3f..b4e999d 100644 --- a/src/socks/v4.rs +++ b/src/socks/v4.rs @@ -18,12 +18,7 @@ fn read_response(socket: &mut TcpStream) -> io::Result { match response.read_u8()? { 90 => {} - 91 => { - return Err(io::Error::new( - io::ErrorKind::Other, - "request rejected or failed", - )) - } + 91 => return Err(io::Error::other("request rejected or failed")), 92 => { return Err(io::Error::new( io::ErrorKind::PermissionDenied, diff --git a/src/socks/v5.rs b/src/socks/v5.rs index 7a602d2..6b06e8f 100644 --- a/src/socks/v5.rs +++ b/src/socks/v5.rs @@ -37,10 +37,7 @@ fn read_addr(socket: &mut R) -> io::Result { ip, port, 0, 0, )))) } - _ => Err(io::Error::new( - io::ErrorKind::Other, - "unsupported address type", - )), + _ => Err(io::Error::other("unsupported address type")), } } @@ -54,35 +51,15 @@ fn read_response(socket: &mut TcpStream) -> io::Result { match socket.read_u8()? { 0 => {} - 1 => { - return Err(io::Error::new( - io::ErrorKind::Other, - "general SOCKS server failure", - )) - } - 2 => { - return Err(io::Error::new( - io::ErrorKind::Other, - "connection not allowed by ruleset", - )) - } - 3 => return Err(io::Error::new(io::ErrorKind::Other, "network unreachable")), - 4 => return Err(io::Error::new(io::ErrorKind::Other, "host unreachable")), - 5 => return Err(io::Error::new(io::ErrorKind::Other, "connection refused")), - 6 => return Err(io::Error::new(io::ErrorKind::Other, "TTL expired")), - 7 => { - return Err(io::Error::new( - io::ErrorKind::Other, - "command not supported", - )) - } - 8 => { - return Err(io::Error::new( - io::ErrorKind::Other, - "address kind not supported", - )) - } - _ => return Err(io::Error::new(io::ErrorKind::Other, "unknown error")), + 1 => return Err(io::Error::other("general SOCKS server failure")), + 2 => return Err(io::Error::other("connection not allowed by ruleset")), + 3 => return Err(io::Error::other("network unreachable")), + 4 => return Err(io::Error::other("host unreachable")), + 5 => return Err(io::Error::other("connection refused")), + 6 => return Err(io::Error::other("TTL expired")), + 7 => return Err(io::Error::other("command not supported")), + 8 => return Err(io::Error::other("address kind not supported")), + _ => return Err(io::Error::other("unknown error")), } if socket.read_u8()? != 0 { @@ -227,14 +204,11 @@ impl Socks5Stream { } if selected_method == 0xff { - return Err(io::Error::new( - io::ErrorKind::Other, - "no acceptable auth methods", - )); + return Err(io::Error::other("no acceptable auth methods")); } if selected_method != auth.id() && selected_method != Authentication::None.id() { - return Err(io::Error::new(io::ErrorKind::Other, "unknown auth method")); + return Err(io::Error::other("unknown auth method")); } match *auth {