MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / register_cvm

Method register_cvm

gateway/src/main_service.rs:1434–1476  ·  view source on GitHub ↗
(self, request: RegisterCvmRequest)

Source from the content-addressed store, hash-verified

1432
1433impl GatewayRpc for RpcHandler {
1434 async fn register_cvm(self, request: RegisterCvmRequest) -> Result<RegisterCvmResponse> {
1435 let app_info = match self.remote_app_info {
1436 Some(app_info) => app_info,
1437 None => {
1438 let Some(ra) = &self.attestation else {
1439 bail!("neither app-info nor attestation provided");
1440 };
1441 ra.decode_app_info(false)
1442 .context("failed to decode app-info from attestation")?
1443 }
1444 };
1445 self.state
1446 .auth_client
1447 .ensure_app_authorized(&app_info)
1448 .await
1449 .context("App authorization failed")?;
1450 let app_id = hex::encode(&app_info.app_id);
1451 let instance_id = hex::encode(&app_info.instance_id);
1452 let compose_hash = hex::encode(&app_info.compose_hash);
1453 let port_policy = request.port_policy.map(|p| {
1454 let ports = p
1455 .ports
1456 .into_iter()
1457 .filter_map(|attr| {
1458 // Wire format is uint32 to avoid varint shenanigans, but valid TCP
1459 // ports fit in u16. Drop out-of-range entries instead of truncating.
1460 let port = u16::try_from(attr.port).ok()?;
1461 Some((port, crate::kv::PortFlags { pp: attr.pp }))
1462 })
1463 .collect();
1464 PortPolicy {
1465 ports,
1466 restrict_mode: p.restrict_mode,
1467 }
1468 });
1469 self.state.do_register_cvm(
1470 &app_id,
1471 &instance_id,
1472 &request.client_public_key,
1473 &compose_hash,
1474 port_policy,
1475 )
1476 }
1477
1478 async fn acme_info(self) -> Result<AcmeInfoResponse> {
1479 self.state.acme_info(None)

Callers

nothing calls this directly

Calls 5

encodeFunction · 0.85
decode_app_infoMethod · 0.80
ensure_app_authorizedMethod · 0.80
into_iterMethod · 0.80
do_register_cvmMethod · 0.80

Tested by

no test coverage detected