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

Function relay_graphql

crates/openshell-supervisor-network/src/l7/relay.rs:1192–1392  ·  view source on GitHub ↗
(
    config: &L7EndpointConfig,
    engine: &TunnelPolicyEngine,
    client: &mut C,
    upstream: &mut U,
    ctx: &L7EvalContext,
)

Source from the content-addressed store, hash-verified

1190}
1191
1192async fn relay_graphql<C, U>(
1193 config: &L7EndpointConfig,
1194 engine: &TunnelPolicyEngine,
1195 client: &mut C,
1196 upstream: &mut U,
1197 ctx: &L7EvalContext,
1198) -> Result<()>
1199where
1200 C: AsyncRead + AsyncWrite + Unpin + Send,
1201 U: AsyncRead + AsyncWrite + Unpin + Send,
1202{
1203 loop {
1204 if close_if_stale(engine.generation_guard(), ctx) {
1205 return Ok(());
1206 }
1207
1208 let parsed = match crate::l7::graphql::parse_graphql_http_request(
1209 client,
1210 config.graphql_max_body_bytes,
1211 crate::l7::path::CanonicalizeOptions {
1212 allow_encoded_slash: config.allow_encoded_slash,
1213 ..Default::default()
1214 },
1215 )
1216 .await
1217 {
1218 Ok(Some(parsed)) => parsed,
1219 Ok(None) => return Ok(()),
1220 Err(e) => {
1221 if is_benign_connection_error(&e) {
1222 debug!(
1223 host = %ctx.host,
1224 port = ctx.port,
1225 error = %e,
1226 "GraphQL L7 connection closed"
1227 );
1228 } else {
1229 let detail =
1230 parse_rejection_detail(&e.to_string(), ParseRejectionMode::L7Endpoint);
1231 emit_parse_rejection(ctx, &detail, "l7-graphql");
1232 }
1233 return Ok(());
1234 }
1235 };
1236
1237 let req = parsed.request;
1238 let graphql_info = parsed.info;
1239
1240 if deny_h2c_upgrade_if_requested(&req, config, ctx, client).await? {
1241 return Ok(());
1242 }
1243
1244 if close_if_stale(engine.generation_guard(), ctx) {
1245 return Ok(());
1246 }
1247
1248 let (eval_target, redacted_target) = if let Some(ref resolver) = ctx.secret_resolver {
1249 match secrets::rewrite_target_for_eval(&req.target, resolver) {

Callers 1

relay_with_inspectionFunction · 0.85

Calls 15

close_if_staleFunction · 0.85
parse_rejection_detailFunction · 0.85
emit_parse_rejectionFunction · 0.85
rewrite_target_for_evalFunction · 0.85
evaluate_l7_requestFunction · 0.85
handle_upgradeFunction · 0.85
generation_guardMethod · 0.80
messageMethod · 0.80

Tested by

no test coverage detected