Merge branch 'error-socksproto-autoconvert' into 'main'
Provide, and use From impl for InternalError See merge request tpo/core/arti!315
This commit is contained in:
commit
e80d472beb
|
@ -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
|
||||
|
|
|
@ -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)?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue