Skip to content

Commit

Permalink
SQUASH clippy enum_variant_names fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjulien committed Dec 19, 2024
1 parent 11756a3 commit 74af65d
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions rust/src/socks/socks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ impl Transaction for SocksTransaction {

#[derive(PartialEq, Eq, Debug)]
enum SocksConnectionState {
SocksStateNew = 0,
SocksStateAuthMethodSent = 1,
SocksStateAuthMethodResponded = 2,
SocksStateAuthDataSent = 3,
SocksStateAuthDataResponded = 4,
SocksStateConnectSent = 5,
SocksStateConnectResponded = 6,
New = 0,
AuthMethodSent = 1,
AuthMethodResponded = 2,
AuthDataSent = 3,
AuthDataResponded = 4,
ConnectSent = 5,
ConnectResponded = 6,
}
impl Default for SocksConnectionState {
fn default() -> Self {
SocksConnectionState::SocksStateNew
SocksConnectionState::New
}
}
impl fmt::Display for SocksConnectionState {
Expand Down Expand Up @@ -173,7 +173,7 @@ impl SocksState {
&mut self, tinput: &'a [u8], rinput: &'a [u8],
) -> (AppLayerResult, &'a [u8]) {
match self.state {
SocksConnectionState::SocksStateNew => {
SocksConnectionState::New => {
let r = parser::parse_connect_request(rinput);
match r {
Ok((rem, request)) => {
Expand All @@ -189,7 +189,7 @@ impl SocksState {
if self.transactions.len() >= unsafe { SOCKS_MAX_TX } {
return (AppLayerResult::err(), &[]);
}
self.state = SocksConnectionState::SocksStateAuthMethodSent;
self.state = SocksConnectionState::AuthMethodSent;
SCLogDebug!("> state now {}", self.state);
return (AppLayerResult::ok(), rem);
}
Expand All @@ -209,8 +209,8 @@ impl SocksState {
}
}
}
SocksConnectionState::SocksStateAuthMethodSent => {}
SocksConnectionState::SocksStateAuthMethodResponded => {
SocksConnectionState::AuthMethodSent => {}
SocksConnectionState::AuthMethodResponded => {
let r = parser::parse_auth_request(rinput);
match r {
Ok((rem, request)) => {
Expand All @@ -228,7 +228,7 @@ impl SocksState {
if self.transactions.len() >= unsafe { SOCKS_MAX_TX } {
return (AppLayerResult::err(), &[]);
}
self.state = SocksConnectionState::SocksStateAuthDataSent;
self.state = SocksConnectionState::AuthDataSent;
SCLogDebug!("> state now {}", self.state);
return (AppLayerResult::ok(), rem);
}
Expand All @@ -248,8 +248,8 @@ impl SocksState {
}
}
}
SocksConnectionState::SocksStateAuthDataSent => {}
SocksConnectionState::SocksStateAuthDataResponded => {
SocksConnectionState::AuthDataSent => {}
SocksConnectionState::AuthDataResponded => {
SCLogDebug!("connect request!");
let r = parser::parse_connect_command_request(rinput);
match r {
Expand All @@ -268,7 +268,7 @@ impl SocksState {
if self.transactions.len() >= unsafe { SOCKS_MAX_TX } {
return (AppLayerResult::err(), &[]);
}
self.state = SocksConnectionState::SocksStateConnectSent;
self.state = SocksConnectionState::ConnectSent;
SCLogDebug!("> state now {}", self.state);
return (AppLayerResult::ok(), rem);
}
Expand All @@ -288,8 +288,8 @@ impl SocksState {
}
}
}
SocksConnectionState::SocksStateConnectSent => {}
SocksConnectionState::SocksStateConnectResponded => {}
SocksConnectionState::ConnectSent => {}
SocksConnectionState::ConnectResponded => {}
}
return (AppLayerResult::err(), &[]);
}
Expand All @@ -299,8 +299,8 @@ impl SocksState {
) -> (AppLayerResult, &'a [u8]) {
SCLogDebug!("< state {}", self.state);
match self.state {
SocksConnectionState::SocksStateNew => {}
SocksConnectionState::SocksStateAuthMethodSent => {
SocksConnectionState::New => {}
SocksConnectionState::AuthMethodSent => {
let r = parser::parse_connect_response(rinput);
match r {
Ok((rem, response)) => {
Expand All @@ -317,9 +317,9 @@ impl SocksState {
}

if response == 0 {
self.state = SocksConnectionState::SocksStateAuthDataResponded;
self.state = SocksConnectionState::AuthDataResponded;
} else {
self.state = SocksConnectionState::SocksStateAuthMethodResponded;
self.state = SocksConnectionState::AuthMethodResponded;
}

SCLogDebug!("< state now {}", self.state);
Expand All @@ -343,8 +343,8 @@ impl SocksState {
}
}
}
SocksConnectionState::SocksStateAuthMethodResponded => {}
SocksConnectionState::SocksStateAuthDataSent => {
SocksConnectionState::AuthMethodResponded => {}
SocksConnectionState::AuthDataSent => {
SCLogDebug!("auth response!");
let r = parser::parse_auth_response(rinput);
match r {
Expand All @@ -359,7 +359,7 @@ impl SocksState {
} else {
SCLogDebug!("< no tx found");
}
self.state = SocksConnectionState::SocksStateAuthDataResponded;
self.state = SocksConnectionState::AuthDataResponded;

SCLogDebug!("< state now {}", self.state);
return (AppLayerResult::ok(), rem);
Expand All @@ -380,8 +380,8 @@ impl SocksState {
}
}
}
SocksConnectionState::SocksStateAuthDataResponded => {}
SocksConnectionState::SocksStateConnectSent => {
SocksConnectionState::AuthDataResponded => {}
SocksConnectionState::ConnectSent => {
SCLogDebug!("connect response!");
let r = parser::parse_connect_command_response(rinput);
match r {
Expand All @@ -396,7 +396,7 @@ impl SocksState {
} else {
SCLogDebug!("< no tx found");
}
self.state = SocksConnectionState::SocksStateConnectResponded;
self.state = SocksConnectionState::ConnectResponded;

SCLogDebug!("< state now {}", self.state);
return (AppLayerResult::ok(), rem);
Expand All @@ -417,7 +417,7 @@ impl SocksState {
}
}
}
SocksConnectionState::SocksStateConnectResponded => {}
SocksConnectionState::ConnectResponded => {}
}
return (AppLayerResult::err(), &[]);
}
Expand Down Expand Up @@ -483,13 +483,13 @@ impl SocksState {
SCLogDebug!("issue {:?}", r);
return r;
}
if self.state == SocksConnectionState::SocksStateConnectResponded {
if self.state == SocksConnectionState::ConnectResponded {
// TODO how does it work if we got more data in `input` here?
break;
}
record = remaining;
}
if self.state == SocksConnectionState::SocksStateConnectResponded {
if self.state == SocksConnectionState::ConnectResponded {
SCLogDebug!("requesting upgrade");
unsafe {
// TODO TLS is wrong, it can by any protocol.
Expand Down

0 comments on commit 74af65d

Please sign in to comment.