Support reading client/server secret from an environment variable (#18)

This commit is contained in:
Orhun Parmaksız 2022-04-14 20:40:52 +02:00 committed by GitHub
parent b045d8028e
commit cae08bb3c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -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"

View File

@ -65,7 +65,7 @@ OPTIONS:
-h, --help Print help information
-l, --local-host <HOST> The local host to expose [default: localhost]
-p, --port <PORT> Optional port on the remote server to select [default: 0]
-s, --secret <SECRET> Optional secret for authentication
-s, --secret <SECRET> Optional secret for authentication [env: BORE_SECRET]
-t, --to <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 <MIN_PORT> Minimum TCP port number to accept [default: 1024]
-s, --secret <SECRET> Optional secret for authentication
-s, --secret <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 <LOCAL_PORT> --to <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).

View File

@ -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<String>,
},
@ -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<String>,
},
}