I hate this, i don't know

This commit is contained in:
gallant 2022-10-07 09:30:34 -05:00
parent 5f7e3081e0
commit 8483d6ee01
2 changed files with 19 additions and 38 deletions

View File

@ -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<String> {
pub fn concat(&self, connect: bool) -> Vec<String> {
let mut final_thing: Vec<String> = 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);
});

View File

@ -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<String, ExitStatus>{
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)
}