From 8483d6ee011e8795a5c49505e5d9b18f809cf646 Mon Sep 17 00:00:00 2001 From: gallant Date: Fri, 7 Oct 2022 09:30:34 -0500 Subject: [PATCH] I hate this, i don't know --- src/app.rs | 42 ++++++++++-------------------------------- src/lib.rs | 15 +++++++++------ 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/src/app.rs b/src/app.rs index 0bbe836..eec776f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -13,7 +13,7 @@ pub struct TemplateApp { #[serde(skip)] value: f32, } -#[derive(serde::Deserialize, serde::Serialize)] +#[derive(serde::Deserialize, serde::Serialize, Clone)] #[serde(default)] pub struct SshDeets { pub dns: bool, @@ -52,7 +52,7 @@ impl SshDeets { } } - pub fn concat(self, connect: bool) -> Vec { + pub fn concat(&self, connect: bool) -> Vec { let mut final_thing: Vec = vec![]; if connect == false{ if self.dns == true { @@ -60,7 +60,7 @@ impl SshDeets { final_thing.push(String::from("-Nr")); final_thing.push(format!("{}:{}", self.user, self.ip)); final_thing.push(String::from("-x")); - final_thing.push(self.mask); + final_thing.push(self.mask.clone()); return final_thing; } else { @@ -128,36 +128,10 @@ impl eframe::App for TemplateApp { }); }); - /* egui::SidePanel::left("side_panel").show(ctx, |ui| { - ui.heading("Side Panel"); - - ui.horizontal(|ui| { - ui.label("Write something: "); - ui.text_edit_singleline(label); - }); - - ui.add(egui::Slider::new(value, 0.0..=10.0).text("value")); - if ui.button("Increment").clicked() { - *value += 1.0; - } - - ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 0.0; - ui.label("powered by "); - ui.hyperlink_to("egui", "https://github.com/emilk/egui"); - ui.label(" and "); - ui.hyperlink_to( - "eframe", - "https://github.com/emilk/egui/tree/master/crates/eframe", - ); - ui.label("."); - }); - }); - }); */ - + egui::CentralPanel::default().show(ctx, |ui| { // The central panel the region left after adding TopPanel's and SidePanel's + let mut outout = String::new(); ui.label("put your linux ssh username, ip, and port (does not have to be root)"); ui.text_edit_singleline(&mut deets.user); ui.text_edit_singleline(&mut deets.ip); @@ -170,7 +144,7 @@ impl eframe::App for TemplateApp { ui.text_edit_singleline(&mut deets.mask); if ui.button("connect").clicked() { - //connect_ssh(false, *deets); + connect_ssh(false, &*deets); } /* ui.heading("eframe template"); ui.hyperlink("https://github.com/emilk/eframe_template"); @@ -178,6 +152,10 @@ impl eframe::App for TemplateApp { "https://github.com/emilk/eframe_template/blob/master/", "Source code." )); */ + egui::SidePanel::right("side_panel").show(ctx, |ui| { + ui.add(egui::widgets::Label::new("This will be for stdout eventually".to_owned())); + + }); egui::warn_if_debug_build(ui); }); diff --git a/src/lib.rs b/src/lib.rs index 3364262..34c8a00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,21 @@ #![warn(clippy::all, rust_2018_idioms)] -use std::process::{ExitStatus, Command}; +use std::process::{ExitStatus, Command, Stdio}; mod app; pub use app::TemplateApp; pub use app::SshDeets; -pub fn connect_ssh(connect: bool, structure: SshDeets) -> Result<(), ExitStatus>{ +pub fn connect_ssh(connect: bool, structure: &SshDeets) -> Result{ let argss = structure.concat(connect); + let mut stdout = String::new(); if connect == false{ - Command::new("sshuttle") + let skrunk = Command::new("sshuttle") .args(argss) - .spawn() - .expect("FUCK"); + //.spawn() + .stdout(Stdio::piped()) + .output().unwrap(); + let stdout = String::from_utf8(skrunk.stdout).unwrap(); } - Ok(()) + Ok(stdout) }