diff --git a/crates/tor-socksproto/src/err.rs b/crates/tor-socksproto/src/err.rs index 5d8d535fd..ee29f4c18 100644 --- a/crates/tor-socksproto/src/err.rs +++ b/crates/tor-socksproto/src/err.rs @@ -41,7 +41,7 @@ pub enum Error { /// Something went wrong with the programming of this module. #[error("Internal programming error while handling SOCKS handshake")] - Internal(InternalError), + Internal(#[from] InternalError), } // Note: at present, tor-socksproto isn't used in any settings where ErrorKind diff --git a/crates/tor-socksproto/src/handshake.rs b/crates/tor-socksproto/src/handshake.rs index 14f51cb28..83ea408f9 100644 --- a/crates/tor-socksproto/src/handshake.rs +++ b/crates/tor-socksproto/src/handshake.rs @@ -113,10 +113,7 @@ impl SocksHandshake { let mut r = Reader::from_slice(input); let version = r.take_u8()?.try_into()?; if version != SocksVersion::V4 { - return Err(Error::Internal(internal!( - "called s4 on wrong type {:?}", - version - ))); + return Err(internal!("called s4 on wrong type {:?}", version).into()); } let cmd: SocksCmd = r.take_u8()?.into(); @@ -157,10 +154,7 @@ impl SocksHandshake { let mut r = Reader::from_slice(input); let version: SocksVersion = r.take_u8()?.try_into()?; if version != SocksVersion::V5 { - return Err(Error::Internal(internal!( - "called on wrong handshake type {:?}", - version - ))); + return Err(internal!("called on wrong handshake type {:?}", version).into()); } /// Constant for Username/Password-style authentication. @@ -220,10 +214,9 @@ impl SocksHandshake { let version: SocksVersion = r.take_u8()?.try_into()?; if version != SocksVersion::V5 { - return Err(Error::Internal(internal!( - "called s5 on non socks5 handshake with type {:?}", - version - ))); + return Err( + internal!("called s5 on non socks5 handshake with type {:?}", version).into(), + ); } let cmd = r.take_u8()?.into(); let _ignore = r.take_u8()?; @@ -233,7 +226,7 @@ impl SocksHandshake { let auth = self .socks5_auth .take() - .ok_or_else(|| Error::Internal(internal!("called s5 without negotiating auth")))?; + .ok_or_else(|| internal!("called s5 without negotiating auth"))?; let request = SocksRequest::new(version, cmd, addr, port, auth)?;