change NewVmResp to allow the CLI to build params

This commit is contained in:
ghe0 2024-12-28 03:53:38 +02:00
parent b6e7fa0311
commit f050e58176
Signed by: ghe0
GPG Key ID: 451028EE56A0FBB4
3 changed files with 42 additions and 19 deletions

@ -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 {

@ -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 {

@ -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:?}");