Skip to content

Commit

Permalink
feat: add client mismatch exit
Browse files Browse the repository at this point in the history
  • Loading branch information
skifli authored Sep 30, 2024
1 parent 773a749 commit 7b21224
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bruty_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bruty_client"
authors = ["skifli"]
version = "0.2.2"
version = "0.2.3"
edition = "2021"

[dependencies]
Expand Down
6 changes: 6 additions & 0 deletions bruty_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ async fn handle_msg(
error_code.explanation
);

if error_code.code == bruty_share::ErrorCode::UnsupportedClientVersion {
log::error!("Unsupported client version, please update");

std::process::exit(1);
}

return false;
}
bruty_share::OperationCode::TestRequestData => {
Expand Down
2 changes: 1 addition & 1 deletion bruty_server/src/payload_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{SplitSinkExt, WebSocketSender};
use futures_util::SinkExt;

const ALLOWED_CLIENT_VERSIONS: &[&str] = &["0.2.2"];
const ALLOWED_CLIENT_VERSIONS: &[&str] = &["0.2.3"];

/// Checks if the connection is authenticated.
/// If not, it sends an InvalidSession OP code and closes the connection.
Expand Down
4 changes: 2 additions & 2 deletions bruty_share/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub const VALID_CHARS: &[char] = &[
];

/// Error codes sent with an InvalidSession OP code
#[derive(serde::Serialize, serde::Deserialize, Debug)]
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug)]
pub enum ErrorCode {
UnknownError,
UnexpectedOP,
Expand Down Expand Up @@ -122,7 +122,7 @@ pub struct TestingResultData {
/// Data sent with an InvalidSession OP code
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct InvalidSessionData {
code: ErrorCode,
pub code: ErrorCode,
pub description: String,
pub explanation: String,
}
Expand Down

0 comments on commit 7b21224

Please sign in to comment.