diff --git a/bruty_client/Cargo.toml b/bruty_client/Cargo.toml index dcba091..c014696 100644 --- a/bruty_client/Cargo.toml +++ b/bruty_client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bruty_client" authors = ["skifli"] -version = "0.3.0" +version = "0.3.1" edition = "2021" [dependencies] diff --git a/bruty_client/src/client_threads.rs b/bruty_client/src/client_threads.rs index 6e097bb..95c5680 100644 --- a/bruty_client/src/client_threads.rs +++ b/bruty_client/src/client_threads.rs @@ -8,8 +8,6 @@ struct IDCheckingStats { pub async fn results_handler(client_channels: &bruty_share::types::ClientChannels) { let mut results_map: ahash::AHashMap, IDCheckingStats> = ahash::AHashMap::new(); - let mut completed_checks: u64 = 0; - let start_time = std::time::Instant::now(); loop { let video = client_channels.results_receiver.recv_async().await; @@ -36,18 +34,15 @@ pub async fn results_handler(client_channels: &bruty_share::types::ClientChannel } if stats.total_checked == 4096 { - completed_checks += 1; - let base_id_clone_clone = base_id_clone.clone(); let positives_len = stats.positives.len(); log::info!( - "Tested {} with {} hit{}, client @{}/s", + "Tested {} with {} hit{}", base_id_clone.iter().collect::(), positives_len, if positives_len == 1 { "" } else { "s" }, - completed_checks as f64 * 4069.0 / start_time.elapsed().as_secs_f64(), ); client_channels diff --git a/bruty_client/src/main.rs b/bruty_client/src/main.rs index 8125c2b..b988b86 100644 --- a/bruty_client/src/main.rs +++ b/bruty_client/src/main.rs @@ -75,9 +75,9 @@ struct Args { short = 'a', long = "advanced-generations", help = "Number of IDs to be generated in advance (multiply by 64^2)", - default_value_t = 8 + default_value_t = 256 )] - advanced_generations: u8, + advanced_generations: u16, } /// Handles a WebSocket message. diff --git a/bruty_server/Cargo.toml b/bruty_server/Cargo.toml index c99c78c..d7e2b6c 100644 --- a/bruty_server/Cargo.toml +++ b/bruty_server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bruty_server" authors = ["skifli"] -version = "0.3.0" +version = "0.3.1" edition = "2021" [dependencies] diff --git a/bruty_server/src/main.rs b/bruty_server/src/main.rs index f375e9f..d341a00 100644 --- a/bruty_server/src/main.rs +++ b/bruty_server/src/main.rs @@ -283,7 +283,13 @@ async fn handle_websocket( } log::info!( - "Forwaded awaiting result from {} (ID {}) to the next session.", + "Forwaded {} awaiting result{} from {} (ID {}) to the next session.", + session.awaiting_results.len(), + if session.awaiting_results.len() == 1 { + "" + } else { + "s" + }, session.user.name, session.user.id ); @@ -376,7 +382,7 @@ async fn main( let (results_sender, results_receiver) = flume::unbounded(); // Create a channel for when the server receives results, to send to the result handler. let (results_awaiting_sender, results_awaiting_receiver) = flume::unbounded(); // Create a channel for when the server is awaiting results. let (results_received_sender, results_received_receiver) = flume::unbounded(); // Create a channel for when the server receives results. - let (current_id_sender, current_id_receiver) = flume::bounded(1); // Create a channel for when the current project ID changes. + let (current_id_sender, current_id_receiver) = flume::unbounded(); // Create a channel for when the current project ID changes. let id_sender_clone = id_sender.clone(); let results_awaiting_sender_clone = results_awaiting_sender.clone(); diff --git a/bruty_server/src/payload_handlers.rs b/bruty_server/src/payload_handlers.rs index b9b2957..3d7b3c3 100644 --- a/bruty_server/src/payload_handlers.rs +++ b/bruty_server/src/payload_handlers.rs @@ -1,7 +1,7 @@ use crate::{SplitSinkExt, WebSocketSender}; use futures_util::SinkExt; -const ALLOWED_CLIENT_VERSIONS: &[&str] = &["0.3.0"]; +const ALLOWED_CLIENT_VERSIONS: &[&str] = &["0.3.1"]; /// Checks if the connection is authenticated. /// If not, it sends an InvalidSession OP code and closes the connection. diff --git a/bruty_server/src/server_threads.rs b/bruty_server/src/server_threads.rs index 002f018..d8328e9 100644 --- a/bruty_server/src/server_threads.rs +++ b/bruty_server/src/server_threads.rs @@ -14,7 +14,7 @@ pub fn permutation_generator( current_id_sender: &flume::Sender>, ) { if starting_id.len() == 9 { - while id_sender.len() > 0 { + while id_sender.len() > 256 { // Wait for IDs } @@ -79,6 +79,7 @@ pub async fn results_progress_handler( let mut awaiting_current_id_update = Vec::new(); let mut cant_update_awaiting_results = Vec::new(); + let mut start_times = Vec::new(); loop { let current_id_receiver_try = current_id_receiver.try_recv(); @@ -87,6 +88,7 @@ pub async fn results_progress_handler( log::info!("Finished generating {}", id.iter().collect::()); awaiting_current_id_update.push(id.clone()); + start_times.push(std::time::Instant::now()); cant_update_awaiting_results.clear(); } @@ -136,8 +138,9 @@ pub async fn results_progress_handler( persist.save("server_state", state.clone()).unwrap(); // Save the current ID to the database log::info!( - "Finished checking {}", - state.current_id.iter().collect::() + "Finished checking {} @{}/s", + state.current_id.iter().collect::(), + 262144 / start_times.remove(0).elapsed().as_secs() ); } else { if cant_update_awaiting_results != awaiting_current_id_update { diff --git a/bruty_share/src/lib.rs b/bruty_share/src/lib.rs index 5580c39..4549918 100644 --- a/bruty_share/src/lib.rs +++ b/bruty_share/src/lib.rs @@ -45,8 +45,7 @@ impl ErrorCode { ErrorCode::DecodeError => InvalidSessionData { code: ErrorCode::DecodeError, description: "Decode error".to_string(), - explanation: "The server - received an invalid payload." + explanation: "The server received an invalid payload." .to_string(), }, ErrorCode::AuthenticationFailed => InvalidSessionData { @@ -103,7 +102,7 @@ pub enum OperationCode { /// Data sent with an Identify OP code #[derive(serde::Serialize, serde::Deserialize, Debug)] pub struct IdentifyData { - pub advanced_generations: u8, + pub advanced_generations: u16, pub client_version: String, pub id: u8, pub secret: String,