mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_udp: mio: update access list on SIGHUP instead of regularly
This commit is contained in:
parent
e332ac3052
commit
d922e5e680
5 changed files with 92 additions and 46 deletions
|
|
@ -16,6 +16,7 @@ arc-swap = "1"
|
|||
hashbrown = "0.11.2"
|
||||
hex = "0.4"
|
||||
indexmap = "1"
|
||||
log = "0.4"
|
||||
privdrop = "0.5"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -75,17 +75,31 @@ impl AccessList {
|
|||
}
|
||||
|
||||
pub trait AccessListQuery {
|
||||
fn update_from_path(&self, path: &PathBuf) -> anyhow::Result<()>;
|
||||
fn update(&self, config: &AccessListConfig);
|
||||
fn allows(&self, list_mode: AccessListMode, info_hash_bytes: &[u8; 20]) -> bool;
|
||||
}
|
||||
|
||||
pub type AccessListArcSwap = ArcSwap<AccessList>;
|
||||
|
||||
impl AccessListQuery for AccessListArcSwap {
|
||||
fn update_from_path(&self, path: &PathBuf) -> anyhow::Result<()> {
|
||||
self.store(Arc::new(AccessList::create_from_path(path)?));
|
||||
|
||||
Ok(())
|
||||
fn update(&self, config: &AccessListConfig) {
|
||||
match config.mode {
|
||||
AccessListMode::White | AccessListMode::Black => {
|
||||
match AccessList::create_from_path(&config.path) {
|
||||
Ok(new) => {
|
||||
self.store(Arc::new(new));
|
||||
}
|
||||
Err(err) => {
|
||||
::log::error!("Updating access list failed: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
AccessListMode::Off => {
|
||||
::log::error!(
|
||||
"AccessListQuery::update_from_path called, but AccessListMode is Off"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn allows(&self, mode: AccessListMode, info_hash_bytes: &[u8; 20]) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue