From 2a780ba0deac7bfd4bb27d5f4709312b5fa47bc6 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:30:08 +0800 Subject: [PATCH] minor changes --- src/lib.rs | 2 +- src/protocol/address.rs | 3 ++- src/protocol/handshake/auth_method.rs | 3 ++- src/protocol/handshake/password_method/response.rs | 3 ++- src/protocol/mod.rs | 3 ++- src/protocol/reply.rs | 3 ++- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 66f8dc5..d033b53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ #[cfg(feature = "tokio")] pub mod client; -pub mod error; +pub(crate) mod error; pub mod protocol; #[cfg(feature = "tokio")] pub mod server; diff --git a/src/protocol/address.rs b/src/protocol/address.rs index 52fa680..33cefb4 100644 --- a/src/protocol/address.rs +++ b/src/protocol/address.rs @@ -11,9 +11,10 @@ use std::{ #[cfg(feature = "tokio")] use tokio::io::{AsyncRead, AsyncReadExt}; -#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Default)] #[repr(u8)] pub enum AddressType { + #[default] IPv4 = 0x01, Domain = 0x03, IPv6 = 0x04, diff --git a/src/protocol/handshake/auth_method.rs b/src/protocol/handshake/auth_method.rs index f8eb7d0..a830d69 100644 --- a/src/protocol/handshake/auth_method.rs +++ b/src/protocol/handshake/auth_method.rs @@ -1,8 +1,9 @@ /// A proxy authentication method. #[repr(u8)] -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Default)] pub enum AuthMethod { /// No authentication required. + #[default] NoAuth = 0x00, /// GSS API. GssApi = 0x01, diff --git a/src/protocol/handshake/password_method/response.rs b/src/protocol/handshake/password_method/response.rs index d9aada4..2c2d5f5 100644 --- a/src/protocol/handshake/password_method/response.rs +++ b/src/protocol/handshake/password_method/response.rs @@ -7,8 +7,9 @@ use async_trait::async_trait; use tokio::io::{AsyncRead, AsyncReadExt}; #[repr(u8)] -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Default)] pub enum Status { + #[default] Succeeded = 0x00, Failed = 0xff, } diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index c3220cd..c927783 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -26,9 +26,10 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; /// SOCKS protocol version, either 4 or 5 #[repr(u8)] -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)] pub enum Version { V4 = 4, + #[default] V5 = 5, } diff --git a/src/protocol/reply.rs b/src/protocol/reply.rs index d179296..a2255fb 100644 --- a/src/protocol/reply.rs +++ b/src/protocol/reply.rs @@ -1,6 +1,7 @@ #[repr(u8)] -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Default)] pub enum Reply { + #[default] Succeeded = 0x00, GeneralFailure = 0x01, ConnectionNotAllowed = 0x02,