decent setup

This commit is contained in:
gallant 2022-10-01 08:21:24 -05:00
parent 692d9865cd
commit 7da5e13b91
7 changed files with 97 additions and 23 deletions

24
Cargo.lock generated
View file

@ -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"

View file

@ -1,7 +1,7 @@
[package]
name = "eframe_template"
name = "sshuttle_gui"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
authors = ["Gallant"]
edition = "2021"
rust-version = "1.60"

View file

@ -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 */

View file

@ -7,7 +7,7 @@
<head>
<!-- change this to your project name -->
<title>eframe template</title>
<title>sshuttle_gui</title>
<!-- config for our rust wasm binary. go to https://trunkrs.dev/assets/#rust for more customization -->
<link data-trunk rel="rust" data-wasm-opt="2" />

View file

@ -10,6 +10,64 @@ pub struct TemplateApp {
value: f32,
}
pub struct SshDeets {
dns: bool,
user: String,
ip: String,
port: String,
mask: Option<String>,
}
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<String>) -> 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<String> {
let mut final_thing: Vec<String> = 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);
});

View file

@ -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(())
}

View file

@ -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");
}