forked from ghe0/brain-mock
refactor: update detee-shared dependency and adjust imports to use sgx module
This commit is contained in:
parent
784878d0a1
commit
2cada47d24
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -418,7 +418,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "detee-shared"
|
||||
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 = [
|
||||
"base64",
|
||||
"prost",
|
||||
|
22
src/data.rs
22
src/data.rs
@ -1,18 +1,18 @@
|
||||
use crate::grpc::snp_proto::{self as grpc};
|
||||
use chrono::Utc;
|
||||
use dashmap::DashMap;
|
||||
use detee_shared::pb::brain::DelAppReq;
|
||||
use detee_shared::sgx::pb::brain::DelAppReq;
|
||||
use log::{debug, info, warn};
|
||||
use std::str::FromStr;
|
||||
use std::sync::RwLock;
|
||||
use tokio::sync::mpsc::Sender;
|
||||
use tokio::sync::oneshot::Sender as OneshotSender;
|
||||
|
||||
use detee_shared::pb::brain::AppContract as AppContractPB;
|
||||
use detee_shared::pb::brain::BrainMessageApp;
|
||||
use detee_shared::pb::brain::MappedPort;
|
||||
use detee_shared::pb::brain::NewAppReq;
|
||||
use detee_shared::pb::brain::NewAppRes;
|
||||
use detee_shared::sgx::pb::brain::AppContract as AppContractPB;
|
||||
use detee_shared::sgx::pb::brain::BrainMessageApp;
|
||||
use detee_shared::sgx::pb::brain::MappedPort;
|
||||
use detee_shared::sgx::pb::brain::NewAppReq;
|
||||
use detee_shared::sgx::pb::brain::NewAppRes;
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
@ -833,9 +833,9 @@ impl BrainData {
|
||||
req.node_pubkey, req.uuid
|
||||
);
|
||||
let msg = BrainMessageApp {
|
||||
msg: Some(detee_shared::pb::brain::brain_message_app::Msg::NewAppReq(
|
||||
req.clone(),
|
||||
)),
|
||||
msg: Some(
|
||||
detee_shared::sgx::pb::brain::brain_message_app::Msg::NewAppReq(req.clone()),
|
||||
),
|
||||
};
|
||||
if let Err(e) = app_daemon_tx.send(msg).await {
|
||||
warn!(
|
||||
@ -869,7 +869,9 @@ impl BrainData {
|
||||
);
|
||||
let msg = BrainMessageApp {
|
||||
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(),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
|
33
src/grpc.rs
33
src/grpc.rs
@ -16,9 +16,9 @@ use tokio::sync::mpsc;
|
||||
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
|
||||
use tonic::{Request, Response, Status, Streaming};
|
||||
|
||||
use detee_shared::pb::brain::brain_app_cli_server::BrainAppCli;
|
||||
use detee_shared::pb::brain::brain_app_daemon_server::BrainAppDaemon;
|
||||
use detee_shared::pb::brain::{
|
||||
use detee_shared::sgx::pb::brain::brain_app_cli_server::BrainAppCli;
|
||||
use detee_shared::sgx::pb::brain::brain_app_daemon_server::BrainAppDaemon;
|
||||
use detee_shared::sgx::pb::brain::{
|
||||
AppContract, BrainMessageApp, DaemonMessageApp, DelAppReq, ListAppContractsReq, NewAppReq,
|
||||
NewAppRes, RegisterAppNodeReq,
|
||||
};
|
||||
@ -389,7 +389,7 @@ impl BrainAppCli for BrainAppCliMock {
|
||||
async fn delete_app(
|
||||
&self,
|
||||
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();
|
||||
log::info!("deleting container: {}", req.uuid.clone());
|
||||
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"));
|
||||
};
|
||||
|
||||
Ok(Response::new(detee_shared::pb::brain::Empty {}))
|
||||
Ok(Response::new(detee_shared::sgx::pb::brain::Empty {}))
|
||||
}
|
||||
|
||||
async fn list_app_contracts(
|
||||
@ -469,7 +469,7 @@ impl BrainAppDaemon for BrainAppDaemonMock {
|
||||
|
||||
async fn brain_messages(
|
||||
&self,
|
||||
req: tonic::Request<detee_shared::pb::brain::DaemonAuth>,
|
||||
req: tonic::Request<detee_shared::sgx::pb::brain::DaemonAuth>,
|
||||
) -> Result<tonic::Response<Self::BrainMessagesStream>, Status> {
|
||||
let req_data = req.into_inner();
|
||||
let pubkey = req_data.pubkey.clone();
|
||||
@ -495,16 +495,17 @@ impl BrainAppDaemon for BrainAppDaemonMock {
|
||||
async fn daemon_messages(
|
||||
&self,
|
||||
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 pubkey = String::new();
|
||||
let mut pubkey;
|
||||
|
||||
if let Some(Ok(msg)) = req_stream.next().await {
|
||||
log::debug!(
|
||||
"demon_messages received the following auth message: {:?}",
|
||||
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();
|
||||
check_sig_from_parts(
|
||||
&pubkey,
|
||||
@ -524,15 +525,21 @@ impl BrainAppDaemon for BrainAppDaemonMock {
|
||||
while let Some(daemon_message) = req_stream.next().await {
|
||||
match daemon_message {
|
||||
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);
|
||||
// TODO: wip on authendication
|
||||
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;
|
||||
}
|
||||
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");
|
||||
}
|
||||
_ => {
|
||||
@ -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 {
|
||||
|
@ -2,8 +2,8 @@ mod data;
|
||||
mod grpc;
|
||||
|
||||
use data::BrainData;
|
||||
use detee_shared::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_cli_server::BrainAppCliServer;
|
||||
use detee_shared::sgx::pb::brain::brain_app_daemon_server::BrainAppDaemonServer;
|
||||
use grpc::snp_proto::brain_cli_server::BrainCliServer;
|
||||
use grpc::snp_proto::brain_vm_daemon_server::BrainVmDaemonServer;
|
||||
use grpc::BrainAppCliMock;
|
||||
|
Loading…
Reference in New Issue
Block a user