From f050e58176ed6fced7e1a4f69c959b4148c78a8a Mon Sep 17 00:00:00 2001 From: ghe0 Date: Sat, 28 Dec 2024 03:53:38 +0200 Subject: [PATCH] change NewVmResp to allow the CLI to build params --- cli-mock/brain.proto | 15 ++++++++++++--- daemon-mock/brain.proto | 15 ++++++++++++--- daemon-mock/src/main.rs | 31 ++++++++++++++++++------------- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/cli-mock/brain.proto b/cli-mock/brain.proto index 3bb4bf4..e096b24 100644 --- a/cli-mock/brain.proto +++ b/cli-mock/brain.proto @@ -79,12 +79,21 @@ message ListVMContractsReq { string node_pubkey = 2; } +message NewVmRespIP { + uint32 nic_index = 1; + string address = 2; + string mask = 3; + string gateway = 4; +} + message NewVMResp { string uuid = 1; repeated uint32 exposed_ports = 2; - string public_ipv4 = 3; - string public_ipv6 = 4; - string error = 5; + string ovmf_hash = 5; + // This is needed to allow the CLI to build the kernel params from known data. + // The CLI will use the kernel params to get the measurement. + repeated NewVmRespIP ips = 6; + string error = 7; } message DeleteVMReq { diff --git a/daemon-mock/brain.proto b/daemon-mock/brain.proto index 3bb4bf4..e096b24 100644 --- a/daemon-mock/brain.proto +++ b/daemon-mock/brain.proto @@ -79,12 +79,21 @@ message ListVMContractsReq { string node_pubkey = 2; } +message NewVmRespIP { + uint32 nic_index = 1; + string address = 2; + string mask = 3; + string gateway = 4; +} + message NewVMResp { string uuid = 1; repeated uint32 exposed_ports = 2; - string public_ipv4 = 3; - string public_ipv6 = 4; - string error = 5; + string ovmf_hash = 5; + // This is needed to allow the CLI to build the kernel params from known data. + // The CLI will use the kernel params to get the measurement. + repeated NewVmRespIP ips = 6; + string error = 7; } message DeleteVMReq { diff --git a/daemon-mock/src/main.rs b/daemon-mock/src/main.rs index 8ec2650..8791841 100644 --- a/daemon-mock/src/main.rs +++ b/daemon-mock/src/main.rs @@ -6,7 +6,7 @@ pub mod brain { use anyhow::Result; use brain::{ brain_daemon_service_client::BrainDaemonServiceClient, DeleteVmReq, NewVmReq, NewVmResp, - NodePubkey, NodeResourceReq, RegisterNodeReq, UpdateVmReq, UpdateVmResp, + NewVmRespIp, NodePubkey, NodeResourceReq, RegisterNodeReq, UpdateVmReq, UpdateVmResp, }; use lazy_static::lazy_static; use log::{debug, error, info, warn}; @@ -180,20 +180,25 @@ async fn handle_vm_requests( true => Vec::new(), false => vec![20321, 20415, 25912], }; - let public_ipv4 = match new_vm.public_ipv4 { - true => "10.0.100.5".to_string(), - false => String::new(), - }; - let public_ipv6 = match new_vm.public_ipv6 { - true => "2a02:2f2d:d301:3100:afe8:a85e:54a0:dd28".to_string(), - false => String::new(), - }; + let mut ips = Vec::new(); + ips.push(NewVmRespIp { + nic_index: 0, + address: "190.0.100.5".to_string(), + gateway: "190.0.100.1".to_string(), + mask: "24".to_string(), + }); + ips.push(NewVmRespIp { + nic_index: 0, + address: "2a02:2f2d:d301:3100:afe8:a85e:54a0:dd28".to_string(), + gateway: "2a02:2f2d:d301:3100::1".to_string(), + mask: "64".to_string(), + }); if i != 3 { let confirmation = NewVmResp { uuid: new_vm.uuid, exposed_ports, - public_ipv4, - public_ipv6, + ovmf_hash: "YouAreNotGettingHacked".to_string(), + ips, error: String::new(), }; info!("Sending NewVmConfirmation: {confirmation:?}"); @@ -203,8 +208,8 @@ async fn handle_vm_requests( let confirmation = NewVmResp { uuid: new_vm.uuid, exposed_ports: Vec::new(), - public_ipv4: String::new(), - public_ipv6: String::new(), + ovmf_hash: "YouAreNotGettingHacked".to_string(), + ips: Vec::new(), error: "No.".to_string(), }; info!("Sending error for NewVmConfirmation: {confirmation:?}");