Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrag committed Feb 1, 2021
1 parent 529ba77 commit 36f755e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ async fn handle_command(
(Some(key), Some(_channel_id)) => {
//decode the client hash
let client_hash = hex::decode(key).expect("error with hash decode");
let key = hmac::Key::new(hmac::HMAC_SHA512,
&read_stream_key(false, Some("")));
let key = hmac::Key::new(hmac::HMAC_SHA512, &read_stream_key(false, Some("")));
//compare the two hashes to ensure they match
match hmac::verify(
&key,
Expand Down Expand Up @@ -383,16 +382,16 @@ fn print_stream_key(stream_key: Vec<u8>) {

pub fn read_stream_key(startup: bool, stream_key_env: Option<&str>) -> Vec<u8> {
if startup {
if !stream_key_env.is_none() {
let stream_key = stream_key_env.unwrap().to_string();
if let Some(stream_key) = stream_key_env {
if !stream_key.is_empty() {
let key = stream_key.as_bytes().to_vec();
print_stream_key(key.to_vec());
fs::write("hash", hex::encode(&stream_key)).expect("Unable to write file");
return key
fs::write("hash", hex::encode(&stream_key))
.expect("Unable to write stream key to hash file");
return key;
}
}
return match fs::read_to_string("hash") {
match fs::read_to_string("hash") {
Err(_) => {
let stream_key = generate_stream_key();
warn!("Could not read stream key. Re-generating...");
Expand Down

0 comments on commit 36f755e

Please sign in to comment.