Skip to content

Commit

Permalink
chore: release 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn committed Dec 21, 2024
1 parent f615eff commit 611d1d3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
env:
PACKAGE: "tuic-server"
PACKAGE2: "tuic-client"
RUST_TOOLCHAIN: "nightly-2024-11-26"
RUST_TOOLCHAIN: "nightly-2024-12-20"

jobs:
compile:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
authors = ["EAimTY <[email protected]>", "Itsusinn <[email protected]>"]
version = "1.4.0"
version = "1.4.1"
rust-version = "1.80.0"
edition = "2021"
readme = "README.md"
Expand Down
3 changes: 1 addition & 2 deletions tuic-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(trivial_bounds)]
#![feature(let_chains, async_closure)]
#![feature(let_chains, trivial_bounds)]

use std::{env, process, sync::Arc};

Expand Down
18 changes: 6 additions & 12 deletions tuic-server/src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustls::{
sign::CertifiedKey,
};
use tokio::sync::RwLock;
use tracing::{error, warn};
use tracing::warn;

use crate::utils::{self, FutResultExt};

Expand Down Expand Up @@ -40,17 +40,11 @@ impl CertResolver {
let (mut watcher, mut rx) = utils::async_watcher().await?;

watcher.watch(self.cert_path.as_ref(), RecursiveMode::NonRecursive)?;

while let Some(res) = rx.recv().await {
match res {
Err(e) => error!("TLS cert-key reload watcher error: {:?}", e),
Ok(_) => {
warn!("TLS cert-key reload");
let cert_key = load_cert_key(&self.cert_path, &self.key_path).await?;
let mut guard = self.cert_key.write().await;
*guard = cert_key;
}
}
while (rx.recv().await).is_ok() {
warn!("TLS cert-key reload");
let cert_key = load_cert_key(&self.cert_path, &self.key_path).await?;
let mut guard = self.cert_key.write().await;
*guard = cert_key;
}
Ok(())
}
Expand Down
24 changes: 13 additions & 11 deletions tuic-server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::{
};

use educe::Educe;
use notify::{Event, RecommendedWatcher, Watcher};
use notify::{EventKind, RecommendedWatcher, Watcher};
use serde::{Deserialize, Serialize};
use tokio::sync::mpsc::{Receiver, channel};
use tokio::sync::broadcast;

#[derive(Clone, Copy)]
pub enum UdpRelayMode {
Expand Down Expand Up @@ -70,16 +70,18 @@ where
}
}

pub async fn async_watcher() -> notify::Result<(RecommendedWatcher, Receiver<notify::Result<Event>>)>
{
let (tx, rx) = channel(1);

pub async fn async_watcher() -> eyre::Result<(RecommendedWatcher, broadcast::Receiver<()>)> {
let (tx, rx) = broadcast::channel(1);
let watcher = RecommendedWatcher::new(
move |res| {
let tx = tx.clone();
tokio::task::spawn(async move {
tx.send(res).await.unwrap();
});
move |res: Result<notify::Event, notify::Error>| {
if let Ok(event) = res {
match event.kind {
EventKind::Create(_) | EventKind::Modify(_) => {
tx.send(()).unwrap();
}
_ => {}
}
}
},
notify::Config::default(),
)?;
Expand Down

0 comments on commit 611d1d3

Please sign in to comment.