Merge pull request 'fix on filter' (#7) from ipblc-filter-fix into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #7
This commit is contained in:
commit
af7f1a24a7
@ -89,7 +89,7 @@ impl Display for IpData {
|
||||
}
|
||||
|
||||
pub fn filter(
|
||||
lines: Box<dyn Read>,
|
||||
reader: Box<dyn Read>,
|
||||
iplist: &mut Vec<IpData>,
|
||||
trustnets: &Vec<IpNet>,
|
||||
regex: &Regex,
|
||||
@ -98,7 +98,8 @@ pub fn filter(
|
||||
) -> isize {
|
||||
let mut ips = 0;
|
||||
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 regex.is_match(l.as_str()) {
|
||||
let s_ipaddr: String;
|
||||
|
@ -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) {
|
||||
let currentlen = match std::fs::metadata(&path.to_string()) {
|
||||
Ok(u) => u.len().clone(),
|
||||
Ok(u) => u.len(),
|
||||
Err(_) => 0u64,
|
||||
};
|
||||
let lastlen = match w.insert(path.to_string(), currentlen) {
|
||||
Some(u) => u,
|
||||
None => 0u64,
|
||||
None => currentlen,
|
||||
};
|
||||
(lastlen, lastlen != currentlen)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user