-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
441 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use rand::Rng as _; | ||
use std::net::Ipv4Addr; | ||
|
||
pub fn generate_geo_ip() -> String { | ||
let mut rng = rand::thread_rng(); | ||
Ipv4Addr::new( | ||
rng.gen_range(1..=253), | ||
rng.gen(), | ||
rng.gen(), | ||
rng.gen_range(1..=254) | ||
).to_string() | ||
} | ||
|
||
pub fn generate_us_ip() -> String { | ||
let mut rng = rand::thread_rng(); | ||
let _blocks = [ | ||
(3, 0, 0, 0, 4), // 3.0.0.0/8 | ||
(4, 0, 0, 0, 6), // 4.0.0.0/6 | ||
(8, 0, 0, 0, 7), // 8.0.0.0/7 | ||
(11, 0, 0, 0, 8), // 11.0.0.0/8 | ||
(12, 0, 0, 0, 6), // 12.0.0.0/6 | ||
(16, 0, 0, 0, 6), // 16.0.0.0/6 | ||
(20, 0, 0, 0, 7), // 20.0.0.0/7 | ||
(24, 0, 0, 0, 8), // 24.0.0.0/8 | ||
(26, 0, 0, 0, 7), // 26.0.0.0/7 | ||
(28, 0, 0, 0, 6), // 28.0.0.0/6 | ||
(32, 0, 0, 0, 3), // 32.0.0.0/3 | ||
(64, 0, 0, 0, 2), // 64.0.0.0/2 | ||
(128, 0, 0, 0, 3), // 128.0.0.0/3 | ||
(160, 0, 0, 0, 5), // 160.0.0.0/5 | ||
(168, 0, 0, 0, 6), // 168.0.0.0/6 | ||
(172, 0, 0, 0, 8), // 172.0.0.0/8 | ||
(173, 0, 0, 0, 8), // 173.0.0.0/8 | ||
(174, 0, 0, 0, 7), // 174.0.0.0/7 | ||
(184, 0, 0, 0, 6), // 184.0.0.0/6 | ||
(192, 0, 0, 0, 8), // 192.0.0.0/8 | ||
(198, 0, 0, 0, 7), // 198.0.0.0/7 | ||
(200, 0, 0, 0, 5), // 200.0.0.0/5 | ||
(208, 0, 0, 0, 4), // 208.0.0.0/4 | ||
]; | ||
let (base_a, _, _, _, mask) = _blocks[rng.gen_range(0.._blocks.len())]; | ||
let ip = match mask { | ||
8 => Ipv4Addr::new(base_a, rng.gen(), rng.gen(), rng.gen()), | ||
7 => Ipv4Addr::new(base_a, rng.gen(), rng.gen(), rng.gen()), | ||
6 => Ipv4Addr::new(base_a + rng.gen_range(0..4), rng.gen(), rng.gen(), rng.gen()), | ||
5 => Ipv4Addr::new(base_a + rng.gen_range(0..8), rng.gen(), rng.gen(), rng.gen()), | ||
4 => Ipv4Addr::new(base_a + rng.gen_range(0..16), rng.gen(), rng.gen(), rng.gen()), | ||
3 => Ipv4Addr::new(base_a + rng.gen_range(0..32), rng.gen(), rng.gen(), rng.gen()), | ||
2 => Ipv4Addr::new(base_a + rng.gen_range(0..64), rng.gen(), rng.gen(), rng.gen()), | ||
_ => Ipv4Addr::new(base_a, rng.gen(), rng.gen(), rng.gen()), | ||
}; | ||
ip.to_string() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ pub mod warp; | |
pub use warp::WARP; | ||
|
||
pub mod date; | ||
pub mod cipher; | ||
pub mod cipher; | ||
pub mod geo; | ||
pub mod process; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
use tokio::time::Duration; | ||
use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; | ||
|
||
const RETRY_DELAY: Duration = Duration::from_secs(120); | ||
const CAPACITY: usize = 1000; | ||
const MAX_SEED: usize = 2; | ||
const _EPOOL: &str = "SVQ4azYxMm4tSDhDNDJFajYtODAyN0pFVHAgbzY3OXZjMEYtM1ZMVzFrNzQtY0YwOWE0N1AgMHkyYjNVejUtUGNrSDk3NTQtM202NEExcnUgN1AwM0VXMk0tTWdsMzEyYjYtNXU2QzJ5NHMgMnZ0RDlJNzQtN3R3MTBhVDQtRVk1NzB1NlEgc0MyNTRPVjEtNkIwTTgxenMtOFltN0paMTMgOUw1R0VzODAtOHVTM3g5ZTEtOW12WTU2N2EgN2wyM1RXNWYtdjZUNTI5S3ctMWRvMlJBMzQgZTdNWEUyMDktaXg1MElyMTItOHEzY2IxN3ogM1BGSDg1OXktYzUxNEo5cHItMkU5NE0xUlggN0thYjEwTzQtOU9sdlc4NDMtNTBucWg3MmkgM0o0bmZ2OTIteDUzTTRBOFctWGQxdjkyN2IgYWhHMFM4MzEtME1tNTEzQkotSzduNlQxNVcgSzk0N0ZPRzUtNjRsMHZESDIteTc4MzFwVmkgcjE0dDlKeTUtOTZRM2gxVnYtN040YWkwcDggTTRGM2Q2N0EtYlo5azBxNzIteVVSZTg5MjQgSUJTTDgyNDYtSTM1OWlMNnEtNXdYMmZsNDcgUDZFMzE4Yk4tN2JJMlIwUTgtNzJKOWZ1NFYgVDVEWjgzRzAtUm1BMTQ5N3ctODFYeVJZMzcgOGw1MER4YzEtWms4ajdhOTAtMndOOTMxb0U="; | ||
|
||
use super::warp::WARP; | ||
use super::cipher; | ||
use super::geo; | ||
|
||
pub async fn batch_create(num: usize) -> Vec<WARP> { | ||
let mp = MultiProgress::new(); | ||
let create_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/green} {pos:>7}/{len:7}") | ||
.unwrap() | ||
.tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); | ||
|
||
let mut tasks = Vec::new(); | ||
let mut warps = Vec::new(); | ||
|
||
for _ in 0..num { | ||
let task = tokio::spawn(async { | ||
let ip = geo::generate_us_ip(); | ||
WARP::build(ip).await | ||
}); | ||
|
||
tasks.push(task); | ||
|
||
if tasks.len() == CAPACITY { | ||
let mut _tasks = vec![]; | ||
_tasks.append(&mut tasks); | ||
|
||
let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); | ||
pb.set_style(create_style.clone()); | ||
|
||
for task in _tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
pb.inc(1); | ||
} | ||
tasks.clear(); | ||
pb.finish(); | ||
tokio::time::sleep(RETRY_DELAY).await; | ||
} | ||
} | ||
|
||
let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); | ||
_pb.set_style(create_style.clone()); | ||
for task in tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
_pb.inc(1); | ||
} | ||
_pb.finish(); | ||
warps | ||
} | ||
|
||
pub async fn batch_seed(warp: Vec<WARP>) -> Vec<WARP> { | ||
let mp = MultiProgress::new(); | ||
let seed_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/yellow} {pos:>7}/{len:7}") | ||
.unwrap() | ||
.tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); | ||
|
||
let mut _warps = warp.clone(); | ||
let pool = cipher::decode(_EPOOL); | ||
let seeds : Vec<_> = pool.split(" ").into_iter().collect(); | ||
let mut tasks = Vec::new(); | ||
let mut warps = Vec::new(); | ||
|
||
for _ in 0..MAX_SEED { | ||
for seed in &seeds { | ||
if let Some(warp) = _warps.pop() { | ||
let seed = seed.to_string(); | ||
let task = tokio::spawn(async move { | ||
warp.update_license(seed).await | ||
}); | ||
tasks.push(task); | ||
} else { | ||
break; | ||
} | ||
|
||
if tasks.len() == CAPACITY { | ||
tokio::time::sleep(RETRY_DELAY).await; | ||
let mut _tasks = vec![]; | ||
_tasks.append(&mut tasks); | ||
|
||
let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); | ||
pb.set_style(seed_style.clone()); | ||
|
||
for task in _tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
pb.inc(1); | ||
} | ||
tasks.clear(); | ||
pb.finish(); | ||
} | ||
} | ||
} | ||
|
||
let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); | ||
_pb.set_style(seed_style.clone()); | ||
for task in tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
_pb.inc(1); | ||
} | ||
_pb.finish(); | ||
warps | ||
} | ||
|
||
pub async fn batch_update(warp: Vec<WARP>) -> Vec<WARP> { | ||
let mp = MultiProgress::new(); | ||
let update_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/blue} {pos:>7}/{len:7}") | ||
.unwrap() | ||
.tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); | ||
|
||
let mut tasks = Vec::new(); | ||
let mut warps = Vec::new(); | ||
|
||
for sw in warp{ | ||
let ss = sw.license(); | ||
let task = tokio::spawn(async move { | ||
sw.update_license(ss).await | ||
}); | ||
tasks.push(task); | ||
|
||
if tasks.len() == CAPACITY { | ||
tokio::time::sleep(RETRY_DELAY).await; | ||
let mut _tasks = vec![]; | ||
_tasks.append(&mut tasks); | ||
|
||
let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); | ||
pb.set_style(update_style.clone()); | ||
|
||
for task in _tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
pb.inc(1); | ||
} | ||
tasks.clear(); | ||
pb.finish(); | ||
} | ||
} | ||
|
||
let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); | ||
_pb.set_style(update_style.clone()); | ||
for task in tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
_pb.inc(1); | ||
} | ||
_pb.finish(); | ||
|
||
warps | ||
} | ||
|
||
pub async fn batch_delete(warp: Vec<WARP>) -> Vec<WARP> { | ||
let mp = MultiProgress::new(); | ||
let delete_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/red} {pos:>7}/{len:7}") | ||
.unwrap() | ||
.tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); | ||
|
||
let mut tasks = Vec::new(); | ||
let mut warps = Vec::new(); | ||
|
||
for dw in warp{ | ||
let task = tokio::spawn(async move { | ||
dw.delete().await | ||
}); | ||
tasks.push(task); | ||
|
||
if tasks.len() == CAPACITY { | ||
tokio::time::sleep(RETRY_DELAY).await; | ||
let mut _tasks = vec![]; | ||
_tasks.append(&mut tasks); | ||
|
||
let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); | ||
pb.set_style(delete_style.clone()); | ||
|
||
for task in _tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
pb.inc(1); | ||
} | ||
tasks.clear(); | ||
pb.finish(); | ||
} | ||
} | ||
|
||
let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); | ||
_pb.set_style(delete_style.clone()); | ||
for task in tasks { | ||
if let Ok(Ok(warp)) = task.await { | ||
warps.push(warp); | ||
} | ||
_pb.inc(1); | ||
} | ||
_pb.finish(); | ||
|
||
warps | ||
} | ||
|
||
pub async fn batch_info(warp: Vec<WARP>){ | ||
let mut tasks = Vec::new(); | ||
|
||
for _warp in warp{ | ||
let task = tokio::spawn(async move { | ||
_warp.get_quota().await | ||
}); | ||
tasks.push(task); | ||
} | ||
|
||
for task in tasks { | ||
if let Ok(Ok(info)) = task.await { | ||
println!("{:#?}", info); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
// let _pb = mp.add(ProgressBar::new(seed_tasks.len() as u64)); | ||
// _pb.set_style(update_style.clone()); | ||
// for task in seed_tasks { | ||
// if let Ok(Ok(warp)) = task.await { | ||
// seed_warps.push(warp); | ||
// } | ||
// _pb.inc(1); | ||
// } | ||
// _pb.finish(); | ||
|
||
// tokio::time::sleep(RETRY_DELAY).await; | ||
// let mut warps = Vec::new(); | ||
// let mut tasks = Vec::new(); | ||
|
||
// for sw in seed_warps{ | ||
// let ss = sw.license(); | ||
// let task = tokio::spawn(async move { | ||
// sw.update_license(ss).await | ||
// }); | ||
// tasks.push(task); | ||
// } | ||
|
||
// let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); | ||
// _pb.set_style(update_style.clone()); | ||
// for task in tasks { | ||
// if let Ok(Ok(warp)) = task.await { | ||
// warps.push(warp); | ||
// } | ||
// _pb.inc(1); | ||
// } | ||
// _pb.finish(); |
Oops, something went wrong.