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,7 +158,8 @@ impl Context {
|
|||||||
let mut res: Vec<IpData> = vec![];
|
let mut res: Vec<IpData> = vec![];
|
||||||
let now: DateTime<Local> = Local::now().trunc_subsecs(0);
|
let now: DateTime<Local> = Local::now().trunc_subsecs(0);
|
||||||
for (_, block) in self.blocklist.iter_mut() {
|
for (_, block) in self.blocklist.iter_mut() {
|
||||||
let set = self.cfg.sets.get(&block.ipdata.src.to_string()).unwrap();
|
match self.cfg.sets.get(&block.ipdata.src) {
|
||||||
|
Some(set) => {
|
||||||
if block.tryfail >= set.tryfail {
|
if block.tryfail >= set.tryfail {
|
||||||
res.push(block.ipdata.clone());
|
res.push(block.ipdata.clone());
|
||||||
if block.tryfail == set.tryfail {
|
if block.tryfail == set.tryfail {
|
||||||
@ -166,6 +167,9 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
res
|
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;
|
compare_files_changes(&ctxclone, &mut blrx, &ipeventtx).await;
|
||||||
});
|
});
|
||||||
|
|
||||||
let ipevent_init = IpEvent {
|
let ipevent_bootstrap = IpEvent {
|
||||||
msgtype: String::from("init"),
|
msgtype: String::from("bootstrap"),
|
||||||
ipdata: IpData {
|
ipdata: IpData {
|
||||||
ip: "".to_string(),
|
ip: "".to_string(),
|
||||||
src: "".to_string(),
|
src: "".to_string(),
|
||||||
@ -59,7 +59,7 @@ pub async fn run() {
|
|||||||
mode: "".to_string(),
|
mode: "".to_string(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
send_to_ipbl_zmq(&zmqreqsocket, &ipevent_init).await;
|
send_to_ipbl_zmq(&zmqreqsocket, &ipevent_bootstrap).await;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut ret: Vec<String> = Vec::new();
|
let mut ret: Vec<String> = Vec::new();
|
||||||
@ -77,7 +77,7 @@ pub async fn run() {
|
|||||||
|
|
||||||
let mut ctx = ctxclone.write().await;
|
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 {
|
for ip_to_send in ctx.get_blocklist_toblock().await {
|
||||||
let event = IpEvent{
|
let event = IpEvent{
|
||||||
msgtype: String::from("init"),
|
msgtype: String::from("init"),
|
||||||
@ -85,7 +85,6 @@ pub async fn run() {
|
|||||||
};
|
};
|
||||||
send_to_ipbl_zmq(&zmqreqsocket, &event).await;
|
send_to_ipbl_zmq(&zmqreqsocket, &event).await;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh context blocklist
|
// refresh context blocklist
|
||||||
@ -242,7 +241,7 @@ async fn compare_files_changes(
|
|||||||
}
|
}
|
||||||
for ip in iplist {
|
for ip in iplist {
|
||||||
let ipevent = IpEvent {
|
let ipevent = IpEvent {
|
||||||
msgtype: String::from("file"),
|
msgtype: String::from("add"),
|
||||||
ipdata: ip,
|
ipdata: ip,
|
||||||
};
|
};
|
||||||
ipeventtx.send(ipevent).await.unwrap();
|
ipeventtx.send(ipevent).await.unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user