This commit is contained in:
pwn
2025-12-05 11:14:59 +03:00
parent 376d0fc8ad
commit b79ef3a3f3
8 changed files with 35 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ use std::time::Duration;
use tokio::{task, time};
const UDP_PORT: u16 = 5004;
const MAX_PATCH_SIZE: usize = 8 * 1024;
const PATCH_MAX_AGE: Duration = Duration::from_secs(30 * 60);
const CLEAN_INTERVAL: Duration = Duration::from_secs(10 * 60);
const SYSEX_TIMEOUT: Duration = Duration::from_millis(50);
@@ -56,6 +57,15 @@ async fn handle_sysex(
let response = match msg {
sysex::Request::Diag => sysex::Response::Diag,
sysex::Request::Put { data } => {
if data.len() > MAX_PATCH_SIZE {
let response = sysex::Response::Error(format!(
"Patch too large ({} bytes > {MAX_PATCH_SIZE})",
data.len()
));
state.udp_sock.send_to(&response.encode(), addr).await?;
return Ok(());
}
let lua_dsp = String::from_utf8_lossy(&data).to_string();
if let Err(error) =
run_blocking_with_timeout(SYSEX_TIMEOUT, move || lua_sandbox::validate(&lua_dsp))