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

Function validate_tcp_forward_init

crates/openshell-server/src/grpc/sandbox.rs:1099–1116  ·  view source on GitHub ↗
(init: &TcpForwardInit)

Source from the content-addressed store, hash-verified

1097}
1098
1099fn validate_tcp_forward_init(init: &TcpForwardInit) -> Result<relay_open::Target, Status> {
1100 if init.sandbox_id.is_empty() {
1101 return Err(Status::invalid_argument("sandbox_id is required"));
1102 }
1103
1104 if let Some(target) = init.target.as_ref() {
1105 return match target {
1106 tcp_forward_init::Target::Ssh(_) => {
1107 Ok(relay_open::Target::Ssh(SshRelayTarget::default()))
1108 }
1109 tcp_forward_init::Target::Tcp(target) => Ok(relay_open::Target::Tcp(
1110 validate_tcp_forward_target(target)?,
1111 )),
1112 };
1113 }
1114
1115 Err(Status::invalid_argument("tcp forward target is required"))
1116}
1117
1118fn validate_tcp_forward_target(target: &TcpRelayTarget) -> Result<TcpRelayTarget, Status> {
1119 if target.port == 0 || target.port > u32::from(u16::MAX) {

Calls 2

is_emptyMethod · 0.45