From bfb4e9b487c514471d014ddcfda8567f7706adc6 Mon Sep 17 00:00:00 2001 From: Noor Date: Thu, 27 Mar 2025 14:53:04 +0000 Subject: [PATCH] Fix: host ip override Add default host IP address retrieval to HostConfig and update its references --- src/config.rs | 7 +++++++ src/grpc.rs | 2 +- src/main.rs | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4999fc2..65779fc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,9 +1,12 @@ use anyhow::Result; use serde::{Deserialize, Serialize}; +use crate::global::IP_INFO; + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct HostConfig { pub brain_url: String, + #[serde(default = "retrieve_node_ip")] pub host_ip_address: String, pub operator_wallet: String, pub max_cores_per_app: u32, @@ -25,6 +28,10 @@ fn default_reserved_no_of_port() -> u32 { 16 } +fn retrieve_node_ip() -> String { + IP_INFO.ip.clone() +} + impl HostConfig { pub fn load_from_disk(path: &str) -> Result { let content = std::fs::read_to_string(path)?; diff --git a/src/grpc.rs b/src/grpc.rs index faaa0ef..5b626a6 100644 --- a/src/grpc.rs +++ b/src/grpc.rs @@ -31,7 +31,7 @@ pub async fn register_node(config: &crate::HostConfig) -> Result { - // TODO: update host resources to brain self.send_node_resources().await; - info!("Succesfully started VM {uuid}"); + info!("Succesfully started App {uuid}"); let res = NewAppRes { uuid, status: "success".to_string(),