Skip to main content

trojan_cert/
cli.rs

1//! CLI definitions for certificate management.
2
3use clap::{Args, Parser, Subcommand};
4use std::net::IpAddr;
5use std::path::PathBuf;
6
7/// Certificate management for trojan.
8#[derive(Parser, Debug, Clone)]
9#[command(
10    name = "trojan-cert",
11    version,
12    about = "Certificate management for trojan"
13)]
14pub struct CertArgs {
15    #[command(subcommand)]
16    pub command: CertCommands,
17}
18
19#[derive(Subcommand, Debug, Clone)]
20pub enum CertCommands {
21    /// Generate a self-signed certificate.
22    Generate(GenerateArgs),
23}
24
25#[derive(Args, Debug, Clone)]
26pub struct GenerateArgs {
27    /// Domain names to include in the certificate (can specify multiple).
28    #[arg(short, long, required = true)]
29    pub domain: Vec<String>,
30
31    /// IP addresses to include in Subject Alternative Names.
32    #[arg(long)]
33    pub ip: Vec<IpAddr>,
34
35    /// Output directory for certificate and key files.
36    #[arg(short, long, default_value = ".")]
37    pub output: PathBuf,
38
39    /// Certificate validity period in days.
40    #[arg(long, default_value = "365")]
41    pub days: u32,
42
43    /// Certificate filename (without .pem extension).
44    #[arg(long, default_value = "cert")]
45    pub cert_name: String,
46
47    /// Private key filename (without .pem extension).
48    #[arg(long, default_value = "key")]
49    pub key_name: String,
50}