From 40af25345096ec1c0f02779243f4ee9a90783548 Mon Sep 17 00:00:00 2001 From: April John Date: Fri, 28 Feb 2025 18:15:54 +0100 Subject: [PATCH] migrate to rust version 2024 --- Cargo.toml | 2 +- rustfmt.toml | 1 + src/gui.rs | 1 - src/main.rs | 19 ++++++++++++++----- 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 rustfmt.toml diff --git a/Cargo.toml b/Cargo.toml index d4cfb70..4b128ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "hai" version = "0.1.0" authors = ["April Faye John "] -edition = "2021" +edition = "2024" publish = false license = "AGPL-3.0-or-later" diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..c5cf55d --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +style_edition = "2024" \ No newline at end of file diff --git a/src/gui.rs b/src/gui.rs index 7021b7e..fd895a7 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -6,7 +6,6 @@ use egui::{TextureOptions, Vec2}; pub fn gui_main() -> eframe::Result { - env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 540.0]), ..Default::default() diff --git a/src/main.rs b/src/main.rs index 4258c33..0946f0f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,10 +10,13 @@ mod gui; mod pman; mod quic; +use std::fs::File; +use std::net::SocketAddr; +use std::str::FromStr; use bunt::println; use clap::{Parser, Subcommand}; -use config::{Config, Source}; -use log::info; +use config::{Config, FileFormat, Source}; +use log::{debug, info}; use pman::{init_process_manager, ProcessCommand, ProcessManager}; use shadow_rs::shadow; use std::sync::{Arc, Mutex, OnceLock}; @@ -41,7 +44,7 @@ struct Args { #[derive(Debug, Subcommand)] enum Commands { - #[command(arg_required_else_help = true, about = "Start client without GUI")] + #[command(about = "Start client without GUI")] CliClient, #[command(about = "List compile time backed info to audit binary")] Shadow, @@ -66,7 +69,10 @@ static CONFIG_FILE: OnceLock> = OnceLock::new(); fn get_config_file_source() -> impl Source { let file = CONFIG_FILE.get(); let default_dir = dirs::config_dir().unwrap(); - config::File::from_str(s, format) + let file_buf = default_dir.join("hai").join("config.toml"); + println!("{}", file_buf.to_string_lossy()); + let file_content = std::fs::read_to_string(file_buf).unwrap(); + config::File::from_str(&*file_content, FileFormat::Toml) } #[tokio::main] @@ -81,7 +87,10 @@ async fn main() { let _ = init_process_manager(); match args.command { - Commands::CliClient => {} + Commands::CliClient => { + let ip_addr_str = config().get_string("remote_endpoint").unwrap(); + let ip_sock = SocketAddr::from_str(&ip_addr_str).unwrap(); + } Commands::Shadow => { bininfo::print_info();