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; string node_pubkey = 2;
} }
message NewVmRespIP {
uint32 nic_index = 1;
string address = 2;
string mask = 3;
string gateway = 4;
}
message NewVMResp { message NewVMResp {
string uuid = 1; string uuid = 1;
repeated uint32 exposed_ports = 2; repeated uint32 exposed_ports = 2;
string public_ipv4 = 3; string ovmf_hash = 5;
string public_ipv6 = 4; // This is needed to allow the CLI to build the kernel params from known data.
string error = 5; // The CLI will use the kernel params to get the measurement.
repeated NewVmRespIP ips = 6;
string error = 7;
} }
message DeleteVMReq { message DeleteVMReq {

@ -79,12 +79,21 @@ message ListVMContractsReq {
string node_pubkey = 2; string node_pubkey = 2;
} }
message NewVmRespIP {
uint32 nic_index = 1;
string address = 2;
string mask = 3;
string gateway = 4;
}
message NewVMResp { message NewVMResp {
string uuid = 1; string uuid = 1;
repeated uint32 exposed_ports = 2; repeated uint32 exposed_ports = 2;
string public_ipv4 = 3; string ovmf_hash = 5;
string public_ipv6 = 4; // This is needed to allow the CLI to build the kernel params from known data.
string error = 5; // The CLI will use the kernel params to get the measurement.
repeated NewVmRespIP ips = 6;
string error = 7;
} }
message DeleteVMReq { message DeleteVMReq {

@ -6,7 +6,7 @@ pub mod brain {
use anyhow::Result; use anyhow::Result;
use brain::{ use brain::{
brain_daemon_service_client::BrainDaemonServiceClient, DeleteVmReq, NewVmReq, NewVmResp, 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 lazy_static::lazy_static;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
@ -180,20 +180,25 @@ async fn handle_vm_requests(
true => Vec::new(), true => Vec::new(),
false => vec![20321, 20415, 25912], false => vec![20321, 20415, 25912],
}; };
let public_ipv4 = match new_vm.public_ipv4 { let mut ips = Vec::new();
true => "10.0.100.5".to_string(), ips.push(NewVmRespIp {
false => String::new(), nic_index: 0,
}; address: "190.0.100.5".to_string(),
let public_ipv6 = match new_vm.public_ipv6 { gateway: "190.0.100.1".to_string(),
true => "2a02:2f2d:d301:3100:afe8:a85e:54a0:dd28".to_string(), mask: "24".to_string(),
false => String::new(), });
}; 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 { if i != 3 {
let confirmation = NewVmResp { let confirmation = NewVmResp {
uuid: new_vm.uuid, uuid: new_vm.uuid,
exposed_ports, exposed_ports,
public_ipv4, ovmf_hash: "YouAreNotGettingHacked".to_string(),
public_ipv6, ips,
error: String::new(), error: String::new(),
}; };
info!("Sending NewVmConfirmation: {confirmation:?}"); info!("Sending NewVmConfirmation: {confirmation:?}");
@ -203,8 +208,8 @@ async fn handle_vm_requests(
let confirmation = NewVmResp { let confirmation = NewVmResp {
uuid: new_vm.uuid, uuid: new_vm.uuid,
exposed_ports: Vec::new(), exposed_ports: Vec::new(),
public_ipv4: String::new(), ovmf_hash: "YouAreNotGettingHacked".to_string(),
public_ipv6: String::new(), ips: Vec::new(),
error: "No.".to_string(), error: "No.".to_string(),
}; };
info!("Sending error for NewVmConfirmation: {confirmation:?}"); info!("Sending error for NewVmConfirmation: {confirmation:?}");