diff --git a/src/ipblc.rs b/src/ipblc.rs index 0fe28a4..6c7413a 100644 --- a/src/ipblc.rs +++ b/src/ipblc.rs @@ -64,9 +64,8 @@ pub async fn run() { ipevent = ipeventrx.recv() => { let received_ip = ipevent.unwrap(); - let mut ctx = ctxclone.write().await; - if received_ip.msgtype == "bootstrap".to_string() { + let mut ctx = ctxclone.write().await; for ip_to_send in ctx.get_blocklist_toblock().await { let ipe = IpEvent{ msgtype: String::from("init"), @@ -84,8 +83,13 @@ pub async fn run() { continue } - // refresh context blocklist - let filtered_ipevent = ctx.update_blocklist(&received_ip).await; + let (filtered_ipevent,server); + { + let mut ctx = ctxclone.write().await; + // refresh context blocklist + filtered_ipevent = ctx.update_blocklist(&received_ip).await; + server = ctx.flags.server.clone(); + } // send ip list to api and ws sockets if let Some(ipevent) = filtered_ipevent { @@ -97,9 +101,8 @@ pub async fn run() { hostname: gethostname(true), ipdata: ipevent.ipdata, }; - send_to_ipbl_api(&ctx.flags.server, &ipe).await; + send_to_ipbl_api(&server, &ipe).await; let status = send_to_ipbl_websocket(&mut wssocketrr, &ipe).await; - drop(ctx); if !status { wssocketrr = websocketreqrep(&ctxwsrr).await; continue;