1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(name = "discord-proxy")]
#[command(about = "Start Discord with a process-local proxy")]
pub struct Cli {
#[arg(short, long, global = true, value_name = "FILE")]
pub config: Option<PathBuf>,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Debug, Subcommand)]
pub enum Commands {
/// Start Discord with proxy settings.
Launch(LaunchArgs),
/// Print the detected Discord installation without launching it.
Doctor(DoctorArgs),
/// Run only the local HTTP CONNECT proxy bridge.
Bridge(BridgeArgs),
}
#[derive(Debug, Args)]
pub struct LaunchArgs {
/// Upstream proxy URL, for example http://127.0.0.1:1080 or socks5://user:pass@127.0.0.1:1080.
#[arg(short, long)]
pub proxy: Option<String>,
/// Discord channel: stable, canary, ptb, or development.
#[arg(long)]
pub channel: Option<String>,
/// Discord root directory that contains Update.exe and app-* folders.
#[arg(long, value_name = "DIR")]
pub discord_dir: Option<PathBuf>,
/// Local bridge listen port. Defaults to a random available loopback port.
#[arg(long)]
pub listen_port: Option<u16>,
/// Do not start the local bridge even when SOCKS or authentication would normally require it.
#[arg(long)]
pub no_bridge: bool,
/// Print the launch plan without starting Discord.
#[arg(long)]
pub dry_run: bool,
}
#[derive(Debug, Args)]
pub struct DoctorArgs {
/// Discord channel: stable, canary, ptb, or development.
#[arg(long)]
pub channel: Option<String>,
/// Discord root directory that contains Update.exe and app-* folders.
#[arg(long, value_name = "DIR")]
pub discord_dir: Option<PathBuf>,
}
#[derive(Debug, Args)]
pub struct BridgeArgs {
/// Upstream proxy URL.
#[arg(short, long)]
pub proxy: String,
/// Local bridge listen port. Defaults to a random available loopback port.
#[arg(long)]
pub listen_port: Option<u16>,
}