diff options
| author | Fuwn <[email protected]> | 2021-08-21 06:14:16 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-08-21 06:14:16 +0000 |
| commit | 192745305bf5afe1a07bf504b3dd44eb83ffbf0e (patch) | |
| tree | 218493e35aab514289f8d2ec08dd20600a11fc20 | |
| parent | fix(nitrous): socks4h being used instead of socks4 (diff) | |
| download | nitrous-192745305bf5afe1a07bf504b3dd44eb83ffbf0e.tar.xz nitrous-192745305bf5afe1a07bf504b3dd44eb83ffbf0e.zip | |
fix(check): use http if http
| -rw-r--r-- | benches/bench.rs | 18 | ||||
| -rw-r--r-- | src/cli.rs | 1 | ||||
| -rw-r--r-- | src/nitrous.rs | 37 |
3 files changed, 37 insertions, 19 deletions
diff --git a/benches/bench.rs b/benches/bench.rs index 5a432c3..454bb1d 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -4,17 +4,19 @@ #[macro_use] extern crate criterion; -use rand::Rng; use criterion::Criterion; +use rand::Rng; fn bench_generate(c: &mut Criterion) { - c.bench_function("generate", |b| b.iter(|| { - rand::thread_rng() - .sample_iter(rand::distributions::Alphanumeric) - .take(16) - .map(char::from) - .collect::<String>() - })); + c.bench_function("generate", |b| { + b.iter(|| { + rand::thread_rng() + .sample_iter(rand::distributions::Alphanumeric) + .take(16) + .map(char::from) + .collect::<String>() + }) + }); } criterion_group!(benches, bench_generate); @@ -10,6 +10,7 @@ use structopt::{ use crate::nitrous::Nitrous; +#[derive(PartialEq)] pub enum ProxyType { Http, Socks4, diff --git a/src/nitrous.rs b/src/nitrous.rs index f8d22e9..d589db9 100644 --- a/src/nitrous.rs +++ b/src/nitrous.rs @@ -77,19 +77,34 @@ impl Nitrous { let code = code.unwrap(); let status = reqwest::Client::builder() - .proxy(reqwest::Proxy::all(format!("{}://{}", { - match proxy_type { - ProxyType::Http => "http", - ProxyType::Socks4 => "socks4", - ProxyType::Socks5 | ProxyType::Tor => "socks5h", - } - }, proxy_addr)).unwrap()) + .proxy( + reqwest::Proxy::all(format!( + "{}://{}", + { + match proxy_type { + ProxyType::Http => "http", + ProxyType::Socks4 => "socks4", + ProxyType::Socks5 | ProxyType::Tor => "socks5h", + } + }, + proxy_addr + )) + .unwrap(), + ) .build() .unwrap() - .get( - format!("https://discordapp.com/api/v6/entitlements/gift-codes/{}?with_application=false&\ - with_subscription_plan=true", code), - ) + .get(format!( + "{}://discordapp.com/api/v6/entitlements/gift-codes/{}?with_application=false&\ + with_subscription_plan=true", + { + if proxy_type == ProxyType::Http { + "http" + } else { + "https" + } + }, + code + )) .send() .await .unwrap() |