fix on filter #7

Merged
paulbsd merged 1 commits from ipblc-filter-fix into master 2023-11-04 12:47:05 +01:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 4c697c2e0c - Show all commits

View File

@ -89,7 +89,7 @@ impl Display for IpData {
} }
pub fn filter( pub fn filter(
lines: Box<dyn Read>, reader: Box<dyn Read>,
iplist: &mut Vec<IpData>, iplist: &mut Vec<IpData>,
trustnets: &Vec<IpNet>, trustnets: &Vec<IpNet>,
regex: &Regex, regex: &Regex,
@ -98,7 +98,8 @@ pub fn filter(
) -> isize { ) -> isize {
let mut ips = 0; let mut ips = 0;
let hostname = gethostname(true); let hostname = gethostname(true);
for line in BufReader::new(lines).lines() { let lines = BufReader::new(reader).lines();
for line in lines.into_iter() {
if let Ok(l) = line { if let Ok(l) = line {
if regex.is_match(l.as_str()) { if regex.is_match(l.as_str()) {
let s_ipaddr: String; let s_ipaddr: String;

View File

@ -181,12 +181,12 @@ async fn watchfiles(inoarc: Arc<RwLock<Inotify>>) -> Receiver<FileEvent> {
async fn get_last_file_size(w: &mut HashMap<String, u64>, path: &str) -> (u64, bool) { async fn get_last_file_size(w: &mut HashMap<String, u64>, path: &str) -> (u64, bool) {
let currentlen = match std::fs::metadata(&path.to_string()) { let currentlen = match std::fs::metadata(&path.to_string()) {
Ok(u) => u.len().clone(), Ok(u) => u.len(),
Err(_) => 0u64, Err(_) => 0u64,
}; };
let lastlen = match w.insert(path.to_string(), currentlen) { let lastlen = match w.insert(path.to_string(), currentlen) {
Some(u) => u, Some(u) => u,
None => 0u64, None => currentlen,
}; };
(lastlen, lastlen != currentlen) (lastlen, lastlen != currentlen)
} }