for testing

This commit is contained in:
Paul 2022-09-18 00:50:51 +02:00
parent 759928a425
commit 424b1457a6
2 changed files with 7 additions and 5 deletions

View File

@ -79,9 +79,9 @@ pub async fn process(ctx: &Arc<Mutex<Context>>) {
ctx.gc_blocklist().await;
// send ip list to ws and zmq sockets
if let Some(ip) = filtered_ip {
send_to_ipbl_ws(&ctx, &ip, &mut ret).await;
send_to_ipbl_zmq(&reqsocket, &ip).await;
if let Some(mut ip) = filtered_ip {
send_to_ipbl_ws(&ctx, &mut ip, &mut ret).await;
send_to_ipbl_zmq(&reqsocket, &mut ip).await;
}
// apply firewall blocking

View File

@ -23,8 +23,9 @@ impl std::fmt::Debug for FileEvent {
}
}
async fn send_to_ipbl_zmq(reqsocket: &zmq::Socket, ip: &IpData) {
async fn send_to_ipbl_zmq(reqsocket: &zmq::Socket, ip: &mut IpData) {
let msg = format!("{value}", value = serde_json::to_string(&ip).unwrap());
ip.mode = "zmq".to_string();
match reqsocket.send(&msg, 0) {
Ok(_) => {}
Err(e) => {
@ -44,8 +45,9 @@ async fn send_to_ipbl_zmq(reqsocket: &zmq::Socket, ip: &IpData) {
};
}
async fn send_to_ipbl_ws(ctx: &Context, ip: &IpData, ret: &mut Vec<String>) {
async fn send_to_ipbl_ws(ctx: &Context, ip: &mut IpData, ret: &mut Vec<String>) {
ret.push(format!("host: {hostname}", hostname = ctx.hostname));
ip.mode = "zmq".to_string();
loop {
match push_ip(&ctx, &ip, ret).await {
Ok(_) => {