This commit is contained in:
parent
95d726987f
commit
befd6c862b
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -678,7 +678,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "portnut"
|
name = "portnut"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "portnut"
|
name = "portnut"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
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
|
||||||
|
@ -5,7 +5,6 @@ Portnut is a port stressing / scanning multithreaded utility. It can handle raw
|
|||||||
# TODO
|
# TODO
|
||||||
* Make a distributed version that allows stressing from multiple computers at the same time
|
* Make a distributed version that allows stressing from multiple computers at the same time
|
||||||
* Return more stats (low 1%, high 1%)
|
* Return more stats (low 1%, high 1%)
|
||||||
* Http : Read more about "blocking" reqwest, add a timeout
|
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
Go to the releases page and download the latest version.
|
Go to the releases page and download the latest version.
|
||||||
|
@ -5,7 +5,7 @@ use std::sync::mpsc;
|
|||||||
|
|
||||||
use crate::results::*;
|
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 mut handles = vec![];
|
||||||
let (tx, rx) = mpsc::channel();
|
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 end_time = Instant::now() + interval;
|
||||||
let wait = sleep.clone();
|
let wait = sleep.clone();
|
||||||
let tx2 = tx.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; }
|
if Instant::now() >= end_time { break; }
|
||||||
|
|
||||||
let b4 = Instant::now();
|
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;
|
let time = Instant::now() - b4;
|
||||||
match resp {
|
match resp {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
"httpstress" => {
|
"httpstress" => {
|
||||||
println!("===== HTTP STRESS TEST =====");
|
println!("===== HTTP STRESS TEST =====");
|
||||||
http_stress(address, duration, sleep, threads)?;
|
http_stress(address, duration, sleep, threads, timeout)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -98,10 +98,12 @@ struct Args {
|
|||||||
///Mode of use : either tcpstress, tcpscan or httpstress
|
///Mode of use : either tcpstress, tcpscan or httpstress
|
||||||
mode: String,
|
mode: String,
|
||||||
///IP address or hostname to scan - or url if using http
|
///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)]
|
#[arg(short, long)]
|
||||||
address: String,
|
address: String,
|
||||||
///Timeout for each connection in seconds
|
///Timeout for each connection in seconds, default 30
|
||||||
#[arg(short, long, default_value_t = 1)]
|
#[arg(short, long, default_value_t = 30)]
|
||||||
timeout: u64,
|
timeout: u64,
|
||||||
///Number of milliseconds to wait in between scans or requests
|
///Number of milliseconds to wait in between scans or requests
|
||||||
#[arg(short, long, default_value_t = 30)]
|
#[arg(short, long, default_value_t = 30)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user