Compare commits
4 commits
master
...
coderedart
Author | SHA1 | Date | |
---|---|---|---|
d4ccf581e6 | |||
14999fb8ce | |||
94c10486cb | |||
ee826a50fa |
8
.github/workflows/pages.yml
vendored
8
.github/workflows/pages.yml
vendored
|
@ -1,12 +1,12 @@
|
|||
name: Github Pages
|
||||
|
||||
# By default, runs if you push to master. keeps your deployed app in sync with master branch.
|
||||
# By default, runs if you push to master. keeps your deployed app in sync with master branch.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
# to only run when you do a new github release, comment out above part and uncomment the below trigger.
|
||||
# on:
|
||||
# on:
|
||||
# release:
|
||||
# types:
|
||||
# - published
|
||||
|
@ -27,7 +27,7 @@ jobs:
|
|||
override: true
|
||||
- name: Rust Cache # cache the rust build artefacts
|
||||
uses: Swatinem/rust-cache@v1
|
||||
- name: Download and install Trunk binary
|
||||
- name: Downlaod and Install Trunk binary
|
||||
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
|
||||
- name: Build # build
|
||||
# "${GITHUB_REPOSITORY#*/}" evaluates into the name of the repository
|
||||
|
@ -35,7 +35,7 @@ jobs:
|
|||
# this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested
|
||||
# relatively as eframe_template/favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which
|
||||
# will obviously return error 404 not found.
|
||||
run: ./trunk build --release --public-url "${GITHUB_REPOSITORY#*/}"
|
||||
run: ./trunk build --release --public-url "${GITHUB_REPOSITORY#*/}"
|
||||
- name: Deploy
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
|
|
6
.github/workflows/rust.yml
vendored
6
.github/workflows/rust.yml
vendored
|
@ -99,7 +99,7 @@ jobs:
|
|||
toolchain: 1.61.0
|
||||
target: wasm32-unknown-unknown
|
||||
override: true
|
||||
- name: Download and install Trunk binary
|
||||
- name: Downlaod and Install Trunk binary
|
||||
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
|
||||
- name: Build
|
||||
run: ./trunk build
|
||||
- name: Build
|
||||
run: ./trunk build
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
/target
|
||||
/dist
|
||||
/dist
|
676
Cargo.lock
generated
676
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
12
Cargo.toml
12
Cargo.toml
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "sshuttle_gui"
|
||||
name = "eframe_template"
|
||||
version = "0.1.0"
|
||||
authors = ["Gallant"]
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
|
||||
|
@ -9,8 +9,8 @@ rust-version = "1.60"
|
|||
|
||||
|
||||
[dependencies]
|
||||
egui = "0.19.0"
|
||||
eframe = { version = "0.19.0", features = ["persistence"] }
|
||||
egui = "0.18.0"
|
||||
eframe = { version = "0.18.0", features = ["persistence"] }
|
||||
serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence
|
||||
|
||||
# native:
|
||||
|
@ -34,5 +34,5 @@ opt-level = 2 # fast and small wasm
|
|||
# eframe = { git = "https://github.com/emilk/egui", branch = "master" }
|
||||
|
||||
# If you fork https://github.com/emilk/egui you can test with:
|
||||
# egui = { path = "../egui/crates/egui" }
|
||||
# eframe = { path = "../egui/crates/eframe" }
|
||||
# egui = { path = "../egui/egui" }
|
||||
# eframe = { path = "../egui/eframe" }
|
||||
|
|
10
README.md
10
README.md
|
@ -3,7 +3,7 @@
|
|||
[![dependency status](https://deps.rs/repo/github/emilk/eframe_template/status.svg)](https://deps.rs/repo/github/emilk/eframe_template)
|
||||
[![Build Status](https://github.com/emilk/eframe_template/workflows/CI/badge.svg)](https://github.com/emilk/eframe_template/actions?workflow=CI)
|
||||
|
||||
This is a template repo for [eframe](https://github.com/emilk/egui/tree/master/crates/eframe), a framework for writing apps using [egui](https://github.com/emilk/egui/).
|
||||
This is a template repo for [eframe](https://github.com/emilk/egui/tree/master/eframe), a framework for writing apps using [egui](https://github.com/emilk/egui/).
|
||||
|
||||
The goal is for this to be the simplest way to get started writing a GUI app in Rust.
|
||||
|
||||
|
@ -43,7 +43,7 @@ On Linux you need to first run:
|
|||
|
||||
On Fedora Rawhide you need to run:
|
||||
|
||||
`dnf install clang clang-devel clang-tools-extra speech-dispatcher-devel libxkbcommon-devel pkg-config openssl-devel libxcb-devel fontconfig-devel`
|
||||
`dnf install clang clang-devel clang-tools-extra speech-dispatcher-devel libxkbcommon-devel pkg-config openssl-devel libxcb-devel`
|
||||
|
||||
### Web Locally
|
||||
|
||||
|
@ -51,8 +51,8 @@ You can compile your app to [WASM](https://en.wikipedia.org/wiki/WebAssembly) an
|
|||
|
||||
We use [Trunk](https://trunkrs.dev/) to build for web target.
|
||||
1. Install Trunk with `cargo install --locked trunk`.
|
||||
2. Run `trunk serve` to build and serve on `http://127.0.0.1:8080`. Trunk will rebuild automatically if you edit the project.
|
||||
3. Open `http://127.0.0.1:8080/index.html#dev` in a browser. See the warning below.
|
||||
2. run `trunk serve` to build and serve on `http://127.0.0.1:8080`. will rebuild automatically if you edit the project.
|
||||
3. open `http://127.0.0.1:8080/index.html#dev` in a browser. see the warning below.
|
||||
|
||||
> `assets/sw.js` script will try to cache our app, and loads the cached version when it cannot connect to server allowing your app to work offline (like PWA).
|
||||
> appending `#dev` to `index.html` will skip this caching, allowing us to load the latest builds during development.
|
||||
|
@ -72,4 +72,4 @@ You can test the template app at <https://emilk.github.io/eframe_template/>.
|
|||
|
||||
As of 2022, egui is in active development with frequent releases with breaking changes. [eframe_template](https://github.com/emilk/eframe_template/) will be updated in lock-step to always use the latest version of egui.
|
||||
|
||||
When updating `egui` and `eframe` it is recommended you do so one version at the time, and read about the changes in [the egui changelog](https://github.com/emilk/egui/blob/master/CHANGELOG.md) and [eframe changelog](https://github.com/emilk/egui/blob/master/crates/eframe/CHANGELOG.md).
|
||||
When updating `egui` and `eframe` it is recommended you do so one version at the time, and read about the changes in [the egui changelog](https://github.com/emilk/egui/blob/master/CHANGELOG.md) and [eframe changelog](https://github.com/emilk/egui/blob/master/eframe/CHANGELOG.md).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "egui Template PWA",
|
||||
"name": "Egui Template PWA",
|
||||
"short_name": "egui-template-pwa",
|
||||
"icons": [
|
||||
{
|
||||
|
@ -25,4 +25,4 @@
|
|||
"display": "standalone",
|
||||
"background_color": "white",
|
||||
"theme_color": "white"
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ var cacheName = 'egui-template-pwa';
|
|||
var filesToCache = [
|
||||
'./',
|
||||
'./index.html',
|
||||
'./sshuttle_gui.js',
|
||||
'./sshuttle_gui_bg.wasm',
|
||||
'./eframe_template.js',
|
||||
'./eframe_template_bg.wasm',
|
||||
];
|
||||
|
||||
/* Start the service worker and cache all of the app's content */
|
||||
|
@ -22,4 +22,4 @@ self.addEventListener('fetch', function (e) {
|
|||
return response || fetch(e.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
1
check.sh
1
check.sh
|
@ -8,4 +8,3 @@ cargo fmt --all -- --check
|
|||
cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all
|
||||
cargo test --workspace --all-targets --all-features
|
||||
cargo test --workspace --doc
|
||||
trunk build
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<head>
|
||||
<!-- change this to your project name -->
|
||||
<title>sshuttle_gui</title>
|
||||
<title>eframe template</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" />
|
||||
|
@ -56,8 +56,6 @@
|
|||
overflow: hidden;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Position canvas in center-top: */
|
||||
|
@ -114,7 +112,6 @@
|
|||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
@ -137,4 +134,4 @@
|
|||
|
||||
</html>
|
||||
|
||||
<!-- Powered by egui: https://github.com/emilk/egui/ -->
|
||||
<!-- Powered by egui: https://github.com/emilk/egui/ -->
|
139
src/app.rs
139
src/app.rs
|
@ -1,82 +1,19 @@
|
|||
use egui::Window;
|
||||
use crate::connect_ssh;
|
||||
|
||||
|
||||
/// We derive Deserialize/Serialize so we can persist app state on shutdown.
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
#[serde(default)] // if we add new fields, give them default values when deserializing old state
|
||||
pub struct TemplateApp {
|
||||
// Example stuff:
|
||||
label: String,
|
||||
deets: SshDeets,
|
||||
|
||||
// this how you opt-out of serialization of a member
|
||||
#[serde(skip)]
|
||||
value: f32,
|
||||
}
|
||||
#[derive(serde::Deserialize, serde::Serialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct SshDeets {
|
||||
pub dns: bool,
|
||||
pub user: String,
|
||||
pub ip: String,
|
||||
pub port: String,
|
||||
pub mask: String,
|
||||
}
|
||||
|
||||
impl Default for SshDeets {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
dns: true,
|
||||
user: "No".to_owned(),
|
||||
ip: "127.0.0.1".to_owned(),
|
||||
port: "8080".to_owned(),
|
||||
mask: "".to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SshDeets {
|
||||
pub fn new(self,
|
||||
yeah: bool,
|
||||
username: &str,
|
||||
ip_addy: &str,
|
||||
port_num: &str,
|
||||
masking: String) -> Self
|
||||
{
|
||||
Self {
|
||||
dns: yeah,
|
||||
user: String::from(username),
|
||||
ip: String::from(ip_addy),
|
||||
port: String::from(port_num),
|
||||
mask: masking,
|
||||
}
|
||||
|
||||
}
|
||||
pub fn concat(&self, connect: bool) -> Vec<String> {
|
||||
let mut final_thing: Vec<String> = vec![];
|
||||
if connect == false{
|
||||
if self.dns == true {
|
||||
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.clone());
|
||||
return final_thing;
|
||||
}
|
||||
else {
|
||||
return vec![];
|
||||
}
|
||||
}else {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TemplateApp {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
// Example stuff:
|
||||
deets: SshDeets::default(),
|
||||
label: "Hello World!".to_owned(),
|
||||
value: 2.7,
|
||||
}
|
||||
|
@ -107,66 +44,68 @@ impl eframe::App for TemplateApp {
|
|||
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
let Self { label, value, deets } = self;
|
||||
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
let Self { label, value } = self;
|
||||
|
||||
// Examples of how to create different panels and windows.
|
||||
// Pick whichever suits you.
|
||||
// Tip: a good default choice is to just keep the `CentralPanel`.
|
||||
// For inspiration and more examples, go to https://emilk.github.io/egui
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages!
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
egui::menu::bar(ui, |ui| {
|
||||
ui.menu_button("File", |ui| {
|
||||
if ui.button("Quit").clicked() {
|
||||
_frame.close();
|
||||
frame.quit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
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/eframe");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
ui.text_edit_singleline(&mut deets.port);
|
||||
|
||||
ui.label("check if using --dns flag");
|
||||
ui.checkbox(&mut deets.dns, "dns'd");
|
||||
|
||||
ui.label("include mask flags");
|
||||
ui.text_edit_singleline(&mut deets.mask);
|
||||
|
||||
if ui.button("connect").clicked() {
|
||||
connect_ssh(false, &*deets);
|
||||
}
|
||||
/* ui.heading("eframe template");
|
||||
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::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);
|
||||
});
|
||||
|
||||
|
||||
Window::new("info")
|
||||
.anchor(egui::Align2::RIGHT_TOP, [-5.0,5.0])
|
||||
.default_size([500.0,500.0])
|
||||
.show(ctx, |ui| {
|
||||
ui.label("Make sure you have ssh keys, no password connecting!");
|
||||
});
|
||||
|
||||
if false {
|
||||
egui::Window::new("Window").show(ctx, |ui| {
|
||||
ui.label("Windows can be moved by dragging them.");
|
||||
ui.label("They are automatically sized based on contents.");
|
||||
ui.label("You can turn on resizing and scrolling if you like.");
|
||||
ui.label("You would normally chose either panels OR windows.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -1,21 +1,4 @@
|
|||
#![warn(clippy::all, rust_2018_idioms)]
|
||||
|
||||
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<String, ExitStatus>{
|
||||
let argss = structure.concat(connect);
|
||||
let mut stdout = String::new();
|
||||
if connect == false{
|
||||
let skrunk = Command::new("sshuttle")
|
||||
.args(argss)
|
||||
//.spawn()
|
||||
.stdout(Stdio::piped())
|
||||
.output().unwrap();
|
||||
let stdout = String::from_utf8(skrunk.stdout).unwrap();
|
||||
}
|
||||
Ok(stdout)
|
||||
}
|
||||
|
|
|
@ -9,12 +9,11 @@ fn main() {
|
|||
|
||||
let native_options = eframe::NativeOptions::default();
|
||||
eframe::run_native(
|
||||
"sshuttle",
|
||||
"eframe template",
|
||||
native_options,
|
||||
Box::new(|cc| Box::new(sshuttle_gui::TemplateApp::new(cc))),
|
||||
Box::new(|cc| Box::new(eframe_template::TemplateApp::new(cc))),
|
||||
);
|
||||
}
|
||||
|
||||
// when compiling to web using trunk.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn main() {
|
||||
|
@ -24,11 +23,9 @@ fn main() {
|
|||
// Redirect tracing to console.log and friends:
|
||||
tracing_wasm::set_as_global_default();
|
||||
|
||||
let web_options = eframe::WebOptions::default();
|
||||
eframe::start_web(
|
||||
"the_canvas_id", // hardcode it
|
||||
web_options,
|
||||
Box::new(|cc| Box::new(sshuttle_gui::TemplateApp::new(cc))),
|
||||
Box::new(|cc| Box::new(eframe_template::TemplateApp::new(cc))),
|
||||
)
|
||||
.expect("failed to start eframe");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue