From adc3bb8eeb5930cbe3cd6cfe4d52440ea33a3c3c Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Fri, 17 Mar 2023 14:24:24 +0000 Subject: [PATCH] dpkg setup adds an auto-generated node-id --- src/rust/Cargo.lock | 1 + src/rust/lqos_setup/Cargo.toml | 3 ++- src/rust/lqos_setup/src/main.rs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index f8835901..6dd80110 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -1413,6 +1413,7 @@ version = "0.1.0" dependencies = [ "colored", "default-net", + "uuid", ] [[package]] diff --git a/src/rust/lqos_setup/Cargo.toml b/src/rust/lqos_setup/Cargo.toml index 5287c3c1..76d84786 100644 --- a/src/rust/lqos_setup/Cargo.toml +++ b/src/rust/lqos_setup/Cargo.toml @@ -5,4 +5,5 @@ edition = "2021" [dependencies] colored = "2" -default-net = "0" # For obtaining an easy-to-use NIC list \ No newline at end of file +default-net = "0" # For obtaining an easy-to-use NIC list +uuid = { version = "1", features = ["v4", "fast-rng" ] } diff --git a/src/rust/lqos_setup/src/main.rs b/src/rust/lqos_setup/src/main.rs index 28def8cf..da2d20e5 100644 --- a/src/rust/lqos_setup/src/main.rs +++ b/src/rust/lqos_setup/src/main.rs @@ -1,5 +1,6 @@ use colored::Colorize; use default_net::{get_interfaces, interface::InterfaceType, Interface}; +use uuid::Uuid; use std::{fs, path::Path, process::Command}; fn get_available_interfaces() -> Vec { @@ -117,6 +118,7 @@ fn get_bandwidth(up: bool) -> u32 { const ETC_LQOS_CONF: &str = "lqos_directory = '/opt/libreqos/src' queue_check_period_ms = 1000 +node_id = {NODE_ID} [tuning] stop_irq_balance = true @@ -138,8 +140,10 @@ vlan_mapping = [] "; fn write_etc_lqos_conf(internet: &str, isp: &str) { + let new_id = Uuid::new_v4().to_string(); let output = - ETC_LQOS_CONF.replace("{INTERNET}", internet).replace("{ISP}", isp); + ETC_LQOS_CONF.replace("{INTERNET}", internet).replace("{ISP}", isp) + .replace("{NODE_ID}", &new_id); fs::write(LQOS_CONF, output).expect("Unable to write file"); }