aboutsummaryrefslogtreecommitdiffstats
path: root/src/args.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/args.rs')
-rw-r--r--src/args.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/args.rs b/src/args.rs
index ea0a4ac..11357c2 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -42,7 +42,7 @@ struct CLIArgs {
/// username:password, username:sha256:hash, username:sha512:hash
/// (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)
#[structopt(short = "a", long = "auth", parse(try_from_str = "parse_auth"))]
- auth: Option<auth::RequiredAuth>,
+ auth: Vec<auth::RequiredAuth>,
/// Generate a random 6-hexdigit route
#[structopt(long = "random-route")]
@@ -78,7 +78,7 @@ fn parse_interface(src: &str) -> Result<IpAddr, std::net::AddrParseError> {
src.parse::<IpAddr>()
}
-/// Checks wether the auth string is valid, i.e. it follows the syntax username:password
+/// Parse authentication requirement
fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> {
let mut split = src.splitn(3, ':');
let invalid_auth_format = Err(ContextualError::InvalidAuthFormat);
@@ -173,14 +173,16 @@ mod tests {
use auth::*;
use RequiredAuthPassword::*;
- RequiredAuth {
+ let password = match encrypt {
+ "plain" => Plain(password.to_owned()),
+ "sha256" => Sha256(hex::decode(password.to_owned()).unwrap()),
+ "sha512" => Sha512(hex::decode(password.to_owned()).unwrap()),
+ _ => panic!("Unknown encryption type"),
+ };
+
+ auth::RequiredAuth {
username: username.to_owned(),
- password: match encrypt {
- "plain" => Plain(password.to_owned()),
- "sha256" => Sha256(hex::decode(password.to_owned()).unwrap()),
- "sha512" => Sha512(hex::decode(password.to_owned()).unwrap()),
- _ => panic!("Unknown encryption type"),
- },
+ password,
}
}