From cae08bb3c2ccfd4a151094b89c8acc047bd42ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 14 Apr 2022 20:40:52 +0200 Subject: [PATCH] Support reading client/server secret from an environment variable (#18) --- Cargo.toml | 2 +- README.md | 6 ++++-- src/main.rs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eaf6bde..939cb56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ path = "src/main.rs" [dependencies] anyhow = { version = "1.0.56", features = ["backtrace"] } -clap = { version = "3.1.8", features = ["derive"] } +clap = { version = "3.1.8", features = ["derive", "env"] } dashmap = "5.2.0" hex = "0.4.3" hmac = "0.12.1" diff --git a/README.md b/README.md index 5b32c37..aea9ffc 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ OPTIONS: -h, --help Print help information -l, --local-host The local host to expose [default: localhost] -p, --port Optional port on the remote server to select [default: 0] - -s, --secret Optional secret for authentication + -s, --secret Optional secret for authentication [env: BORE_SECRET] -t, --to Address of the remote server to expose local ports to -V, --version Print version information ``` @@ -92,7 +92,7 @@ USAGE: OPTIONS: -h, --help Print help information --min-port Minimum TCP port number to accept [default: 1024] - -s, --secret Optional secret for authentication + -s, --secret Optional secret for authentication [env: BORE_SECRET] -V, --version Print version information ``` @@ -116,6 +116,8 @@ bore server --secret my_secret_string bore local --to --secret my_secret_string ``` +`BORE_SECRET` environment variable can also be used for setting the secret for client/server. + ## Acknowledgements Created by Eric Zhang ([@ekzhang1](https://twitter.com/ekzhang1)). Licensed under the [MIT license](LICENSE). diff --git a/src/main.rs b/src/main.rs index 934e892..ca17c3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ enum Command { port: u16, /// Optional secret for authentication. - #[clap(short, long)] + #[clap(short, long, env = "BORE_SECRET", hide_env_values = true)] secret: Option, }, @@ -41,7 +41,7 @@ enum Command { min_port: u16, /// Optional secret for authentication. - #[clap(short, long)] + #[clap(short, long, env = "BORE_SECRET", hide_env_values = true)] secret: Option, }, }