feat: add auto pipeline as default top-level command

This commit is contained in:
chuan
2026-06-23 21:09:00 +08:00
parent 39080678bb
commit af9e09148e
3 changed files with 264 additions and 79 deletions
+54 -2
View File
@@ -4,11 +4,21 @@ use std::path::PathBuf;
use clap::{Args, Parser, Subcommand};
/// With no subcommand, the top-level args run the full auto pipeline
/// (ping → latency → speed → export).
#[derive(Parser)]
#[command(name = "fast-xray", about = "Fast Cloudflare IP optimizer for CDN-fronted Xray/VLESS nodes.")]
#[command(
name = "fast-xray",
about = "Fast Cloudflare IP optimizer for CDN-fronted Xray/VLESS nodes.",
arg_required_else_help = true,
args_conflicts_with_subcommands = true
)]
pub(crate) struct Cli {
#[command(subcommand)]
pub(crate) command: Command,
pub(crate) command: Option<Command>,
#[command(flatten)]
pub(crate) auto: AutoArgs,
}
#[derive(Subcommand)]
@@ -23,6 +33,48 @@ pub(crate) enum Command {
Export(ExportArgs),
}
#[derive(Args)]
pub(crate) struct AutoArgs {
/// Input vless:// node URL (or use --node-file).
pub(crate) node: Option<String>,
/// Read the vless:// node URL from a file (avoids shell escaping of `&`).
#[arg(long)]
pub(crate) node_file: Option<PathBuf>,
/// Stage 1: how many valid IPs the ping stage collects.
#[arg(short = 'n', long, default_value_t = 50)]
pub(crate) count: usize,
/// Stage 2: keep the fastest N after latency (feeds the speed stage).
#[arg(long, default_value_t = 30)]
pub(crate) lat_top: usize,
/// Stage 3: final node count written to result.txt.
#[arg(long, default_value_t = 10)]
pub(crate) speed_top: usize,
/// Also test IPv6 ranges (off by default).
#[arg(short = '6', long = "ipv6")]
pub(crate) ipv6: bool,
/// Quality gate: drop IPs whose real latency exceeds this (ms). 0 = off.
#[arg(long, default_value_t = 0.0)]
pub(crate) max_latency: f64,
/// Quality gate: drop IPs slower than this (Mbps). 0 = off.
#[arg(long, default_value_t = 0.0)]
pub(crate) min_speed: f64,
/// Output directory for all intermediate files and result.txt.
#[arg(short = 'o', long, default_value = "result")]
pub(crate) output: PathBuf,
/// Print each stage's result table.
#[arg(short = 'v', long)]
pub(crate) verbose: bool,
}
#[derive(Args)]
pub(crate) struct PingArgs {
/// Target number of valid (reachable) IPs to collect.