1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-15 19:26:58 +02:00

fix(ipc): message size limited to 1024 bytes

Fixes #1065
This commit is contained in:
Jake Stanger 2025-06-24 23:04:24 +01:00
commit c4f5485d53
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
3 changed files with 33 additions and 17 deletions

View file

@ -2,7 +2,7 @@ use super::Ipc;
use crate::ipc::{Command, Response};
use color_eyre::Result;
use color_eyre::{Help, Report};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::net::UnixStream;
impl Ipc {
@ -16,18 +16,20 @@ impl Ipc {
.suggestion("Is Ironbar running?")),
}?;
let write_buffer = serde_json::to_vec(&command)?;
let mut write_buffer = serde_json::to_vec(&command)?;
if debug {
eprintln!("REQUEST JSON: {}", serde_json::to_string(&command)?);
}
write_buffer.push(b'\n');
stream.write_all(&write_buffer).await?;
let mut read_buffer = vec![0; 1024];
let bytes = stream.read(&mut read_buffer).await?;
let mut read_buffer = String::new();
let mut reader = BufReader::new(stream);
let bytes = reader.read_line(&mut read_buffer).await?;
let response = serde_json::from_slice(&read_buffer[..bytes])?;
let response = serde_json::from_str(&read_buffer[..bytes])?;
Ok(response)
}
}