updated monitoring socket
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
df9d19f616
commit
43d3137dd2
@ -24,34 +24,26 @@ pub async fn apiserver(ctxarc: &Arc<RwLock<Context>>) -> io::Result<()> {
|
||||
loop {
|
||||
//apitx.send(String::from("")).await.unwrap();
|
||||
match listener.accept().await {
|
||||
Ok((stream, _addr)) => {
|
||||
Ok((mut stream, _addr)) => {
|
||||
//let mut buf = [0; 1024];
|
||||
let data;
|
||||
{
|
||||
let ctx = ctxarc.read().await;
|
||||
data = serde_json::to_string(&ctx.blocklist);
|
||||
data = serde_json::to_string(&ctx.blocklist).unwrap();
|
||||
}
|
||||
|
||||
match data {
|
||||
Ok(dt) => {
|
||||
let (_reader, mut writer) = stream.into_split();
|
||||
match writer.write_all(format!("{dt}").as_bytes()).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
println!("{err}");
|
||||
}
|
||||
}
|
||||
stream
|
||||
.write_all(format!("{data}\n").as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
stream.flush().await.unwrap();
|
||||
stream.shutdown().await.unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
println!("unable to serialize data: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
println!("couldn't get client: {}", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user