MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / outer_ssh_forward_matches

Function outer_ssh_forward_matches

crates/openshell-core/src/forward.rs:337–384  ·  view source on GitHub ↗
(args: &[&str], port: u16, prefix_has_no_command: bool)

Source from the content-addressed store, hash-verified

335}
336
337fn outer_ssh_forward_matches(args: &[&str], port: u16, prefix_has_no_command: bool) -> bool {
338 let Some(forward_args) = args.strip_suffix(&["sandbox"]) else {
339 return false;
340 };
341 let mut saw_no_command = prefix_has_no_command;
342 let mut saw_forward = false;
343 let mut current = 0;
344
345 while current < forward_args.len() {
346 let arg = forward_args[current];
347 match arg {
348 "-N" => {
349 saw_no_command = true;
350 current += 1;
351 }
352 "-f" | "-T" | "-tt" => {
353 current += 1;
354 }
355 "-o" => {
356 if current + 1 >= forward_args.len() {
357 return false;
358 }
359 current += 2;
360 }
361 "-L" => {
362 let Some(candidate) = forward_args.get(current + 1) else {
363 return false;
364 };
365 saw_forward |= ssh_forward_arg_matches_openshell_loopback_port(candidate, port);
366 current += 2;
367 }
368 _ if arg.starts_with("-L") => {
369 let Some(candidate) = arg.strip_prefix("-L").filter(|value| !value.is_empty())
370 else {
371 return false;
372 };
373 saw_forward |= ssh_forward_arg_matches_openshell_loopback_port(candidate, port);
374 current += 1;
375 }
376 _ if arg.starts_with("-o") || arg.starts_with("-v") => {
377 current += 1;
378 }
379 _ => return false,
380 }
381 }
382
383 saw_no_command && saw_forward
384}
385
386fn expected_sandbox_id_from_record(record: &ForwardPidRecord) -> Option<&str> {
387 // Legacy one-field PID files are cleanup records, not signal authority.

Callers 1

args_match_ssh_forwardFunction · 0.85

Calls 4

lenMethod · 0.80
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected