diff --git a/Cargo.lock b/Cargo.lock index 92bd0a2..92f6cf1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -470,18 +470,6 @@ dependencies = [ "winit", ] -[[package]] -name = "eframe_template" -version = "0.1.0" -dependencies = [ - "console_error_panic_hook", - "eframe", - "egui", - "serde", - "tracing-subscriber", - "tracing-wasm", -] - [[package]] name = "egui" version = "0.19.0" @@ -1422,6 +1410,18 @@ dependencies = [ "wayland-client", ] +[[package]] +name = "sshuttle_gui" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "eframe", + "egui", + "serde", + "tracing-subscriber", + "tracing-wasm", +] + [[package]] name = "str-buf" version = "1.0.6" diff --git a/Cargo.toml b/Cargo.toml index d2a9b66..da98340 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "eframe_template" +name = "sshuttle_gui" version = "0.1.0" -authors = ["Emil Ernerfeldt "] +authors = ["Gallant"] edition = "2021" rust-version = "1.60" diff --git a/assets/sw.js b/assets/sw.js index 7ecd229..83e9294 100644 --- a/assets/sw.js +++ b/assets/sw.js @@ -2,8 +2,8 @@ var cacheName = 'egui-template-pwa'; var filesToCache = [ './', './index.html', - './eframe_template.js', - './eframe_template_bg.wasm', + './sshuttle_gui.js', + './sshuttle_gui_bg.wasm', ]; /* Start the service worker and cache all of the app's content */ diff --git a/index.html b/index.html index 872b4f4..fa7215e 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - eframe template + sshuttle_gui diff --git a/src/app.rs b/src/app.rs index 01cd7ba..dc0c3e3 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,6 +10,64 @@ pub struct TemplateApp { value: f32, } +pub struct SshDeets { + dns: bool, + user: String, + ip: String, + port: String, + mask: Option, +} + +impl Default for SshDeets { + fn default() -> Self { + Self { + dns: true, + user: String::from("No"), + ip: String::from("127.0.0.1"), + port: String::from("8080"), + mask: None, + } + } +} + +impl SshDeets { + pub fn new(self, + yeah: bool, + username: &str, + ip_addy: &str, + port_num: &str, + masking: Option) -> Self + { + let balling = Self { + dns: yeah, + user: String::from(username), + ip: String::from(ip_addy), + port: String::from(port_num), + mask: masking, + }; + balling + + } + pub fn concat(self, connect: bool) -> Vec { + let mut final_thing: Vec = vec![]; + if connect == false{ + if self.dns == true && self.mask != None{ + final_thing.push(String::from("--dns")); + 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.unwrap()); + return final_thing; + } + else { + return vec![]; + } + }else { + unimplemented!(); + } + } +} + impl Default for TemplateApp { fn default() -> Self { Self { @@ -64,7 +122,7 @@ impl eframe::App for TemplateApp { }); }); - egui::SidePanel::left("side_panel").show(ctx, |ui| { + /* egui::SidePanel::left("side_panel").show(ctx, |ui| { ui.heading("Side Panel"); ui.horizontal(|ui| { @@ -90,17 +148,19 @@ impl eframe::App for TemplateApp { ui.label("."); }); }); - }); + }); */ egui::CentralPanel::default().show(ctx, |ui| { // The central panel the region left after adding TopPanel's and SidePanel's - + + ui.text_edit_singleline(label); ui.heading("eframe template"); ui.hyperlink("https://github.com/emilk/eframe_template"); ui.add(egui::github_link_file!( "https://github.com/emilk/eframe_template/blob/master/", "Source code." )); + egui::warn_if_debug_build(ui); }); diff --git a/src/lib.rs b/src/lib.rs index fbae77a..3364262 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,18 @@ #![warn(clippy::all, rust_2018_idioms)] +use std::process::{ExitStatus, Command}; + mod app; pub use app::TemplateApp; +pub use app::SshDeets; + +pub fn connect_ssh(connect: bool, structure: SshDeets) -> Result<(), ExitStatus>{ + let argss = structure.concat(connect); + if connect == false{ + Command::new("sshuttle") + .args(argss) + .spawn() + .expect("FUCK"); + } + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 969b8f7..d6cf012 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,9 +9,9 @@ fn main() { let native_options = eframe::NativeOptions::default(); eframe::run_native( - "eframe template", + "sshuttle", native_options, - Box::new(|cc| Box::new(eframe_template::TemplateApp::new(cc))), + Box::new(|cc| Box::new(sshuttle_gui::TemplateApp::new(cc))), ); } @@ -28,7 +28,7 @@ fn main() { eframe::start_web( "the_canvas_id", // hardcode it web_options, - Box::new(|cc| Box::new(eframe_template::TemplateApp::new(cc))), + Box::new(|cc| Box::new(sshuttle_gui::TemplateApp::new(cc))), ) .expect("failed to start eframe"); }