Compare commits

...

1 Commits

Author SHA1 Message Date
S.B 0b1c1a8c7a fix generator path and improve proxy selection 2025-06-17 00:06:52 +02:00
2 changed files with 10 additions and 12 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ use std::path::{Path, PathBuf};
fn main() { fn main() {
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("cred_dispatch.rs"); // Keep dispatch file naming consistent with build.rs
let dest_path = Path::new(&out_dir).join("creds_dispatch.rs");
let mut file = File::create(&dest_path).unwrap(); let mut file = File::create(&dest_path).unwrap();
let creds_root = Path::new("src/modules/creds"); let creds_root = Path::new("src/modules/creds");
+8 -11
View File
@@ -1,7 +1,7 @@
use crate::commands; use crate::commands;
use crate::utils; use crate::utils;
use anyhow::Result; use anyhow::Result;
use rand::prelude::*; // Updated for rand 0.10 use rand::prelude::*; // rand 0.9 prelude provides rng() and SliceRandom
use std::env; use std::env;
use std::io::{self, Write}; use std::io::{self, Write};
use std::collections::HashSet; use std::collections::HashSet;
@@ -188,20 +188,17 @@ pub async fn interactive_shell() -> Result<()> {
/// Picks a random proxy from `proxy_list` that is NOT in `tried_proxies`. /// Picks a random proxy from `proxy_list` that is NOT in `tried_proxies`.
fn pick_random_untried_proxy(proxy_list: &[String], tried_proxies: &HashSet<String>) -> String { fn pick_random_untried_proxy(proxy_list: &[String], tried_proxies: &HashSet<String>) -> String {
let untried: Vec<&String> = proxy_list.iter() let mut rng = rand::rng();
let choices: Vec<&String> = proxy_list
.iter()
.filter(|p| !tried_proxies.contains(*p)) .filter(|p| !tried_proxies.contains(*p))
.collect(); .collect();
if untried.is_empty() { if let Some(choice) = choices.choose(&mut rng) {
// Fall back if somehow there's nothing untried choice.to_string()
let mut rng = rand::rng(); } else {
let idx = rng.random_range(0..proxy_list.len()); proxy_list.choose(&mut rng).unwrap().to_string()
return proxy_list[idx].clone();
} }
let mut rng = rand::rng();
let idx = rng.random_range(0..untried.len());
untried[idx].clone()
} }
/// Sets ALL_PROXY so reqwest uses it for all requests (including socks4, socks5, http, https) /// Sets ALL_PROXY so reqwest uses it for all requests (including socks4, socks5, http, https)