updated bootstrap procedure
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
e8c7172219
commit
df2668cdc1
@ -158,12 +158,16 @@ impl Context {
|
||||
let mut res: Vec<IpData> = vec![];
|
||||
let now: DateTime<Local> = Local::now().trunc_subsecs(0);
|
||||
for (_, block) in self.blocklist.iter_mut() {
|
||||
let set = self.cfg.sets.get(&block.ipdata.src.to_string()).unwrap();
|
||||
if block.tryfail >= set.tryfail {
|
||||
res.push(block.ipdata.clone());
|
||||
if block.tryfail == set.tryfail {
|
||||
block.starttime = DateTime::from(now);
|
||||
match self.cfg.sets.get(&block.ipdata.src) {
|
||||
Some(set) => {
|
||||
if block.tryfail >= set.tryfail {
|
||||
res.push(block.ipdata.clone());
|
||||
if block.tryfail == set.tryfail {
|
||||
block.starttime = DateTime::from(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
res
|
||||
|
11
src/ipblc.rs
11
src/ipblc.rs
@ -49,8 +49,8 @@ pub async fn run() {
|
||||
compare_files_changes(&ctxclone, &mut blrx, &ipeventtx).await;
|
||||
});
|
||||
|
||||
let ipevent_init = IpEvent {
|
||||
msgtype: String::from("init"),
|
||||
let ipevent_bootstrap = IpEvent {
|
||||
msgtype: String::from("bootstrap"),
|
||||
ipdata: IpData {
|
||||
ip: "".to_string(),
|
||||
src: "".to_string(),
|
||||
@ -59,7 +59,7 @@ pub async fn run() {
|
||||
mode: "".to_string(),
|
||||
},
|
||||
};
|
||||
send_to_ipbl_zmq(&zmqreqsocket, &ipevent_init).await;
|
||||
send_to_ipbl_zmq(&zmqreqsocket, &ipevent_bootstrap).await;
|
||||
|
||||
loop {
|
||||
let mut ret: Vec<String> = Vec::new();
|
||||
@ -77,7 +77,7 @@ pub async fn run() {
|
||||
|
||||
let mut ctx = ctxclone.write().await;
|
||||
|
||||
if received_ip.ipdata.ip == "".to_string() && received_ip.msgtype == "init".to_string() {
|
||||
if received_ip.msgtype == "bootstrap".to_string() {
|
||||
for ip_to_send in ctx.get_blocklist_toblock().await {
|
||||
let event = IpEvent{
|
||||
msgtype: String::from("init"),
|
||||
@ -85,7 +85,6 @@ pub async fn run() {
|
||||
};
|
||||
send_to_ipbl_zmq(&zmqreqsocket, &event).await;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// refresh context blocklist
|
||||
@ -242,7 +241,7 @@ async fn compare_files_changes(
|
||||
}
|
||||
for ip in iplist {
|
||||
let ipevent = IpEvent {
|
||||
msgtype: String::from("file"),
|
||||
msgtype: String::from("add"),
|
||||
ipdata: ip,
|
||||
};
|
||||
ipeventtx.send(ipevent).await.unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user