Patch
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user