mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 09:09:17 +00:00
move dirty to crate::utils
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
use tokio::sync::watch;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DirtyFlag {
|
||||
tx: watch::Sender<bool>,
|
||||
rx: watch::Receiver<bool>,
|
||||
}
|
||||
|
||||
impl DirtyFlag {
|
||||
pub fn new(value: bool) -> Self {
|
||||
let (tx, rx) = watch::channel(value);
|
||||
Self { tx, rx }
|
||||
}
|
||||
|
||||
pub fn mark(&self) {
|
||||
self.tx.send(true).ok();
|
||||
}
|
||||
|
||||
pub fn peek(&self) -> bool {
|
||||
*self.tx.borrow()
|
||||
}
|
||||
|
||||
pub fn reset(&self) -> bool {
|
||||
self.tx.send_replace(false)
|
||||
}
|
||||
|
||||
pub async fn wait(&self) {
|
||||
let mut rx = self.rx.clone();
|
||||
let _ = rx.wait_for(|v| *v).await;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DirtyFlag {
|
||||
fn default() -> Self {
|
||||
Self::new(true)
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ use hickory_proto::rr::LowerName;
|
||||
use idna::AsciiDenyList;
|
||||
|
||||
pub mod addr;
|
||||
pub mod dirty;
|
||||
pub mod response;
|
||||
pub mod zone_handler;
|
||||
|
||||
@@ -37,7 +36,7 @@ pub fn parse(name: &str) -> LowerName {
|
||||
name
|
||||
} else {
|
||||
let sanitized = sanitize(name);
|
||||
tracing::debug!("invalid hostname: {}, sanitized to: {}", name, sanitized);
|
||||
tracing::debug!("invalid name: {}, sanitized to: {}", name, sanitized);
|
||||
sanitized.parse().unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user