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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(
name = "sb-mesh",
about = "S&B Sovereign Mesh — User-Space P2P Overlay Network & Terminal TUI",
version = "0.1.0"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Launch the interactive Ratatui terminal dashboard (Default)
Tui,
/// Run headless mesh node daemon
Daemon {
#[arg(short, long)]
port: Option<u16>,
},
/// Display current node status, public keys, and peer count
Status,
/// Manage mesh peers
Peer {
#[command(subcommand)]
sub: PeerCommands,
},
/// Generate or consume direct device pairing tokens (sbm-pair://)
Pair {
#[command(subcommand)]
sub: PairCommands,
},
/// Send an authenticated cryptographic ping to a peer
Ping {
/// Callsign, Node ID or Public Key of the peer
target: String,
},
/// Toggle or inspect Air-Gap killswitch status
Airgap {
/// Action: 'on', 'off', or 'toggle'
#[arg(default_value = "toggle")]
action: String,
},
/// Run user-space SOCKS5 proxy (127.0.0.1:1080)
Proxy {
/// Local port for SOCKS5 proxy listener
#[arg(short, long, default_value_t = 1080)]
port: u16,
},
/// Establish a P2P port-forwarding tunnel to a peer
Tunnel {
/// Local listening port (e.g. 8080)
#[arg(short, long)]
local: u16,
/// Remote destination address (e.g. 10.240.0.2:80 or target_ip:port)
#[arg(short, long)]
remote: String,
},
/// Display multi-hop routing table, subnet routes, and exit node status
Routes,
/// Revoke a compromised public key via P2P Gossip CRL
Revoke {
/// WireGuard Base64 public key to revoke
pubkey: String,
/// Reason for revocation
#[arg(short, long, default_value = "Device compromised or decommissioned")]
reason: String,
},
/// Share a local development port over the P2P Sovereign Mesh (Ngrok alternative)
Share {
/// Local port to share (e.g. 3000, 8080)
port: u16,
/// Optional service label or custom subdomain name
#[arg(short, long)]
label: Option<String>,
/// Local service bind host (default: 127.0.0.1)
#[arg(long, default_value = "127.0.0.1")]
host: String,
/// Ingress port on mesh interface (default: same as local port)
#[arg(short, long)]
ingress_port: Option<u16>,
/// Optional access token / passphrase requirement for connecting peers
#[arg(short, long)]
token: Option<String>,
},
}
#[derive(Subcommand, Debug)]
pub enum PeerCommands {
/// Add a new peer manually
Add {
/// Callsign / Friendly name for the peer
callsign: String,
/// WireGuard-compatible Base64 public key (32 bytes)
public_key: String,
/// Peer socket endpoint IP:Port (e.g. 192.168.1.50:58888)
#[arg(short, long)]
endpoint: Option<String>,
/// Optional internal overlay IP (e.g. 10.240.0.2)
#[arg(short, long)]
overlay_ip: Option<String>,
},
/// List all configured peers
List,
/// Remove a peer by public key or callsign
Remove {
target: String,
},
}
#[derive(Subcommand, Debug)]
pub enum PairCommands {
/// Generate a pairing token to invite another device
Generate {
/// Your public or LAN IP:Port endpoint (e.g. 192.168.1.100:58888)
endpoint: String,
/// Display high-density terminal QR code for scanning
#[arg(long, default_value_t = false)]
qr: bool,
/// Time-to-Live (TTL) in seconds (default: 300s = 5 min, 0 = unlimited)
#[arg(long, default_value_t = 300)]
ttl: u64,
},
/// Connect to a device using a pairing token (sbm-pair://...)
Connect {
/// Friendly callsign for this new device
callsign: String,
/// The pairing token
token: String,
},
}