mirror of
https://github.com/edu4rdshl/fhc.git
synced 2026-07-17 23:24:50 +00:00
Add --max-redirects option.
Signed-off-by: Eduard Tolosa <edu4rdshl@protonmail.com>
This commit is contained in:
parent
df80de9263
commit
98233a98b8
1 changed files with 15 additions and 8 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use fhc::httplib;
|
use fhc::{httplib, structs::LibOptions};
|
||||||
|
|
||||||
use {
|
use {
|
||||||
clap::{value_t, App, Arg},
|
clap::{value_t, App, Arg},
|
||||||
|
|
@ -51,6 +51,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
.long("retries")
|
.long("retries")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Max number of http probes per target."),
|
.help("Max number of http probes per target."),
|
||||||
|
).arg(
|
||||||
|
Arg::with_name("max-redirects")
|
||||||
|
.short("L")
|
||||||
|
.long("max-redirects")
|
||||||
|
.takes_value(true)
|
||||||
|
.help("Max number of redirects. Default: 0"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("1xx")
|
Arg::with_name("1xx")
|
||||||
|
|
@ -106,10 +112,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let threads = value_t!(matches.value_of("threads"), usize).unwrap_or_else(|_| 50);
|
let threads = value_t!(matches.value_of("threads"), usize).unwrap_or_else(|_| 50);
|
||||||
let retries = value_t!(matches.value_of("retries"), usize).unwrap_or_else(|_| 1);
|
let retries = value_t!(matches.value_of("retries"), usize).unwrap_or_else(|_| 1);
|
||||||
let timeout = value_t!(matches.value_of("timeout"), u64).unwrap_or_else(|_| 3);
|
let timeout = value_t!(matches.value_of("timeout"), u64).unwrap_or_else(|_| 3);
|
||||||
|
let max_redirects = value_t!(matches.value_of("max-redirects"), usize).unwrap_or_else(|_| 0);
|
||||||
let user_agents_list = utils::user_agents();
|
let user_agents_list = utils::user_agents();
|
||||||
let show_status_codes = matches.is_present("show-codes");
|
let show_status_codes = matches.is_present("show-codes");
|
||||||
|
|
||||||
let client = httplib::return_http_client(timeout, 3);
|
let client = httplib::return_http_client(timeout, max_redirects);
|
||||||
|
|
||||||
// Read stdin
|
// Read stdin
|
||||||
|
|
||||||
|
|
@ -127,18 +134,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
buffer.lines().map(str::to_owned).collect()
|
buffer.lines().map(str::to_owned).collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
httplib::return_http_data(
|
let lib_options = LibOptions {
|
||||||
hosts,
|
hosts,
|
||||||
client,
|
client,
|
||||||
user_agents_list,
|
user_agents: user_agents_list,
|
||||||
retries,
|
retries,
|
||||||
threads,
|
threads,
|
||||||
false,
|
|
||||||
conditional_response_code,
|
conditional_response_code,
|
||||||
show_status_codes,
|
show_status_codes,
|
||||||
false,
|
..Default::default()
|
||||||
)
|
};
|
||||||
.await;
|
|
||||||
|
httplib::return_http_data(&lib_options).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue