aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-08-21 06:14:16 +0000
committerFuwn <[email protected]>2021-08-21 06:14:16 +0000
commit192745305bf5afe1a07bf504b3dd44eb83ffbf0e (patch)
tree218493e35aab514289f8d2ec08dd20600a11fc20
parentfix(nitrous): socks4h being used instead of socks4 (diff)
downloadnitrous-192745305bf5afe1a07bf504b3dd44eb83ffbf0e.tar.xz
nitrous-192745305bf5afe1a07bf504b3dd44eb83ffbf0e.zip
fix(check): use http if http
-rw-r--r--benches/bench.rs18
-rw-r--r--src/cli.rs1
-rw-r--r--src/nitrous.rs37
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);
diff --git a/src/cli.rs b/src/cli.rs
index 4214a13..b25df83 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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()