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

Function validate_tcp_target_parts

crates/openshell-server/src/grpc/sandbox.rs:1131–1147  ·  view source on GitHub ↗
(host: &str, _port: u32)

Source from the content-addressed store, hash-verified

1129}
1130
1131fn validate_tcp_target_parts(host: &str, _port: u32) -> Result<String, Status> {
1132 if host.is_empty() {
1133 return Err(Status::invalid_argument("tcp target host is required"));
1134 }
1135 if host.eq_ignore_ascii_case("localhost") {
1136 return Ok("127.0.0.1".to_string());
1137 }
1138
1139 let ip: IpAddr = host
1140 .parse()
1141 .map_err(|_| Status::invalid_argument("tcp target host must be loopback"))?;
1142 if ip.is_loopback() {
1143 Ok(ip.to_string())
1144 } else {
1145 Err(Status::invalid_argument("tcp target host must be loopback"))
1146 }
1147}
1148
1149async fn bridge_forward_tcp_stream(
1150 mut inbound: tonic::Streaming<TcpForwardFrame>,

Callers 1

Calls 2

is_emptyMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected