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

Function find_proxy_command_match

crates/openshell-core/src/forward.rs:236–281  ·  view source on GitHub ↗
(args: &[&str], sandbox_id: Option<&str>)

Source from the content-addressed store, hash-verified

234}
235
236fn find_proxy_command_match(args: &[&str], sandbox_id: Option<&str>) -> Option<ProxyCommandMatch> {
237 for (index, arg) in args.iter().enumerate().skip(1) {
238 let Some(prefix_has_no_command) = parse_ssh_prefix_before_proxy(args, index) else {
239 continue;
240 };
241 if !is_ssh_proxy_arg(arg) || !proxy_command_option_present(args, index) {
242 continue;
243 }
244
245 let mut current = index + 1;
246 let mut sandbox_id_requirement_met = sandbox_id.is_none();
247 while current < args.len() {
248 let arg = args[current];
249 if is_outer_ssh_option_start(arg) || arg == "sandbox" {
250 return Some(ProxyCommandMatch {
251 outer_ssh_args_start: current,
252 sandbox_id_requirement_met,
253 prefix_has_no_command,
254 });
255 }
256
257 if let Some(value) = arg.strip_prefix("--sandbox-id=") {
258 sandbox_id_requirement_met |= sandbox_id == Some(value);
259 current += 1;
260 continue;
261 }
262 if arg == "--sandbox-id" {
263 let value = args.get(current + 1)?;
264 sandbox_id_requirement_met |= sandbox_id == Some(*value);
265 current += 2;
266 continue;
267 }
268 if proxy_option_takes_value(arg) {
269 current += 2;
270 continue;
271 }
272 if proxy_option_has_inline_value(arg) {
273 current += 1;
274 continue;
275 }
276
277 return None;
278 }
279 }
280 None
281}
282
283fn is_ssh_proxy_arg(arg: &str) -> bool {
284 arg == "ssh-proxy" || arg.rsplit('/').next() == Some("ssh-proxy")

Callers 1

args_match_ssh_forwardFunction · 0.85

Calls 8

is_ssh_proxy_argFunction · 0.85
proxy_option_takes_valueFunction · 0.85
lenMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected