mirror of
https://github.com/Skallwar/suckit.git
synced 2026-09-10 07:16:19 -04:00
Add CLI argument to disable SSL checks
This commit is contained in:
parent
85e8ecca62
commit
83d0327aac
|
|
@ -148,6 +148,9 @@ pub struct Args {
|
|||
/// If set, run without saving anything to the disk
|
||||
#[structopt(long, help = "Do everything without saving the files to the disk")]
|
||||
pub dry_run: bool,
|
||||
|
||||
#[structopt(long, help = "Dissable SSL certificates verification")]
|
||||
pub disable_certs_checks: bool,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,13 @@ fn parse_auth(auth: &[String], origin: &Url) -> Result<(String, Option<String>,
|
|||
|
||||
impl Downloader {
|
||||
/// Create a new Downloader
|
||||
pub fn new(tries: usize, user_agent: &str, auth: &[String], origin: &Url) -> Downloader {
|
||||
pub fn new(
|
||||
tries: usize,
|
||||
user_agent: &str,
|
||||
disable_certs_checks: bool,
|
||||
auth: &[String],
|
||||
origin: &Url,
|
||||
) -> Downloader {
|
||||
// Create a mapping of hosts to username, password tuples for authentication
|
||||
let mut auth_map = HashMap::new();
|
||||
// Iterate over the auth string in chunks of 3 items each for (username, password, host)
|
||||
|
|
@ -64,7 +70,7 @@ impl Downloader {
|
|||
|
||||
Downloader {
|
||||
client: reqwest::blocking::ClientBuilder::new()
|
||||
.danger_accept_invalid_certs(true)
|
||||
.danger_accept_invalid_certs(disable_certs_checks)
|
||||
.cookie_store(true)
|
||||
.user_agent(user_agent)
|
||||
.build()
|
||||
|
|
@ -179,7 +185,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_download_url() {
|
||||
let url: Url = Url::parse("https://lwn.net").unwrap();
|
||||
match Downloader::new(1, "suckit", &[], &url).get(&url) {
|
||||
match Downloader::new(1, "suckit", false, &[], &url).get(&url) {
|
||||
Err(e) => assert!(false, "Fail to download lwn.net: {:?}", e),
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ impl Scraper {
|
|||
downloader: downloader::Downloader::new(
|
||||
args.tries,
|
||||
&args.user_agent,
|
||||
args.disable_certs_checks,
|
||||
&args.auth,
|
||||
&args.origin,
|
||||
),
|
||||
|
|
@ -423,6 +424,7 @@ mod tests {
|
|||
auth: Vec::new(),
|
||||
continue_on_error: true,
|
||||
dry_run: false,
|
||||
disable_certs_checks: false,
|
||||
};
|
||||
|
||||
let _ = Scraper::new(args);
|
||||
|
|
@ -449,6 +451,7 @@ mod tests {
|
|||
auth: Vec::new(),
|
||||
continue_on_error: true,
|
||||
dry_run: false,
|
||||
disable_certs_checks: false,
|
||||
};
|
||||
|
||||
let _ = Scraper::new(args);
|
||||
|
|
|
|||
Loading…
Reference in a new issue