for testing

This commit is contained in:
Paul 2022-09-18 00:00:25 +02:00
parent c2eff44009
commit 3e2fc8ddde

View File

@ -168,24 +168,29 @@ impl Context {
}
pub async fn update_blocklist(&mut self, ipdata: &IpData) -> Option<IpData> {
if self.blocklist.contains_key(&ipdata.ip) {
if self.blocklist.contains_key(&ipdata.ip)
&& self.hostname == ipdata.hostname
&& ipdata.src == "file"
{
let mut block = self.blocklist.get_mut(&ipdata.ip).unwrap();
block.tryfail += 1;
let set = self.cfg.sets.get(&ipdata.src.to_string()).unwrap();
match self.cfg.sets.get(&ipdata.src) {
Some(set) => {
if block.tryfail >= set.tryfail {
return Some(block.ipdata.clone());
}
return None;
} else {
}
None => {}
}
}
if !self.blocklist.contains_key(&ipdata.ip) {
let mut tryfail = 0;
let mut send = false;
let starttime: DateTime<FixedOffset> =
DateTime::parse_from_rfc3339(ipdata.date.as_str()).unwrap();
match self.cfg.sets.get(&ipdata.src) {
Some(set) => {
let starttime: DateTime<FixedOffset> =
DateTime::parse_from_rfc3339(ipdata.date.as_str()).unwrap();
if ipdata.mode == "zmq".to_string() {
tryfail = 100;
send = true;
}
self.blocklist.insert(
ipdata.ip.to_string(),
@ -199,11 +204,8 @@ impl Context {
}
None => {}
}
match send {
true => return Some(ipdata.clone()),
false => return None,
}
}
};
None
}
pub async fn gc_blocklist(&mut self) -> Vec<IpData> {