ferrotunnel-cli 1.0.7

Unified CLI for FerroTunnel - secure reverse tunnel system
//! FerroTunnel Unified CLI
//!
//! A secure, high-performance reverse tunnel system.

// Use mimalloc as the global allocator for better performance
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

mod commands;
mod middleware;

use anyhow::Result;
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "ferrotunnel",
    author,
    version,
    about = "Secure, high-performance reverse tunnel system",
    long_about = "FerroTunnel is a secure, high-performance reverse tunnel system in Rust.\n\n\
                  It can be used as a CLI tool or embedded directly into your applications.",
    propagate_version = true
)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Run the tunnel server
    Server(commands::server::ServerArgs),

    /// Run the tunnel client
    Client(commands::client::ClientArgs),

    /// Show version information
    Version,
}

#[tokio::main]
async fn main() -> Result<()> {
    // rustls 0.23 requires explicitly installing the crypto provider before any
    // TLS connection is attempted. The `ring` feature makes the provider
    // available but does NOT auto-install it (see ferro-labs/ferrotunnel#98).
    // We ignore the Err case because install_default() fails only when another
    // provider has already been installed (e.g. in tests), which is fine.
    let _ = rustls::crypto::ring::default_provider().install_default();

    let cli = Cli::parse();

    match cli.command {
        Commands::Server(args) => commands::server::run(args).await,
        Commands::Client(args) => commands::client::run(args).await,
        Commands::Version => {
            commands::version::run();
            Ok(())
        }
    }
}