Initial project structure cleanup

This commit is contained in:
litoral05
2026-05-08 16:57:55 +01:00
commit 8075104243
59 changed files with 22335 additions and 0 deletions
+4703
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
[package]
name = "lr-openwrt-tool"
version = "0.1.0"
description = "Litoral Regas VPN Orchestrator"
edition = "2021"
[lib]
name = "lr_openwrt_tool_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-dialog = "2.7.1"
tauri-plugin-fs = "2.5.1"
+1
View File
@@ -0,0 +1 @@
fn main() { tauri_build::build() }
+11
View File
@@ -0,0 +1,11 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Default desktop permissions",
"windows": ["main"],
"permissions": [
"core:default",
"dialog:allow-save",
"fs:allow-write-text-file"
]
}
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
{"default":{"identifier":"default","description":"Default desktop permissions","local":true,"windows":["main"],"permissions":["core:default","dialog:allow-save","fs:allow-write-text-file"]}}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+12
View File
@@ -0,0 +1,12 @@
#[tauri::command]
pub async fn read_text_file(
path: String,
) -> Result<String, String> {
std::fs::read_to_string(&path)
.map_err(|error| {
format!(
"failed to read {}: {}",
path, error,
)
})
}
+4
View File
@@ -0,0 +1,4 @@
pub mod files;
pub mod network;
pub mod router;
pub mod ssh;
+13
View File
@@ -0,0 +1,13 @@
#[tauri::command]
pub async fn ping_host(
ip: String,
) -> Result<bool, String> {
if ip.trim().is_empty() {
return Err(
"ip address cannot be empty"
.to_string(),
);
}
Ok(true)
}
+125
View File
@@ -0,0 +1,125 @@
use std::{
thread,
time::Duration,
};
fn delay() {
thread::sleep(Duration::from_millis(350));
}
#[tauri::command]
pub async fn detect_router(
ip: String,
) -> Result<bool, String> {
delay();
if ip.trim().is_empty() {
return Err(
"router IP is required".into(),
);
}
Ok(true)
}
#[tauri::command]
pub async fn upload_firmware(
ip: String,
firmware_path: String,
) -> Result<String, String> {
delay();
Ok(format!(
"uploaded {} to {}:/tmp/firmware.bin",
firmware_path, ip,
))
}
#[tauri::command]
pub async fn flash_router(
ip: String,
remote_firmware_path: String,
) -> Result<String, String> {
delay();
Ok(format!(
"sysupgrade started on {} with {}",
ip, remote_firmware_path,
))
}
#[tauri::command]
pub async fn wait_for_ssh(
ip: String,
) -> Result<bool, String> {
for _ in 0..3 {
delay();
}
if ip == "198.51.100.1"
|| ip == "192.168.1.1"
{
Ok(true)
} else {
Err(format!(
"SSH timeout waiting for {}",
ip,
))
}
}
#[tauri::command]
pub async fn upload_provisioning_bundle(
ip: String,
env_content: String,
script_content: String,
) -> Result<String, String> {
delay();
Ok(format!(
"uploaded router.env ({} bytes) and provision.sh ({} bytes) to {}",
env_content.len(),
script_content.len(),
ip,
))
}
#[tauri::command]
pub async fn run_provisioning(
ip: String,
) -> Result<String, String> {
delay();
Ok(format!(
"provision.sh completed on {}; fw4/nftables, wg0, DNAT, LuCI over WireGuard configured",
ip,
))
}
#[tauri::command]
pub async fn capture_wireguard_public_key(
_ip: String,
) -> Result<String, String> {
delay();
Ok(
"MOCK_ROUTER_WIREGUARD_PUBLIC_KEY_BASE64="
.into(),
)
}
#[tauri::command]
pub async fn verify_router(
ip: String,
) -> Result<bool, String> {
delay();
if ip == "198.51.100.1" {
Ok(true)
} else {
Err(
"router verification failed"
.into(),
)
}
}
+16
View File
@@ -0,0 +1,16 @@
#[tauri::command]
pub async fn remove_known_host(
ip: String,
) -> Result<String, String> {
if ip.trim().is_empty() {
return Err(
"ip address cannot be empty"
.into(),
);
}
Ok(format!(
"removed stale known_hosts entry for {}",
ip,
))
}
+39
View File
@@ -0,0 +1,39 @@
mod commands;
use commands::{
files::read_text_file,
network::ping_host,
router::{
capture_wireguard_public_key,
detect_router,
flash_router,
run_provisioning,
upload_firmware,
upload_provisioning_bundle,
verify_router,
wait_for_ssh,
},
ssh::remove_known_host,
};
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.invoke_handler(tauri::generate_handler![
read_text_file,
ping_host,
remove_known_host,
detect_router,
upload_firmware,
flash_router,
wait_for_ssh,
upload_provisioning_bundle,
run_provisioning,
capture_wireguard_public_key,
verify_router,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+1
View File
@@ -0,0 +1 @@
fn main() { lr_openwrt_tool_lib::run() }
+35
View File
@@ -0,0 +1,35 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Litoral Regas VPN Orchestrator",
"version": "0.1.0",
"identifier": "com.litoralregas.vpnorchestrator",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "Litoral Regas VPN Orchestrator",
"width": 1440,
"height": 980,
"minWidth": 1100,
"minHeight": 720,
"resizable": false,
"maximized": true
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/icon.ico"
]
}
}