Skip to content

Commit

Permalink
v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Mon-ius committed Aug 19, 2024
1 parent 1b18df1 commit d7dc104
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 47 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "aw"
version = "0.0.4"
version = "0.0.5"
edition = "2021"

[dependencies]
clap = { version = "4.5.15", features = ["derive"] }
tokio = { version = "1.39.2", default-features = false, features = ["rt-multi-thread", "rt"] }
clap = { version = "4.5.16", features = ["derive"] }
tokio = { version = "1.39.3", default-features = false, features = ["rt"] }
reqwest = { version = "0.12.5", default-features = false, features = ["http2", "json", "rustls-tls"] }
serde_json = { version = "1.0.120", default-features = false, features = ["alloc"] }
serde = { version = "1.0.204", features = ["derive"] }
serde_json = { version = "1.0.125", default-features = false, features = ["alloc"] }
serde = { version = "1.0.208", features = ["derive"] }
ring = { version = "0.17.8", default-features = false}
indicatif = "0.17.8"
chrono = "0.4.38"
Expand Down
10 changes: 8 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ use clap::Parser;

#[derive(Parser)]
struct Cli {
n: usize,
value: Option<usize>,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
let start_time = std::time::Instant::now();
let cli = Cli::parse();
let _ = ld_::interface(cli.n);

let _ = match cli.value {
Some(n) => ld_::interface(n),
None => ld_::get_pool(),
};

println!("Processing time: {:?}", start_time.elapsed());
Ok(())
}
66 changes: 30 additions & 36 deletions src/client/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ pub async fn batch_seed(warp: Vec<WARP>) -> Vec<WARP> {

let _pb = mp.add(ProgressBar::new(tasks.len() as u64));
_pb.set_style(seed_style.clone());
if tasks.len()>100{
tokio::time::sleep(RETRY_DELAY).await;
}
for task in tasks {
if let Ok(Ok(warp)) = task.await {
warps.push(warp);
Expand Down Expand Up @@ -151,6 +154,9 @@ pub async fn batch_update(warp: Vec<WARP>) -> Vec<WARP> {

let _pb = mp.add(ProgressBar::new(tasks.len() as u64));
_pb.set_style(update_style.clone());
if tasks.len()>100{
tokio::time::sleep(RETRY_DELAY).await;
}
for task in tasks {
if let Ok(Ok(warp)) = task.await {
warps.push(warp);
Expand Down Expand Up @@ -198,6 +204,9 @@ pub async fn batch_delete(warp: Vec<WARP>) -> Vec<WARP> {

let _pb = mp.add(ProgressBar::new(tasks.len() as u64));
_pb.set_style(delete_style.clone());
if tasks.len()>100{
tokio::time::sleep(RETRY_DELAY).await;
}
for task in tasks {
if let Ok(Ok(warp)) = task.await {
warps.push(warp);
Expand All @@ -210,6 +219,11 @@ pub async fn batch_delete(warp: Vec<WARP>) -> Vec<WARP> {
}

pub async fn batch_info(warp: Vec<WARP>){
let mp = MultiProgress::new();
let info_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.green/red} {pos:>7}/{len:7}")
.unwrap()
.tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ ");

let mut tasks = Vec::new();

for _warp in warp{
Expand All @@ -219,43 +233,23 @@ pub async fn batch_info(warp: Vec<WARP>){
tasks.push(task);
}

let _pb = mp.add(ProgressBar::new(tasks.len() as u64));
_pb.set_style(info_style.clone());

if tasks.len()>100{
tokio::time::sleep(RETRY_DELAY).await;
}

for task in tasks {
if let Ok(Ok(info)) = task.await {
println!("{:#?}", info);
let quota:usize = info.parse().expect("Failed to convert quota to usize");
if quota == 24598562000000000{
_pb.inc(1);
}
else {
print!("-{}-", quota);
}
}
}
}



// 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();
_pb.finish();
}
4 changes: 0 additions & 4 deletions src/client/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,8 @@ impl WARP {
return Err(format!("GET HTTP error: {}", response.text().await?).into());
}

// let json = response.json().await?;
let json: serde_json::Value = response.json().await?;
let info = json["quota"].to_string();
// let caption = json["candidates"][0]["content"]["parts"][0]["text"]
// .as_str()
// .ok_or_else(|| format!("Failed to parse response: {}", response_text))?;
Ok(info)
}

Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod client;
use client::process;

const SECRET: &str = "secret.txt";

pub fn interface(num: usize) -> Result<(), Box<dyn std::error::Error>> {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
Expand All @@ -24,3 +26,12 @@ pub fn interface(num: usize) -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

pub fn get_pool() -> Result<(), Box<dyn std::error::Error>> {
let raw = std::fs::read_to_string(SECRET)?;
let secrete = raw.replace("\n", " ");
let pool = client::cipher::encode(&secrete);

println!("{:?}", pool);
Ok(())
}

0 comments on commit d7dc104

Please sign in to comment.