fixed the concern with pr
This commit is contained in:
parent
5faa8d210d
commit
554468e8b6
16
src/data.rs
16
src/data.rs
@ -1,5 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
use crate::grpc::brain::{self as grpc, MeasurementArgs};
|
||||
use crate::grpc::brain::{self as grpc};
|
||||
use chrono::Utc;
|
||||
use dashmap::DashMap;
|
||||
use log::{debug, info, warn};
|
||||
@ -87,7 +87,6 @@ pub struct BrainData {
|
||||
daemon_deletevm_tx: DashMap<String, Sender<grpc::DeleteVmReq>>,
|
||||
daemon_newvm_tx: DashMap<String, Sender<grpc::NewVmReq>>,
|
||||
daemon_updatevm_tx: DashMap<String, Sender<grpc::UpdateVmReq>>,
|
||||
daemon_get_measurement_tx: DashMap<String, Sender<MeasurementArgs>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -107,7 +106,6 @@ impl BrainData {
|
||||
daemon_deletevm_tx: DashMap::new(),
|
||||
daemon_newvm_tx: DashMap::new(),
|
||||
daemon_updatevm_tx: DashMap::new(),
|
||||
daemon_get_measurement_tx: DashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +208,15 @@ impl BrainData {
|
||||
}
|
||||
let mut public_ipv4 = String::new();
|
||||
let mut public_ipv6 = String::new();
|
||||
for ip in new_vm_resp.args.clone().unwrap_or(grpc::MeasurementArgs::default()).ips {
|
||||
let args = match new_vm_resp.args {
|
||||
Some(args) => args,
|
||||
None => {
|
||||
log::error!("NewVmResp does not contain MeasurementArgs for {}", new_vm_resp.uuid);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
for ip in args.ips {
|
||||
if let Ok(ipv4_addr) = std::net::Ipv4Addr::from_str(&ip.address) {
|
||||
if !ipv4_addr.is_private() && !ipv4_addr.is_link_local() {
|
||||
public_ipv4 = ipv4_addr.to_string();
|
||||
@ -223,7 +229,7 @@ impl BrainData {
|
||||
}
|
||||
let contract = Contract {
|
||||
uuid: new_vm_resp.uuid,
|
||||
exposed_ports: new_vm_resp.args.unwrap_or(grpc::MeasurementArgs::default()).exposed_ports,
|
||||
exposed_ports: args.exposed_ports,
|
||||
public_ipv4,
|
||||
public_ipv6,
|
||||
created_at: Utc::now().to_rfc3339(),
|
||||
|
Loading…
Reference in New Issue
Block a user