mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
aquatic_udp: glommio: move update_access_list to new common.rs
This commit is contained in:
parent
bfcdc1c842
commit
02889e1bb8
3 changed files with 38 additions and 27 deletions
35
aquatic_udp/src/lib/glommio/common.rs
Normal file
35
aquatic_udp/src/lib/glommio/common.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use futures_lite::{AsyncBufReadExt};
|
||||
use glommio::io::{BufferedFile, StreamReaderBuilder};
|
||||
use glommio::{prelude::*};
|
||||
|
||||
use crate::common::*;
|
||||
use crate::config::Config;
|
||||
|
||||
pub async fn update_access_list(
|
||||
config: Config,
|
||||
access_list: Rc<RefCell<AccessList>>,
|
||||
){
|
||||
if config.access_list.mode.is_on(){
|
||||
let access_list_file = BufferedFile::open(config.access_list.path).await.unwrap();
|
||||
|
||||
let mut reader = StreamReaderBuilder::new(access_list_file).build();
|
||||
|
||||
loop {
|
||||
let mut buf = String::with_capacity(42);
|
||||
|
||||
match reader.read_line(&mut buf).await {
|
||||
Ok(_) => {
|
||||
access_list.borrow_mut().insert_from_line(&buf);
|
||||
},
|
||||
Err(err) => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
yield_if_needed().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue