Skip to content

Commit

Permalink
chore(tls-reload): Improve tls reloading & remove deps on rust 1.75
Browse files Browse the repository at this point in the history
  • Loading branch information
erebe committed Jan 8, 2024
1 parent f373293 commit f65ff1c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/tunnel/tls_reloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::{Duration, SystemTime};
use std::time::Duration;
use tracing::{error, info, warn};

struct TlsReloaderState {
Expand Down Expand Up @@ -83,13 +83,9 @@ impl TlsReloader {
};
drop(watcher);

let Ok(file) = File::open(&path) else {
let Ok(_) = File::open(&path) else {
return;
};
let _ = file.set_modified(SystemTime::now()).map_err(|err| {
error!("Cannot force reload TLS file {:?}: {:?}", path, err);
error!("Old certificate will be used until the next change");
});
});
}

Expand All @@ -116,6 +112,7 @@ impl TlsReloader {
}
Err(err) => {
warn!("Error while loading TLS certificate {:?}", err);
Self::try_rewatch_certificate(this.clone(), path.to_path_buf());
}
},
EventKind::Remove(_) => {
Expand All @@ -137,6 +134,7 @@ impl TlsReloader {
}
Err(err) => {
warn!("Error while loading TLS private key {:?}", err);
Self::try_rewatch_certificate(this.clone(), path.to_path_buf());
}
},
EventKind::Remove(_) => {
Expand Down

0 comments on commit f65ff1c

Please sign in to comment.