Skip to content

Commit cc8774f

Browse files
authored
Merge pull request #41 from flashbots/peg/accept-env-vars
Accept various CLI options as environment variables
2 parents 7f4cd74 + 1b2d326 commit cc8774f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tokio-rustls = { version = "0.26.4", default-features = false, features = ["ring
1010
sha2 = "0.10.9"
1111
x509-parser = "0.18.0"
1212
thiserror = "2.0.17"
13-
clap = { version = "4.5.51", features = ["derive"] }
13+
clap = { version = "4.5.51", features = ["derive", "env"] }
1414
webpki-roots = "1.0.4"
1515
rustls-pemfile = "2.2.0"
1616
anyhow = "1.0.100"

src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ enum CliCommand {
3232
/// Run a proxy client
3333
Client {
3434
/// Socket address to listen on
35-
#[arg(short, long, default_value = "0.0.0.0:0")]
35+
#[arg(short, long, default_value = "0.0.0.0:0", env = "LISTEN_ADDR")]
3636
listen_addr: SocketAddr,
3737
/// The hostname:port or ip:port of the proxy server (port defaults to 443)
3838
target_addr: String,
3939
/// The path to a PEM encoded private key for client authentication
40-
#[arg(long)]
40+
#[arg(long, env = "TLS_PRIVATE_KEY_PATH")]
4141
tls_private_key_path: Option<PathBuf>,
4242
/// The path to a PEM encoded certificate chain for client authentication
43-
#[arg(long)]
43+
#[arg(long, env = "TLS_CERTIFICATE_PATH")]
4444
tls_certificate_path: Option<PathBuf>,
4545
/// Type of attestaion to present (dafaults to none)
4646
/// If other than None, a TLS key and certicate must also be given
47-
#[arg(long)]
47+
#[arg(long, env = "CLIENT_ATTESTATION_TYPE")]
4848
client_attestation_type: Option<String>,
4949
/// Optional path to file containing JSON measurements to be enforced on the server
50-
#[arg(long)]
50+
#[arg(long, env = "SERVER_MEASUREMENTS")]
5151
server_measurements: Option<PathBuf>,
5252
/// Additional CA certificate to verify against (PEM) Defaults to no additional TLS certs.
5353
#[arg(long)]
@@ -63,15 +63,15 @@ enum CliCommand {
6363
/// Run a proxy server
6464
Server {
6565
/// Socket address to listen on
66-
#[arg(short, long, default_value = "0.0.0.0:0")]
66+
#[arg(short, long, default_value = "0.0.0.0:0", env = "LISTEN_ADDR")]
6767
listen_addr: SocketAddr,
6868
/// Socket address of the target service to forward traffic to
6969
target_addr: SocketAddr,
7070
/// The path to a PEM encoded private key
71-
#[arg(long)]
71+
#[arg(long, env = "TLS_PRIVATE_KEY_PATH")]
7272
tls_private_key_path: PathBuf,
7373
/// The path to a PEM encoded certificate chain
74-
#[arg(long)]
74+
#[arg(long, env = "TLS_CERTIFICATE_PATH")]
7575
tls_certificate_path: PathBuf,
7676
/// Whether to use client authentication. If the client is running in a CVM this must be
7777
/// enabled.
@@ -82,7 +82,7 @@ enum CliCommand {
8282
#[arg(long)]
8383
server_attestation_type: Option<String>,
8484
/// Optional path to file containing JSON measurements to be enforced on the client
85-
#[arg(long)]
85+
#[arg(long, env = "CLIENT_MEASUREMENTS")]
8686
client_measurements: Option<PathBuf>,
8787
/// The URL of a PCCS to use when verifying DCAP attestations. Defaults to Intel PCS.
8888
#[arg(long)]

0 commit comments

Comments
 (0)