Compare commits
No commits in common. "17fb7ed1209807e5f8f7940fcb2186db9c2e6686" and "c099817e9a83ccb26e5b6b6c25434b0783e9488e" have entirely different histories.
17fb7ed120
...
c099817e9a
|
|
@ -2,7 +2,7 @@
|
|||
name = "hai"
|
||||
version = "0.1.0"
|
||||
authors = ["April Faye John <april.john@denic.de>"]
|
||||
edition = "2024"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
style_edition = "2024"
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
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()
|
||||
|
|
|
|||
29
src/main.rs
29
src/main.rs
|
|
@ -10,13 +10,10 @@ 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, FileFormat, Source};
|
||||
use log::{debug, info};
|
||||
use config::{Config, Source};
|
||||
use log::info;
|
||||
use pman::{init_process_manager, ProcessCommand, ProcessManager};
|
||||
use shadow_rs::shadow;
|
||||
use std::sync::{Arc, Mutex, OnceLock};
|
||||
|
|
@ -44,7 +41,7 @@ struct Args {
|
|||
|
||||
#[derive(Debug, Subcommand)]
|
||||
enum Commands {
|
||||
#[command(about = "Start client without GUI")]
|
||||
#[command(arg_required_else_help = true, about = "Start client without GUI")]
|
||||
CliClient,
|
||||
#[command(about = "List compile time backed info to audit binary")]
|
||||
Shadow,
|
||||
|
|
@ -69,14 +66,11 @@ static CONFIG_FILE: OnceLock<Option<String>> = OnceLock::new();
|
|||
fn get_config_file_source() -> impl Source {
|
||||
let file = CONFIG_FILE.get();
|
||||
let default_dir = dirs::config_dir().unwrap();
|
||||
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)
|
||||
config::File::from_str(s, format)
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
async fn main() {
|
||||
|
||||
env_logger::init();
|
||||
let args = Args::parse();
|
||||
|
|
@ -87,17 +81,11 @@ async fn main() -> anyhow::Result<()> {
|
|||
let _ = init_process_manager();
|
||||
|
||||
match args.command {
|
||||
Commands::CliClient => {
|
||||
let ip_addr_str = config().get_string("remote_endpoint")?;
|
||||
let ip_sock = SocketAddr::from_str(&ip_addr_str)?;
|
||||
let client_endpoint = quic::client::make_client_endpoint(ip_sock.clone(), None)?;
|
||||
let client = client_endpoint.connect(ip_sock, "localhost")?.await?;
|
||||
println!("[client] connected: addr={}", client.remote_address());
|
||||
}
|
||||
Commands::CliClient => {}
|
||||
|
||||
Commands::Shadow => {
|
||||
bininfo::print_info();
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
|
||||
Commands::GuiClient => {
|
||||
|
|
@ -105,7 +93,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
if let Err(e) = res {
|
||||
println!("{}", e);
|
||||
}
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
|
||||
Commands::Devtest => {
|
||||
|
|
@ -124,5 +112,4 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
//handling anything here for gui wont work
|
||||
println!("exit");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,14 @@ use rustls::pki_types::CertificateDer;
|
|||
///
|
||||
/// - server_certs: a list of trusted certificates in DER format.
|
||||
fn configure_client(
|
||||
server_certs: Option<&[&[u8]]>,
|
||||
server_certs: &[&[u8]],
|
||||
) -> Result<ClientConfig, Box<dyn Error + Send + Sync + 'static>> {
|
||||
if let Some(server_certs) = server_certs {
|
||||
let mut certs = rustls::RootCertStore::empty();
|
||||
for cert in server_certs {
|
||||
certs.add(CertificateDer::from(*cert))?;
|
||||
}
|
||||
|
||||
Ok(ClientConfig::with_root_certificates(Arc::new(certs))?)
|
||||
} else {
|
||||
Ok(ClientConfig::with_platform_verifier())
|
||||
let mut certs = rustls::RootCertStore::empty();
|
||||
for cert in server_certs {
|
||||
certs.add(CertificateDer::from(*cert))?;
|
||||
}
|
||||
|
||||
Ok(ClientConfig::with_root_certificates(Arc::new(certs))?)
|
||||
}
|
||||
|
||||
/// Constructs a QUIC endpoint configured for use a client only.
|
||||
|
|
@ -32,7 +28,7 @@ fn configure_client(
|
|||
#[allow(unused)]
|
||||
pub fn make_client_endpoint(
|
||||
bind_addr: SocketAddr,
|
||||
server_certs: Option<&[&[u8]]>,
|
||||
server_certs: &[&[u8]],
|
||||
) -> Result<Endpoint, Box<dyn Error + Send + Sync + 'static>> {
|
||||
let client_cfg = configure_client(server_certs)?;
|
||||
let mut endpoint = Endpoint::client(bind_addr)?;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
pub(crate) mod server;
|
||||
pub(crate) mod client;
|
||||
mod server;
|
||||
mod client;
|
||||
Loading…
Reference in a new issue