Scope stream ICE candidates to the negotiated transport
This commit is contained in:
1 parent
1fe05c06fe
commit
dc3e596625
10 files changed
+583
-48
No files matched your search
+22
-6
@@ -636,6 +636,11 @@ pub fn validate_command(mut command: Command) -> Result<ValidatedCommand, ErrorO
|
||||
}
|
||||
Command::SetTransmit { vad } => crate::voice_dsp::validate_transmit(*vad)?,
|
||||
Command::SetLocalVolumes(a) => crate::voice_dsp::validate_local_volumes(a)?,
|
||||
Command::StreamList { client_id: Some(0) } | Command::StreamJoin { client_id: 0, .. }
|
||||
| Command::StreamSignal { client_id: 0, .. } | Command::StreamLeave { client_id: 0, .. }
|
||||
| Command::StreamRespond { client_id: 0, .. } | Command::StreamRemove { client_id: 0, .. } => {
|
||||
return Err(bad("client_id must be positive"));
|
||||
}
|
||||
Command::StreamJoin { stream_id, message, .. } => {
|
||||
check_stream_id(stream_id)?;
|
||||
if message.as_deref().is_some_and(|s| !stream_text(s, 0, 200, false)) { return Err(bad("invalid stream join message")); }
|
||||
@@ -658,18 +663,15 @@ pub fn validate_command(mut command: Command) -> Result<ValidatedCommand, ErrorO
|
||||
return Err(bad("invalid stream metadata (only P2P is supported)"));
|
||||
}
|
||||
}
|
||||
Command::StreamRespond { stream_id, client_id, decision, offer, message } => {
|
||||
Command::StreamRespond { stream_id, decision, offer, message, .. } => {
|
||||
check_stream_id(stream_id)?;
|
||||
check_text("message", message, 200, true)?;
|
||||
if *client_id == 0 || *decision == offer.is_empty() || offer.len() > 60000
|
||||
if *decision == offer.is_empty() || offer.len() > 60000
|
||||
|| offer.chars().any(|c| c.is_control() && !matches!(c, '\r' | '\n' | '\t')) || message.chars().any(char::is_control) {
|
||||
return Err(bad("invalid stream join response"));
|
||||
}
|
||||
}
|
||||
Command::StreamRemove { stream_id, client_id } => {
|
||||
check_stream_id(stream_id)?;
|
||||
if *client_id == 0 { return Err(bad("client_id must be nonzero")); }
|
||||
}
|
||||
Command::StreamRemove { stream_id, .. } => check_stream_id(stream_id)?,
|
||||
Command::FetchIcon { icon_id: 0 } => return Err(bad("icon_id 0 means no icon")),
|
||||
Command::ClientContext(a) => crate::menu::validate_target(a)?,
|
||||
Command::ClientAction(a) => crate::menu::validate_action(a)?,
|
||||
@@ -875,6 +877,20 @@ mod tests {
|
||||
assert!(matches!(cmd.into_inner(), Command::SendText { expected_channel_id: Some(7), .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_operations_reject_zero_client_at_the_shared_boundary() {
|
||||
for cmd in [Command::StreamList { client_id: Some(0) },
|
||||
Command::StreamJoin { stream_id: "s1".into(), client_id: 0, message: None },
|
||||
Command::StreamLeave { stream_id: "s1".into(), client_id: 0 },
|
||||
Command::StreamSignal { stream_id: "s1".into(), client_id: 0, json: r#"{"cmd":"answer","args":{"answer":"v=0"}}"#.into() },
|
||||
Command::StreamRemove { stream_id: "s1".into(), client_id: 0 },
|
||||
Command::StreamRespond { stream_id: "s1".into(), client_id: 0, decision: false, offer: String::new(), message: String::new() }] {
|
||||
assert_bad(cmd);
|
||||
}
|
||||
assert!(validate_command(Command::StreamList { client_id: None }).is_ok());
|
||||
assert!(matches!(parse_line(r#"{"id":"z","cmd":"stream_signal","args":{"stream_id":"s1","client_id":0,"json":{"cmd":"answer","args":{"answer":"v=0"}}}}"#), Input::Invalid { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_signaling_checks_objects_and_compact_byte_limit() {
|
||||
let signal = |json| Command::StreamSignal { stream_id: "s1".into(), client_id: 7, json };
|
||||
|
||||
Reference in new issue
Block a user