This commit is contained in:
@ -5,7 +5,7 @@ use std::sync::mpsc;
|
||||
|
||||
use crate::results::*;
|
||||
|
||||
pub fn http_stress(url: String, interval: Duration, sleep: Duration, threads: u32) -> std::io::Result<()> {
|
||||
pub fn http_stress(url: String, interval: Duration, sleep: Duration, threads: u32, timeout: Duration) -> std::io::Result<()> {
|
||||
|
||||
let mut handles = vec![];
|
||||
let (tx, rx) = mpsc::channel();
|
||||
@ -17,6 +17,7 @@ pub fn http_stress(url: String, interval: Duration, sleep: Duration, threads: u3
|
||||
let end_time = Instant::now() + interval;
|
||||
let wait = sleep.clone();
|
||||
let tx2 = tx.clone();
|
||||
let delay = timeout.clone();
|
||||
|
||||
|
||||
|
||||
@ -25,7 +26,8 @@ pub fn http_stress(url: String, interval: Duration, sleep: Duration, threads: u3
|
||||
if Instant::now() >= end_time { break; }
|
||||
|
||||
let b4 = Instant::now();
|
||||
let resp = reqwest::blocking::get(add.clone());
|
||||
let client = reqwest::blocking::Client::new();
|
||||
let resp = client.get(add.clone()).timeout(delay).send();
|
||||
let time = Instant::now() - b4;
|
||||
match resp {
|
||||
Ok(_) => {
|
||||
|
@ -48,7 +48,7 @@ fn main() -> std::io::Result<()> {
|
||||
}
|
||||
"httpstress" => {
|
||||
println!("===== HTTP STRESS TEST =====");
|
||||
http_stress(address, duration, sleep, threads)?;
|
||||
http_stress(address, duration, sleep, threads, timeout)?;
|
||||
return Ok(());
|
||||
}
|
||||
_ => {
|
||||
@ -98,10 +98,12 @@ struct Args {
|
||||
///Mode of use : either tcpstress, tcpscan or httpstress
|
||||
mode: String,
|
||||
///IP address or hostname to scan - or url if using http
|
||||
///ex of address : 127.0.0.1
|
||||
///ex of url : http://example.org
|
||||
#[arg(short, long)]
|
||||
address: String,
|
||||
///Timeout for each connection in seconds
|
||||
#[arg(short, long, default_value_t = 1)]
|
||||
///Timeout for each connection in seconds, default 30
|
||||
#[arg(short, long, default_value_t = 30)]
|
||||
timeout: u64,
|
||||
///Number of milliseconds to wait in between scans or requests
|
||||
#[arg(short, long, default_value_t = 30)]
|
||||
|
Reference in New Issue
Block a user