refactor: update detee-shared dependency and adjust imports to use sgx module

This commit is contained in:
Noor 2025-02-17 11:38:57 +05:30
parent 784878d0a1
commit 2cada47d24
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
4 changed files with 35 additions and 26 deletions

2
Cargo.lock generated

@ -418,7 +418,7 @@ dependencies = [
[[package]] [[package]]
name = "detee-shared" name = "detee-shared"
version = "0.1.0" version = "0.1.0"
source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared?branch=stable_01#f2bc29149e32df09508519f3f88cdf880728e6dd" source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared?branch=stable_01#ee592c71d6c760ef05ef4f8b5c88b31fcbaf52aa"
dependencies = [ dependencies = [
"base64", "base64",
"prost", "prost",

@ -1,18 +1,18 @@
use crate::grpc::snp_proto::{self as grpc}; use crate::grpc::snp_proto::{self as grpc};
use chrono::Utc; use chrono::Utc;
use dashmap::DashMap; use dashmap::DashMap;
use detee_shared::pb::brain::DelAppReq; use detee_shared::sgx::pb::brain::DelAppReq;
use log::{debug, info, warn}; use log::{debug, info, warn};
use std::str::FromStr; use std::str::FromStr;
use std::sync::RwLock; use std::sync::RwLock;
use tokio::sync::mpsc::Sender; use tokio::sync::mpsc::Sender;
use tokio::sync::oneshot::Sender as OneshotSender; use tokio::sync::oneshot::Sender as OneshotSender;
use detee_shared::pb::brain::AppContract as AppContractPB; use detee_shared::sgx::pb::brain::AppContract as AppContractPB;
use detee_shared::pb::brain::BrainMessageApp; use detee_shared::sgx::pb::brain::BrainMessageApp;
use detee_shared::pb::brain::MappedPort; use detee_shared::sgx::pb::brain::MappedPort;
use detee_shared::pb::brain::NewAppReq; use detee_shared::sgx::pb::brain::NewAppReq;
use detee_shared::pb::brain::NewAppRes; use detee_shared::sgx::pb::brain::NewAppRes;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum Error { pub enum Error {
@ -833,9 +833,9 @@ impl BrainData {
req.node_pubkey, req.uuid req.node_pubkey, req.uuid
); );
let msg = BrainMessageApp { let msg = BrainMessageApp {
msg: Some(detee_shared::pb::brain::brain_message_app::Msg::NewAppReq( msg: Some(
req.clone(), detee_shared::sgx::pb::brain::brain_message_app::Msg::NewAppReq(req.clone()),
)), ),
}; };
if let Err(e) = app_daemon_tx.send(msg).await { if let Err(e) = app_daemon_tx.send(msg).await {
warn!( warn!(
@ -869,7 +869,9 @@ impl BrainData {
); );
let msg = BrainMessageApp { let msg = BrainMessageApp {
msg: Some( msg: Some(
detee_shared::pb::brain::brain_message_app::Msg::DeleteAppReq(req.clone()), detee_shared::sgx::pb::brain::brain_message_app::Msg::DeleteAppReq(
req.clone(),
),
), ),
}; };

@ -16,9 +16,9 @@ use tokio::sync::mpsc;
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt}; use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
use tonic::{Request, Response, Status, Streaming}; use tonic::{Request, Response, Status, Streaming};
use detee_shared::pb::brain::brain_app_cli_server::BrainAppCli; use detee_shared::sgx::pb::brain::brain_app_cli_server::BrainAppCli;
use detee_shared::pb::brain::brain_app_daemon_server::BrainAppDaemon; use detee_shared::sgx::pb::brain::brain_app_daemon_server::BrainAppDaemon;
use detee_shared::pb::brain::{ use detee_shared::sgx::pb::brain::{
AppContract, BrainMessageApp, DaemonMessageApp, DelAppReq, ListAppContractsReq, NewAppReq, AppContract, BrainMessageApp, DaemonMessageApp, DelAppReq, ListAppContractsReq, NewAppReq,
NewAppRes, RegisterAppNodeReq, NewAppRes, RegisterAppNodeReq,
}; };
@ -389,7 +389,7 @@ impl BrainAppCli for BrainAppCliMock {
async fn delete_app( async fn delete_app(
&self, &self,
req: tonic::Request<DelAppReq>, req: tonic::Request<DelAppReq>,
) -> Result<tonic::Response<detee_shared::pb::brain::Empty>, Status> { ) -> Result<tonic::Response<detee_shared::sgx::pb::brain::Empty>, Status> {
let req = req.into_inner(); let req = req.into_inner();
log::info!("deleting container: {}", req.uuid.clone()); log::info!("deleting container: {}", req.uuid.clone());
if let Err(er) = self.data.send_del_container_req(req).await { if let Err(er) = self.data.send_del_container_req(req).await {
@ -397,7 +397,7 @@ impl BrainAppCli for BrainAppCliMock {
return Err(Status::not_found("Could not find container")); return Err(Status::not_found("Could not find container"));
}; };
Ok(Response::new(detee_shared::pb::brain::Empty {})) Ok(Response::new(detee_shared::sgx::pb::brain::Empty {}))
} }
async fn list_app_contracts( async fn list_app_contracts(
@ -469,7 +469,7 @@ impl BrainAppDaemon for BrainAppDaemonMock {
async fn brain_messages( async fn brain_messages(
&self, &self,
req: tonic::Request<detee_shared::pb::brain::DaemonAuth>, req: tonic::Request<detee_shared::sgx::pb::brain::DaemonAuth>,
) -> Result<tonic::Response<Self::BrainMessagesStream>, Status> { ) -> Result<tonic::Response<Self::BrainMessagesStream>, Status> {
let req_data = req.into_inner(); let req_data = req.into_inner();
let pubkey = req_data.pubkey.clone(); let pubkey = req_data.pubkey.clone();
@ -495,16 +495,17 @@ impl BrainAppDaemon for BrainAppDaemonMock {
async fn daemon_messages( async fn daemon_messages(
&self, &self,
req: tonic::Request<Streaming<DaemonMessageApp>>, req: tonic::Request<Streaming<DaemonMessageApp>>,
) -> Result<tonic::Response<detee_shared::pb::brain::Empty>, Status> { ) -> Result<tonic::Response<detee_shared::sgx::pb::brain::Empty>, Status> {
let mut req_stream = req.into_inner(); let mut req_stream = req.into_inner();
let mut pubkey = String::new(); let mut pubkey;
if let Some(Ok(msg)) = req_stream.next().await { if let Some(Ok(msg)) = req_stream.next().await {
log::debug!( log::debug!(
"demon_messages received the following auth message: {:?}", "demon_messages received the following auth message: {:?}",
msg.msg msg.msg
); );
if let Some(detee_shared::pb::brain::daemon_message_app::Msg::Auth(auth)) = msg.msg { if let Some(detee_shared::sgx::pb::brain::daemon_message_app::Msg::Auth(auth)) = msg.msg
{
pubkey = auth.pubkey.clone(); pubkey = auth.pubkey.clone();
check_sig_from_parts( check_sig_from_parts(
&pubkey, &pubkey,
@ -524,15 +525,21 @@ impl BrainAppDaemon for BrainAppDaemonMock {
while let Some(daemon_message) = req_stream.next().await { while let Some(daemon_message) = req_stream.next().await {
match daemon_message { match daemon_message {
Ok(msg) => match msg.msg { Ok(msg) => match msg.msg {
Some(detee_shared::pb::brain::daemon_message_app::Msg::Auth(daemon_auth)) => { Some(detee_shared::sgx::pb::brain::daemon_message_app::Msg::Auth(
daemon_auth,
)) => {
dbg!(&daemon_auth); dbg!(&daemon_auth);
// TODO: wip on authendication // TODO: wip on authendication
pubkey = daemon_auth.pubkey; pubkey = daemon_auth.pubkey;
} }
Some(detee_shared::pb::brain::daemon_message_app::Msg::NewAppRes(new_cont)) => { Some(detee_shared::sgx::pb::brain::daemon_message_app::Msg::NewAppRes(
new_cont,
)) => {
self.data.send_new_container_resp(new_cont).await; self.data.send_new_container_resp(new_cont).await;
} }
Some(detee_shared::pb::brain::daemon_message_app::Msg::AppNodeResources(_)) => { Some(
detee_shared::sgx::pb::brain::daemon_message_app::Msg::AppNodeResources(_),
) => {
todo!("AppNodeResources not implemented yet"); todo!("AppNodeResources not implemented yet");
} }
_ => { _ => {
@ -547,7 +554,7 @@ impl BrainAppDaemon for BrainAppDaemonMock {
// //
} }
Ok(Response::new(detee_shared::pb::brain::Empty {})) Ok(Response::new(detee_shared::sgx::pb::brain::Empty {}))
} }
} }
impl PubkeyGetter for NewVmReq { impl PubkeyGetter for NewVmReq {

@ -2,8 +2,8 @@ mod data;
mod grpc; mod grpc;
use data::BrainData; use data::BrainData;
use detee_shared::pb::brain::brain_app_cli_server::BrainAppCliServer; use detee_shared::sgx::pb::brain::brain_app_cli_server::BrainAppCliServer;
use detee_shared::pb::brain::brain_app_daemon_server::BrainAppDaemonServer; use detee_shared::sgx::pb::brain::brain_app_daemon_server::BrainAppDaemonServer;
use grpc::snp_proto::brain_cli_server::BrainCliServer; use grpc::snp_proto::brain_cli_server::BrainCliServer;
use grpc::snp_proto::brain_vm_daemon_server::BrainVmDaemonServer; use grpc::snp_proto::brain_vm_daemon_server::BrainVmDaemonServer;
use grpc::BrainAppCliMock; use grpc::BrainAppCliMock;