Files
fast-xray/src/main.rs
T

47 lines
1.6 KiB
Rust

//! fast-xray — Cloudflare IP optimizer for CDN-fronted Xray/VLESS nodes.
//!
//! Subcommands mirror the optimization pipeline:
//! ping collect the fastest reachable Cloudflare IPs over TCP
//! latency measure real proxy latency through the node
//! speed download through the node to measure real speed
//! export build importable vless:// nodes from a valid-IP list
mod cli;
mod cloudflare;
mod commands;
mod easy;
mod latency;
mod ping;
mod report;
mod speed;
mod vless;
mod web;
use anyhow::Result;
use clap::Parser;
use cli::{Cli, Command, EasyArgs, WebArgs};
#[tokio::main]
async fn main() -> Result<()> {
// Process-wide TLS crypto provider for our own rustls client configs.
let _ = rustls::crypto::ring::default_provider().install_default();
let cli = Cli::parse();
match cli.command {
Some(Command::Ping(args)) => commands::run_ping(args).await,
Some(Command::Latency(args)) => commands::run_latency(args).await,
Some(Command::Speed(args)) => commands::run_speed(args).await,
Some(Command::Export(args)) => commands::run_export(args),
Some(Command::Easy(args)) => easy::run(args).await,
Some(Command::Web(args)) => web::run(args).await,
// A node without a subcommand runs the auto pipeline; bare invocation
// (e.g. a double-clicked binary) opens the web UI.
None => match cli.auto.node.as_deref() {
Some("chuan") => easy::run_with_fallback(EasyArgs::chuan()).await,
Some(_) => commands::run_auto(cli.auto).await,
None => web::run(WebArgs::default()).await,
},
}
}