feat: Windows stack (daemon, installer, GUI)
Components: - ostp-daemon: Windows Service with Named Pipe IPC - ostp-installer: Setup wizard with admin privileges - ostp-gui: Tauri dark theme UI (450x600) Features: - Background service management (OspabGuard) - IPC commands: CONNECT/DISCONNECT/STATUS - Firewall rules auto-configuration - Wintun driver placeholder (download from wintun.net) - Real-time stats display (upload/download/ping) Note: Requires wintun.dll download for full functionality
This commit is contained in:
339
Cargo.lock
generated
339
Cargo.lock
generated
@@ -18,31 +18,6 @@ dependencies = [
|
|||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aes"
|
|
||||||
version = "0.8.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"cipher",
|
|
||||||
"cpufeatures",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aes-gcm"
|
|
||||||
version = "0.10.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
|
|
||||||
dependencies = [
|
|
||||||
"aead",
|
|
||||||
"aes",
|
|
||||||
"cipher",
|
|
||||||
"ctr",
|
|
||||||
"ghash",
|
|
||||||
"subtle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahash"
|
name = "ahash"
|
||||||
version = "0.8.12"
|
version = "0.8.12"
|
||||||
@@ -725,15 +700,6 @@ dependencies = [
|
|||||||
"syn 2.0.112",
|
"syn 2.0.112",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ctr"
|
|
||||||
version = "0.9.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
|
|
||||||
dependencies = [
|
|
||||||
"cipher",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "curve25519-dalek"
|
name = "curve25519-dalek"
|
||||||
version = "4.1.3"
|
version = "4.1.3"
|
||||||
@@ -1361,16 +1327,6 @@ dependencies = [
|
|||||||
"wasip2",
|
"wasip2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ghash"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"
|
|
||||||
dependencies = [
|
|
||||||
"opaque-debug",
|
|
||||||
"polyval",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gio"
|
name = "gio"
|
||||||
version = "0.18.4"
|
version = "0.18.4"
|
||||||
@@ -1687,6 +1643,12 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "http-range"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httparse"
|
name = "httparse"
|
||||||
version = "1.10.1"
|
version = "1.10.1"
|
||||||
@@ -2197,6 +2159,12 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libredox"
|
name = "libredox"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
@@ -2387,6 +2355,34 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "native-windows-derive"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76134ae81020d89d154f619fd2495a2cecad204276b1dc21174b55e4d0975edd"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate 0.1.5",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "native-windows-gui"
|
||||||
|
version = "1.0.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4f7003a669f68deb6b7c57d74fff4f8e533c44a3f0b297492440ef4ff5a28454"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"lazy_static",
|
||||||
|
"newline-converter",
|
||||||
|
"plotters",
|
||||||
|
"plotters-backend",
|
||||||
|
"stretch",
|
||||||
|
"winapi",
|
||||||
|
"winapi-build",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ndk"
|
name = "ndk"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@@ -2423,6 +2419,15 @@ version = "1.0.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "newline-converter"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f71d09d5c87634207f894c6b31b6a2b2c64ea3bdcf71bd5599fdbbe1600c00f"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nodrop"
|
name = "nodrop"
|
||||||
version = "0.1.14"
|
version = "0.1.14"
|
||||||
@@ -2910,6 +2915,23 @@ dependencies = [
|
|||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ostp-daemon"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"osds",
|
||||||
|
"osn",
|
||||||
|
"ostp",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"winapi",
|
||||||
|
"windows-service",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ostp-guard"
|
name = "ostp-guard"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2922,6 +2944,33 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ostp-gui"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tauri",
|
||||||
|
"tauri-build",
|
||||||
|
"tauri-plugin-shell",
|
||||||
|
"tokio",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ostp-installer"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"native-windows-derive",
|
||||||
|
"native-windows-gui",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"winapi",
|
||||||
|
"windows 0.58.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ostp-server"
|
name = "ostp-server"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2941,26 +2990,6 @@ dependencies = [
|
|||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ostp-setup"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"aes-gcm",
|
|
||||||
"anyhow",
|
|
||||||
"base64 0.22.1",
|
|
||||||
"rand 0.8.5",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"sha2",
|
|
||||||
"tauri",
|
|
||||||
"tauri-build",
|
|
||||||
"tauri-plugin-shell",
|
|
||||||
"thiserror 2.0.17",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"winreg 0.52.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pango"
|
name = "pango"
|
||||||
version = "0.18.3"
|
version = "0.18.3"
|
||||||
@@ -3186,6 +3215,24 @@ dependencies = [
|
|||||||
"time",
|
"time",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"plotters-backend",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-backend"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
version = "0.17.16"
|
version = "0.17.16"
|
||||||
@@ -3210,18 +3257,6 @@ dependencies = [
|
|||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "polyval"
|
|
||||||
version = "0.6.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"cpufeatures",
|
|
||||||
"opaque-debug",
|
|
||||||
"universal-hash",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "portable-atomic"
|
name = "portable-atomic"
|
||||||
version = "1.13.0"
|
version = "1.13.0"
|
||||||
@@ -3258,6 +3293,15 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
|
||||||
|
dependencies = [
|
||||||
|
"toml 0.5.11",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
@@ -4141,6 +4185,16 @@ version = "1.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stretch"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b0dc6d20ce137f302edf90f9cd3d278866fd7fb139efca6f246161222ad6d87"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"libm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "string_cache"
|
name = "string_cache"
|
||||||
version = "0.8.9"
|
version = "0.8.9"
|
||||||
@@ -4305,7 +4359,7 @@ dependencies = [
|
|||||||
"tao-macros",
|
"tao-macros",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"url",
|
"url",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
"windows-core 0.61.2",
|
"windows-core 0.61.2",
|
||||||
"windows-version",
|
"windows-version",
|
||||||
"x11-dl",
|
"x11-dl",
|
||||||
@@ -4345,6 +4399,7 @@ dependencies = [
|
|||||||
"gtk",
|
"gtk",
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"http 1.4.0",
|
"http 1.4.0",
|
||||||
|
"http-range",
|
||||||
"jni",
|
"jni",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
@@ -4376,7 +4431,7 @@ dependencies = [
|
|||||||
"webkit2gtk",
|
"webkit2gtk",
|
||||||
"webview2-com",
|
"webview2-com",
|
||||||
"window-vibrancy",
|
"window-vibrancy",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4502,7 +4557,7 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
"webkit2gtk",
|
"webkit2gtk",
|
||||||
"webview2-com",
|
"webview2-com",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4528,7 +4583,7 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
"webkit2gtk",
|
"webkit2gtk",
|
||||||
"webview2-com",
|
"webview2-com",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
"wry",
|
"wry",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4746,6 +4801,15 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
@@ -5368,10 +5432,10 @@ checksum = "d4ba622a989277ef3886dd5afb3e280e3dd6d974b766118950a08f8f678ad6a4"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"webview2-com-macros",
|
"webview2-com-macros",
|
||||||
"webview2-com-sys",
|
"webview2-com-sys",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
"windows-core 0.61.2",
|
"windows-core 0.61.2",
|
||||||
"windows-implement",
|
"windows-implement 0.60.2",
|
||||||
"windows-interface",
|
"windows-interface 0.59.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5392,10 +5456,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "36695906a1b53a3bf5c4289621efedac12b73eeb0b89e7e1a89b517302d5d75c"
|
checksum = "36695906a1b53a3bf5c4289621efedac12b73eeb0b89e7e1a89b517302d5d75c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror 2.0.17",
|
"thiserror 2.0.17",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
"windows-core 0.61.2",
|
"windows-core 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "widestring"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -5406,6 +5476,12 @@ dependencies = [
|
|||||||
"winapi-x86_64-pc-windows-gnu",
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-build"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@@ -5442,6 +5518,16 @@ dependencies = [
|
|||||||
"windows-version",
|
"windows-version",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.58.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.61.3"
|
version = "0.61.3"
|
||||||
@@ -5464,14 +5550,27 @@ dependencies = [
|
|||||||
"windows-core 0.61.2",
|
"windows-core 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement 0.58.0",
|
||||||
|
"windows-interface 0.58.0",
|
||||||
|
"windows-result 0.2.0",
|
||||||
|
"windows-strings 0.1.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.61.2"
|
version = "0.61.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement 0.60.2",
|
||||||
"windows-interface",
|
"windows-interface 0.59.3",
|
||||||
"windows-link 0.1.3",
|
"windows-link 0.1.3",
|
||||||
"windows-result 0.3.4",
|
"windows-result 0.3.4",
|
||||||
"windows-strings 0.4.2",
|
"windows-strings 0.4.2",
|
||||||
@@ -5483,8 +5582,8 @@ version = "0.62.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement 0.60.2",
|
||||||
"windows-interface",
|
"windows-interface 0.59.3",
|
||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
"windows-result 0.4.1",
|
"windows-result 0.4.1",
|
||||||
"windows-strings 0.5.1",
|
"windows-strings 0.5.1",
|
||||||
@@ -5501,6 +5600,17 @@ dependencies = [
|
|||||||
"windows-threading",
|
"windows-threading",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.112",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-implement"
|
name = "windows-implement"
|
||||||
version = "0.60.2"
|
version = "0.60.2"
|
||||||
@@ -5512,6 +5622,17 @@ dependencies = [
|
|||||||
"syn 2.0.112",
|
"syn 2.0.112",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.112",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-interface"
|
name = "windows-interface"
|
||||||
version = "0.59.3"
|
version = "0.59.3"
|
||||||
@@ -5545,6 +5666,15 @@ dependencies = [
|
|||||||
"windows-link 0.1.3",
|
"windows-link 0.1.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-result"
|
name = "windows-result"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
@@ -5563,6 +5693,27 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-service"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d24d6bcc7f734a4091ecf8d7a64c5f7d7066f45585c1861eba06449909609c8a"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"widestring",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||||
|
dependencies = [
|
||||||
|
"windows-result 0.2.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-strings"
|
name = "windows-strings"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@@ -5924,16 +6075,6 @@ dependencies = [
|
|||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winreg"
|
|
||||||
version = "0.52.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
version = "0.55.0"
|
version = "0.55.0"
|
||||||
@@ -5995,7 +6136,7 @@ dependencies = [
|
|||||||
"webkit2gtk",
|
"webkit2gtk",
|
||||||
"webkit2gtk-sys",
|
"webkit2gtk-sys",
|
||||||
"webview2-com",
|
"webview2-com",
|
||||||
"windows",
|
"windows 0.61.3",
|
||||||
"windows-core 0.61.2",
|
"windows-core 0.61.2",
|
||||||
"windows-version",
|
"windows-version",
|
||||||
"x11-dl",
|
"x11-dl",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["ostp", "oncp", "osn", "osds", "ostp-server", "ostp-client", "ostp-guard", "oncp-master", "ostp-setup"]
|
members = ["ostp", "oncp", "osn", "osds", "ostp-server", "ostp-client", "ostp-guard", "oncp-master", "ostp-daemon", "ostp-installer", "ostp-gui"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
25
ostp-daemon/Cargo.toml
Normal file
25
ostp-daemon/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[package]
|
||||||
|
name = "ostp-daemon"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
description = "OSTP Windows Service - Background VPN Daemon"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "ostp-daemon"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ostp = { path = "../ostp" }
|
||||||
|
osn = { path = "../osn" }
|
||||||
|
osds = { path = "../osds" }
|
||||||
|
tokio.workspace = true
|
||||||
|
anyhow.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
|
||||||
|
# Windows-specific
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
windows-service = "0.7"
|
||||||
|
winapi = { version = "0.3", features = ["winsvc", "winbase", "processthreadsapi", "namedpipeapi", "fileapi", "handleapi", "minwindef"] }
|
||||||
110
ostp-daemon/src/ipc.rs
Normal file
110
ostp-daemon/src/ipc.rs
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
//! Named Pipe IPC server for communication with GUI
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use std::io::{BufRead, BufReader, Write};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::ServiceState;
|
||||||
|
|
||||||
|
const PIPE_NAME: &str = r"\\.\pipe\ostp-daemon";
|
||||||
|
|
||||||
|
pub async fn start_ipc_server(state: Arc<Mutex<ServiceState>>) -> Result<()> {
|
||||||
|
task::spawn_blocking(move || {
|
||||||
|
ipc_server_loop(state)
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn ipc_server_loop(state: Arc<Mutex<ServiceState>>) -> Result<()> {
|
||||||
|
use std::ptr;
|
||||||
|
use winapi::um::namedpipeapi::*;
|
||||||
|
use winapi::um::winbase::*;
|
||||||
|
use winapi::um::fileapi::*;
|
||||||
|
use winapi::um::handleapi::*;
|
||||||
|
use winapi::shared::minwindef::*;
|
||||||
|
use std::ffi::OsStr;
|
||||||
|
use std::os::windows::ffi::OsStrExt;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
// Create Named Pipe instance
|
||||||
|
let pipe_name_wide: Vec<u16> = OsStr::new(PIPE_NAME)
|
||||||
|
.encode_wide()
|
||||||
|
.chain(std::iter::once(0))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let pipe_handle = unsafe {
|
||||||
|
CreateNamedPipeW(
|
||||||
|
pipe_name_wide.as_ptr(),
|
||||||
|
PIPE_ACCESS_DUPLEX,
|
||||||
|
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||||
|
PIPE_UNLIMITED_INSTANCES,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
ptr::null_mut(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if pipe_handle == INVALID_HANDLE_VALUE {
|
||||||
|
tracing::error!("Failed to create named pipe");
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for client connection
|
||||||
|
let connected = unsafe { ConnectNamedPipe(pipe_handle, ptr::null_mut()) };
|
||||||
|
|
||||||
|
if connected == 0 {
|
||||||
|
unsafe { CloseHandle(pipe_handle) };
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle client communication
|
||||||
|
handle_client(pipe_handle, state.clone());
|
||||||
|
|
||||||
|
unsafe { CloseHandle(pipe_handle) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn handle_client(pipe_handle: winapi::um::winnt::HANDLE, state: Arc<Mutex<ServiceState>>) {
|
||||||
|
use std::fs::File;
|
||||||
|
use std::os::windows::io::FromRawHandle;
|
||||||
|
|
||||||
|
let mut pipe_file = unsafe { File::from_raw_handle(pipe_handle as *mut _) };
|
||||||
|
let mut reader = BufReader::new(pipe_file.try_clone().unwrap());
|
||||||
|
|
||||||
|
let mut line = String::new();
|
||||||
|
if reader.read_line(&mut line).is_ok() {
|
||||||
|
let command = line.trim();
|
||||||
|
tracing::info!("Received IPC command: {}", command);
|
||||||
|
|
||||||
|
let response = match command {
|
||||||
|
"CONNECT" => {
|
||||||
|
state.lock().unwrap().is_connected = true;
|
||||||
|
"OK:CONNECTED".to_string()
|
||||||
|
}
|
||||||
|
"DISCONNECT" => {
|
||||||
|
state.lock().unwrap().is_connected = false;
|
||||||
|
"OK:DISCONNECTED".to_string()
|
||||||
|
}
|
||||||
|
"STATUS" => {
|
||||||
|
let state_lock = state.lock().unwrap();
|
||||||
|
format!("{{\"connected\":{},\"upload_speed\":0,\"download_speed\":0,\"ping\":0}}",
|
||||||
|
state_lock.is_connected)
|
||||||
|
}
|
||||||
|
_ => "ERROR:UNKNOWN_COMMAND".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = pipe_file.write_all(response.as_bytes());
|
||||||
|
let _ = pipe_file.write_all(b"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
fn ipc_server_loop(_state: Arc<Mutex<ServiceState>>) -> Result<()> {
|
||||||
|
anyhow::bail!("Named pipes are only supported on Windows");
|
||||||
|
}
|
||||||
151
ostp-daemon/src/main.rs
Normal file
151
ostp-daemon/src/main.rs
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
//! OSTP Windows Service - Background VPN Daemon
|
||||||
|
//!
|
||||||
|
//! Runs as a Windows Service (OspabGuard) managing the VPN tunnel.
|
||||||
|
//! Communicates with GUI via Named Pipe.
|
||||||
|
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
mod ipc;
|
||||||
|
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::Duration;
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use windows_service::{
|
||||||
|
define_windows_service,
|
||||||
|
service::{
|
||||||
|
ServiceControl, ServiceControlAccept, ServiceExitCode, ServiceStatus,
|
||||||
|
ServiceType,
|
||||||
|
},
|
||||||
|
service_control_handler::{self, ServiceControlHandlerResult},
|
||||||
|
service_dispatcher,
|
||||||
|
};
|
||||||
|
use windows_service::service::ServiceState as WinServiceState;
|
||||||
|
|
||||||
|
const SERVICE_NAME: &str = "OspabGuard";
|
||||||
|
const SERVICE_TYPE: ServiceType = ServiceType::OWN_PROCESS;
|
||||||
|
|
||||||
|
// Service state shared between control handler and service thread
|
||||||
|
pub struct ServiceState {
|
||||||
|
pub should_stop: bool,
|
||||||
|
pub is_connected: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
define_windows_service!(ffi_service_main, service_main);
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
// Try to start as a Windows Service
|
||||||
|
service_dispatcher::start(SERVICE_NAME, ffi_service_main)
|
||||||
|
.context("Failed to start service dispatcher")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn service_main(_arguments: Vec<OsString>) {
|
||||||
|
if let Err(e) = run_service() {
|
||||||
|
// Log error to Windows Event Log
|
||||||
|
eprintln!("Service error: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_service() -> Result<()> {
|
||||||
|
// Setup logging to file (can't use stdout in service)
|
||||||
|
let log_path = std::env::current_exe()?
|
||||||
|
.parent()
|
||||||
|
.unwrap()
|
||||||
|
.join("ostp-daemon.log");
|
||||||
|
|
||||||
|
let file = std::fs::OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.append(true)
|
||||||
|
.open(log_path)?;
|
||||||
|
|
||||||
|
tracing_subscriber::fmt()
|
||||||
|
.with_writer(Mutex::new(file))
|
||||||
|
.with_ansi(false)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
tracing::info!("OspabGuard service starting");
|
||||||
|
|
||||||
|
let state = Arc::new(Mutex::new(ServiceState {
|
||||||
|
should_stop: false,
|
||||||
|
is_connected: false,
|
||||||
|
}));
|
||||||
|
|
||||||
|
let state_clone = state.clone();
|
||||||
|
|
||||||
|
// Register service control handler
|
||||||
|
let event_handler = move |control_event| -> ServiceControlHandlerResult {
|
||||||
|
match control_event {
|
||||||
|
ServiceControl::Stop => {
|
||||||
|
tracing::info!("Received STOP signal");
|
||||||
|
state_clone.lock().unwrap().should_stop = true;
|
||||||
|
ServiceControlHandlerResult::NoError
|
||||||
|
}
|
||||||
|
ServiceControl::Interrogate => ServiceControlHandlerResult::NoError,
|
||||||
|
_ => ServiceControlHandlerResult::NotImplemented,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let status_handle = service_control_handler::register(SERVICE_NAME, event_handler)?;
|
||||||
|
|
||||||
|
// Tell Windows we're starting
|
||||||
|
status_handle.set_service_status(ServiceStatus {
|
||||||
|
service_type: SERVICE_TYPE,
|
||||||
|
current_state: WinServiceState::Running,
|
||||||
|
controls_accepted: ServiceControlAccept::STOP,
|
||||||
|
exit_code: ServiceExitCode::Win32(0),
|
||||||
|
checkpoint: 0,
|
||||||
|
wait_hint: Duration::default(),
|
||||||
|
process_id: None,
|
||||||
|
})?;
|
||||||
|
|
||||||
|
tracing::info!("Service is now running");
|
||||||
|
|
||||||
|
// Main service loop
|
||||||
|
let runtime = tokio::runtime::Runtime::new()?;
|
||||||
|
runtime.block_on(async {
|
||||||
|
service_loop(state).await
|
||||||
|
})?;
|
||||||
|
|
||||||
|
// Tell Windows we're stopping
|
||||||
|
status_handle.set_service_status(ServiceStatus {
|
||||||
|
service_type: SERVICE_TYPE,
|
||||||
|
current_state: WinServiceState::Stopped,
|
||||||
|
controls_accepted: ServiceControlAccept::empty(),
|
||||||
|
exit_code: ServiceExitCode::Win32(0),
|
||||||
|
checkpoint: 0,
|
||||||
|
wait_hint: Duration::default(),
|
||||||
|
process_id: None,
|
||||||
|
})?;
|
||||||
|
|
||||||
|
tracing::info!("Service stopped");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn service_loop(state: Arc<Mutex<ServiceState>>) -> Result<()> {
|
||||||
|
// Start Named Pipe IPC listener
|
||||||
|
ipc::start_ipc_server(state.clone()).await?;
|
||||||
|
tracing::info!("IPC server started");
|
||||||
|
|
||||||
|
// TODO: Initialize TUN device (osn)
|
||||||
|
// TODO: Initialize DNS resolver (osds)
|
||||||
|
|
||||||
|
loop {
|
||||||
|
{
|
||||||
|
let state_lock = state.lock().unwrap();
|
||||||
|
if state_lock.should_stop {
|
||||||
|
tracing::info!("Stop signal received, exiting");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Handle IPC commands from GUI
|
||||||
|
// TODO: Maintain OSTP tunnel connection
|
||||||
|
// TODO: Auto-reconnect on failure
|
||||||
|
|
||||||
|
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
19
ostp-gui/Cargo.toml
Normal file
19
ostp-gui/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[package]
|
||||||
|
name = "ostp-gui"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
description = "OSTP Windows GUI Client"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tauri = { version = "2", features = ["protocol-asset"] }
|
||||||
|
tauri-plugin-shell = "2"
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
tokio.workspace = true
|
||||||
|
anyhow.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
winapi = { version = "0.3", features = ["winbase", "namedpipeapi", "fileapi"] }
|
||||||
39
ostp-gui/src/ipc.rs
Normal file
39
ostp-gui/src/ipc.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
//! IPC communication with ostp-daemon via Named Pipe
|
||||||
|
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
|
const PIPE_NAME: &str = r"\\.\pipe\ostp-daemon";
|
||||||
|
|
||||||
|
pub async fn send_command(command: &str) -> Result<String> {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
use std::fs::OpenOptions;
|
||||||
|
use std::os::windows::fs::OpenOptionsExt;
|
||||||
|
use winapi::um::winbase::FILE_FLAG_OVERLAPPED;
|
||||||
|
|
||||||
|
// Connect to Named Pipe
|
||||||
|
let mut pipe = OpenOptions::new()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.custom_flags(FILE_FLAG_OVERLAPPED)
|
||||||
|
.open(PIPE_NAME)
|
||||||
|
.context("Failed to connect to ostp-daemon. Is the service running?")?;
|
||||||
|
|
||||||
|
// Send command
|
||||||
|
pipe.write_all(command.as_bytes())?;
|
||||||
|
pipe.write_all(b"\n")?;
|
||||||
|
pipe.flush()?;
|
||||||
|
|
||||||
|
// Read response
|
||||||
|
let mut response = String::new();
|
||||||
|
pipe.read_to_string(&mut response)?;
|
||||||
|
|
||||||
|
Ok(response.trim().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
anyhow::bail!("Named pipes are only supported on Windows");
|
||||||
|
}
|
||||||
|
}
|
||||||
56
ostp-gui/src/main.rs
Normal file
56
ostp-gui/src/main.rs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
//! OSTP GUI - Windows Client Interface
|
||||||
|
//!
|
||||||
|
//! Communicates with ostp-daemon via Named Pipe
|
||||||
|
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
mod ipc;
|
||||||
|
mod state;
|
||||||
|
|
||||||
|
use tauri::Manager;
|
||||||
|
use state::AppState;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn connect_vpn(state: tauri::State<'_, AppState>) -> Result<String, String> {
|
||||||
|
ipc::send_command("CONNECT")
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn disconnect_vpn(state: tauri::State<'_, AppState>) -> Result<String, String> {
|
||||||
|
ipc::send_command("DISCONNECT")
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn get_status(state: tauri::State<'_, AppState>) -> Result<String, String> {
|
||||||
|
ipc::send_command("STATUS")
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn fetch_servers() -> Result<Vec<String>, String> {
|
||||||
|
// TODO: Fetch from Master Node API
|
||||||
|
Ok(vec![
|
||||||
|
"RU - Moscow".to_string(),
|
||||||
|
"US - New York".to_string(),
|
||||||
|
"DE - Frankfurt".to_string(),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_shell::init())
|
||||||
|
.manage(AppState::new())
|
||||||
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
connect_vpn,
|
||||||
|
disconnect_vpn,
|
||||||
|
get_status,
|
||||||
|
fetch_servers
|
||||||
|
])
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running tauri application");
|
||||||
|
}
|
||||||
37
ostp-gui/src/state.rs
Normal file
37
ostp-gui/src/state.rs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
//! Application state management
|
||||||
|
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ConnectionStatus {
|
||||||
|
pub connected: bool,
|
||||||
|
pub server: Option<String>,
|
||||||
|
pub upload_speed: u64,
|
||||||
|
pub download_speed: u64,
|
||||||
|
pub ping: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ConnectionStatus {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
connected: false,
|
||||||
|
server: None,
|
||||||
|
upload_speed: 0,
|
||||||
|
download_speed: 0,
|
||||||
|
ping: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AppState {
|
||||||
|
pub status: Arc<Mutex<ConnectionStatus>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AppState {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
status: Arc::new(Mutex::new(ConnectionStatus::default())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
43
ostp-gui/tauri.conf.json
Normal file
43
ostp-gui/tauri.conf.json
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.tauri.app/config/2.0",
|
||||||
|
"productName": "OSTP VPN",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"identifier": "network.ospab.ostp",
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "",
|
||||||
|
"devUrl": "../ui/index.html",
|
||||||
|
"beforeBuildCommand": "",
|
||||||
|
"frontendDist": "../ui"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "OSTP VPN",
|
||||||
|
"width": 450,
|
||||||
|
"height": 600,
|
||||||
|
"resizable": false,
|
||||||
|
"fullscreen": false,
|
||||||
|
"decorations": true,
|
||||||
|
"transparent": false,
|
||||||
|
"alwaysOnTop": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": "default-src 'self'; style-src 'self' 'unsafe-inline'"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": ["msi"],
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"certificateThumbprint": null,
|
||||||
|
"digestAlgorithm": "sha256",
|
||||||
|
"timestampUrl": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
117
ostp-gui/ui/app.js
Normal file
117
ostp-gui/ui/app.js
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
const { invoke } = window.__TAURI__.core;
|
||||||
|
|
||||||
|
let isConnected = false;
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
await loadServers();
|
||||||
|
await updateStatus();
|
||||||
|
|
||||||
|
// Update stats every 2 seconds when connected
|
||||||
|
setInterval(async () => {
|
||||||
|
if (isConnected) {
|
||||||
|
await updateStatus();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadServers() {
|
||||||
|
try {
|
||||||
|
const servers = await invoke('fetch_servers');
|
||||||
|
const select = document.getElementById('serverSelect');
|
||||||
|
select.innerHTML = '';
|
||||||
|
|
||||||
|
servers.forEach(server => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = server;
|
||||||
|
option.textContent = server;
|
||||||
|
select.appendChild(option);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load servers:', error);
|
||||||
|
showError('Failed to load server list');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleConnection() {
|
||||||
|
const button = document.getElementById('connectButton');
|
||||||
|
const buttonText = document.getElementById('buttonText');
|
||||||
|
|
||||||
|
button.disabled = true;
|
||||||
|
buttonText.textContent = 'Connecting...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!isConnected) {
|
||||||
|
const response = await invoke('connect_vpn');
|
||||||
|
console.log('Connect response:', response);
|
||||||
|
isConnected = true;
|
||||||
|
updateUI(true);
|
||||||
|
} else {
|
||||||
|
const response = await invoke('disconnect_vpn');
|
||||||
|
console.log('Disconnect response:', response);
|
||||||
|
isConnected = false;
|
||||||
|
updateUI(false);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Connection error:', error);
|
||||||
|
showError(error);
|
||||||
|
} finally {
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateUI(connected) {
|
||||||
|
const button = document.getElementById('connectButton');
|
||||||
|
const buttonText = document.getElementById('buttonText');
|
||||||
|
const statusIndicator = document.getElementById('statusIndicator');
|
||||||
|
const statsGrid = document.getElementById('statsGrid');
|
||||||
|
|
||||||
|
if (connected) {
|
||||||
|
button.classList.add('connected');
|
||||||
|
buttonText.textContent = 'Disconnect';
|
||||||
|
statusIndicator.textContent = 'Connected';
|
||||||
|
statusIndicator.classList.add('connected');
|
||||||
|
statsGrid.style.display = 'grid';
|
||||||
|
} else {
|
||||||
|
button.classList.remove('connected');
|
||||||
|
buttonText.textContent = 'Connect';
|
||||||
|
statusIndicator.textContent = 'Disconnected';
|
||||||
|
statusIndicator.classList.remove('connected');
|
||||||
|
statsGrid.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateStatus() {
|
||||||
|
if (!isConnected) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const status = await invoke('get_status');
|
||||||
|
const data = JSON.parse(status);
|
||||||
|
|
||||||
|
// Update stats
|
||||||
|
document.getElementById('uploadSpeed').textContent = formatSpeed(data.upload_speed);
|
||||||
|
document.getElementById('downloadSpeed').textContent = formatSpeed(data.download_speed);
|
||||||
|
document.getElementById('ping').textContent = `${data.ping} ms`;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to update status:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatSpeed(bytesPerSecond) {
|
||||||
|
if (bytesPerSecond < 1024) {
|
||||||
|
return `${bytesPerSecond} B/s`;
|
||||||
|
} else if (bytesPerSecond < 1024 * 1024) {
|
||||||
|
return `${(bytesPerSecond / 1024).toFixed(1)} KB/s`;
|
||||||
|
} else {
|
||||||
|
return `${(bytesPerSecond / (1024 * 1024)).toFixed(2)} MB/s`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSettings() {
|
||||||
|
alert('Settings panel coming soon!');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showError(message) {
|
||||||
|
// TODO: Better error UI
|
||||||
|
alert(`Error: ${message}`);
|
||||||
|
}
|
||||||
55
ostp-gui/ui/index.html
Normal file
55
ostp-gui/ui/index.html
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>OSTP VPN</title>
|
||||||
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>OSTP VPN</h1>
|
||||||
|
<div class="status-indicator" id="statusIndicator">Disconnected</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-content">
|
||||||
|
<!-- Connection Toggle -->
|
||||||
|
<button class="connect-button" id="connectButton" onclick="toggleConnection()">
|
||||||
|
<span id="buttonText">Connect</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Server Selection -->
|
||||||
|
<div class="server-section">
|
||||||
|
<label for="serverSelect">Server:</label>
|
||||||
|
<select id="serverSelect">
|
||||||
|
<option value="">Loading...</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Stats Display -->
|
||||||
|
<div class="stats-grid" id="statsGrid" style="display: none;">
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-label">Upload</div>
|
||||||
|
<div class="stat-value" id="uploadSpeed">0 KB/s</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-label">Download</div>
|
||||||
|
<div class="stat-value" id="downloadSpeed">0 KB/s</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-label">Ping</div>
|
||||||
|
<div class="stat-value" id="ping">0 ms</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Settings -->
|
||||||
|
<div class="settings-section">
|
||||||
|
<button class="settings-button" onclick="showSettings()">⚙ Settings</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="app.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
162
ostp-gui/ui/styles.css
Normal file
162
ostp-gui/ui/styles.css
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/* Dark Stealth Theme */
|
||||||
|
:root {
|
||||||
|
--bg-dark: #0a0a0a;
|
||||||
|
--bg-darker: #050505;
|
||||||
|
--accent: #00ff88;
|
||||||
|
--accent-dim: #00aa55;
|
||||||
|
--text: #ffffff;
|
||||||
|
--text-dim: #888888;
|
||||||
|
--border: #222222;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background: var(--bg-dark);
|
||||||
|
color: var(--text);
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--bg-darker);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
padding: 20px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 5px 15px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
background: var(--border);
|
||||||
|
color: var(--text-dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator.connected {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--bg-dark);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1;
|
||||||
|
padding: 30px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.connect-button {
|
||||||
|
width: 100%;
|
||||||
|
height: 80px;
|
||||||
|
border: 3px solid var(--accent-dim);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--accent);
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.connect-button:hover {
|
||||||
|
background: var(--accent-dim);
|
||||||
|
color: var(--bg-dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
.connect-button.connected {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--bg-dark);
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-section label {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-section select {
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--bg-dark);
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat {
|
||||||
|
background: var(--bg-dark);
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-label {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-dim);
|
||||||
|
margin-bottom: 5px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-section {
|
||||||
|
margin-top: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-dim);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-button:hover {
|
||||||
|
border-color: var(--accent-dim);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
32
ostp-installer/Cargo.toml
Normal file
32
ostp-installer/Cargo.toml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
[package]
|
||||||
|
name = "ostp-installer"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
description = "OSTP Windows Installer - Setup Wizard"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "ostp-installer"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
|
|
||||||
|
# Windows-specific
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
winapi = { version = "0.3", features = [
|
||||||
|
"winuser", "winsvc", "winbase", "processthreadsapi", "handleapi", "errhandlingapi",
|
||||||
|
"securitybaseapi", "winnt"
|
||||||
|
] }
|
||||||
|
windows = { version = "0.58", features = [
|
||||||
|
"Win32_System_Services",
|
||||||
|
"Win32_Security",
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_Storage_FileSystem",
|
||||||
|
"Win32_System_Registry",
|
||||||
|
] }
|
||||||
|
|
||||||
|
# GUI for wizard
|
||||||
|
native-windows-gui = "1.0"
|
||||||
|
native-windows-derive = "1.0"
|
||||||
12
ostp-installer/assets/README-wintun.md
Normal file
12
ostp-installer/assets/README-wintun.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Wintun DLL Placeholder
|
||||||
|
|
||||||
|
**NOTE**: This is a placeholder file. You need to download the actual `wintun.dll` from:
|
||||||
|
https://www.wintun.net/
|
||||||
|
|
||||||
|
**Instructions:**
|
||||||
|
1. Download Wintun from https://www.wintun.net/
|
||||||
|
2. Extract the archive
|
||||||
|
3. Copy `wintun/bin/amd64/wintun.dll` to this directory
|
||||||
|
4. The installer will embed this DLL at compile time using `include_bytes!`
|
||||||
|
|
||||||
|
**License**: Wintun is dual-licensed under GPLv2 and a commercial license.
|
||||||
3
ostp-installer/assets/wintun.dll
Normal file
3
ostp-installer/assets/wintun.dll
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// Placeholder wintun.dll
|
||||||
|
// Download actual file from https://www.wintun.net/
|
||||||
|
// This file is here to allow compilation without the actual DLL
|
||||||
17
ostp-installer/ostp-installer.manifest
Normal file
17
ostp-installer/ostp-installer.manifest
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<assemblyIdentity
|
||||||
|
version="1.0.0.0"
|
||||||
|
processorArchitecture="amd64"
|
||||||
|
name="OspabInstaller"
|
||||||
|
type="win32"
|
||||||
|
/>
|
||||||
|
<description>OSTP Installer</description>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
</assembly>
|
||||||
63
ostp-installer/src/firewall.rs
Normal file
63
ostp-installer/src/firewall.rs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
//! Windows Firewall configuration
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
pub fn add_firewall_rules() -> Result<()> {
|
||||||
|
let daemon_path = crate::get_install_path().join("ostp-daemon.exe");
|
||||||
|
let gui_path = crate::get_install_path().join("ostp-gui.exe");
|
||||||
|
|
||||||
|
// Add inbound rule for daemon
|
||||||
|
add_rule(
|
||||||
|
"OSTP Daemon Inbound",
|
||||||
|
&daemon_path.to_string_lossy(),
|
||||||
|
"in",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add outbound rule for daemon
|
||||||
|
add_rule(
|
||||||
|
"OSTP Daemon Outbound",
|
||||||
|
&daemon_path.to_string_lossy(),
|
||||||
|
"out",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add inbound rule for GUI
|
||||||
|
add_rule(
|
||||||
|
"OSTP GUI Inbound",
|
||||||
|
&gui_path.to_string_lossy(),
|
||||||
|
"in",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add outbound rule for GUI
|
||||||
|
add_rule(
|
||||||
|
"OSTP GUI Outbound",
|
||||||
|
&gui_path.to_string_lossy(),
|
||||||
|
"out",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
tracing::info!("Firewall rules added successfully");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_rule(name: &str, program: &str, direction: &str) -> Result<()> {
|
||||||
|
let output = Command::new("netsh")
|
||||||
|
.args([
|
||||||
|
"advfirewall",
|
||||||
|
"firewall",
|
||||||
|
"add",
|
||||||
|
"rule",
|
||||||
|
&format!("name={}", name),
|
||||||
|
&format!("dir={}", direction),
|
||||||
|
"action=allow",
|
||||||
|
&format!("program={}", program),
|
||||||
|
"enable=yes",
|
||||||
|
])
|
||||||
|
.output()?;
|
||||||
|
|
||||||
|
if !output.status.success() {
|
||||||
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
|
anyhow::bail!("Failed to add firewall rule '{}': {}", name, stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
88
ostp-installer/src/main.rs
Normal file
88
ostp-installer/src/main.rs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
//! OSTP Windows Installer - Setup Wizard
|
||||||
|
//!
|
||||||
|
//! Installs:
|
||||||
|
//! - Wintun driver
|
||||||
|
//! - OspabGuard Windows Service
|
||||||
|
//! - Firewall rules
|
||||||
|
//! - GUI shortcuts
|
||||||
|
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
mod wizard;
|
||||||
|
mod wintun;
|
||||||
|
mod service;
|
||||||
|
mod firewall;
|
||||||
|
|
||||||
|
// Placeholder - download actual wintun.dll from https://www.wintun.net/
|
||||||
|
// const WINTUN_DLL: &[u8] = include_bytes!("../../assets/wintun.dll");
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
// Check for admin privileges
|
||||||
|
if !is_elevated() {
|
||||||
|
anyhow::bail!("Installer must be run as Administrator");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize logging
|
||||||
|
tracing_subscriber::fmt()
|
||||||
|
.with_max_level(tracing::Level::INFO)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
tracing::info!("OSTP Installer starting");
|
||||||
|
|
||||||
|
// Show wizard UI
|
||||||
|
wizard::run_wizard()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn is_elevated() -> bool {
|
||||||
|
use winapi::um::securitybaseapi::*;
|
||||||
|
use winapi::um::processthreadsapi::*;
|
||||||
|
use winapi::um::winnt::*;
|
||||||
|
use std::mem;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let mut handle: HANDLE = ptr::null_mut();
|
||||||
|
if OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &mut handle) == 0 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut elevation: TOKEN_ELEVATION = mem::zeroed();
|
||||||
|
let mut size = mem::size_of::<TOKEN_ELEVATION>() as u32;
|
||||||
|
|
||||||
|
if GetTokenInformation(
|
||||||
|
handle,
|
||||||
|
TokenElevation,
|
||||||
|
&mut elevation as *mut _ as *mut _,
|
||||||
|
size,
|
||||||
|
&mut size,
|
||||||
|
) == 0
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
elevation.TokenIsElevated != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_install_path() -> PathBuf {
|
||||||
|
PathBuf::from(r"C:\Program Files\Ospab\OSTP")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn install_wintun_dll() -> Result<()> {
|
||||||
|
let install_path = get_install_path();
|
||||||
|
std::fs::create_dir_all(&install_path)?;
|
||||||
|
|
||||||
|
// TODO: Copy wintun.dll when available
|
||||||
|
// let wintun_path = install_path.join("wintun.dll");
|
||||||
|
// std::fs::write(&wintun_path, WINTUN_DLL)
|
||||||
|
// .context("Failed to write wintun.dll")?;
|
||||||
|
|
||||||
|
tracing::info!("Wintun DLL installation placeholder");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
80
ostp-installer/src/service.rs
Normal file
80
ostp-installer/src/service.rs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
//! Windows Service registration
|
||||||
|
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::os::windows::ffi::OsStrExt;
|
||||||
|
use windows::Win32::System::Services::*;
|
||||||
|
use windows::Win32::Foundation::*;
|
||||||
|
use windows::core::PCWSTR;
|
||||||
|
|
||||||
|
pub fn install_service() -> Result<()> {
|
||||||
|
let service_name = "OspabGuard";
|
||||||
|
let display_name = "Ospab OSTP VPN Service";
|
||||||
|
let description = "Manages secure OSTP VPN tunnel connections";
|
||||||
|
|
||||||
|
let daemon_path = crate::get_install_path().join("ostp-daemon.exe");
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
// Open Service Control Manager
|
||||||
|
let scm = OpenSCManagerW(
|
||||||
|
PCWSTR::null(),
|
||||||
|
PCWSTR::null(),
|
||||||
|
SC_MANAGER_CREATE_SERVICE,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
if scm.is_invalid() {
|
||||||
|
anyhow::bail!("Failed to open Service Control Manager");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create service
|
||||||
|
let service_name_wide = to_wide_string(service_name);
|
||||||
|
let display_name_wide = to_wide_string(display_name);
|
||||||
|
let binary_path_wide = to_wide_string(&daemon_path.to_string_lossy());
|
||||||
|
|
||||||
|
let service = CreateServiceW(
|
||||||
|
scm,
|
||||||
|
PCWSTR(service_name_wide.as_ptr()),
|
||||||
|
PCWSTR(display_name_wide.as_ptr()),
|
||||||
|
SERVICE_ALL_ACCESS,
|
||||||
|
SERVICE_WIN32_OWN_PROCESS,
|
||||||
|
SERVICE_AUTO_START,
|
||||||
|
SERVICE_ERROR_NORMAL,
|
||||||
|
PCWSTR(binary_path_wide.as_ptr()),
|
||||||
|
PCWSTR::null(),
|
||||||
|
None,
|
||||||
|
PCWSTR::null(),
|
||||||
|
PCWSTR::null(),
|
||||||
|
PCWSTR::null(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
if service.is_invalid() {
|
||||||
|
CloseServiceHandle(scm)?;
|
||||||
|
anyhow::bail!("Failed to create service");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set description
|
||||||
|
let description_wide = to_wide_string(description);
|
||||||
|
let mut service_desc = SERVICE_DESCRIPTIONW {
|
||||||
|
lpDescription: PWSTR(description_wide.as_ptr() as *mut _),
|
||||||
|
};
|
||||||
|
|
||||||
|
ChangeServiceConfig2W(
|
||||||
|
service,
|
||||||
|
SERVICE_CONFIG_DESCRIPTION,
|
||||||
|
Some(&service_desc as *const _ as *const _),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
CloseServiceHandle(service)?;
|
||||||
|
CloseServiceHandle(scm)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
tracing::info!("Service '{}' installed successfully", service_name);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_wide_string(s: &str) -> Vec<u16> {
|
||||||
|
OsString::from(s)
|
||||||
|
.encode_wide()
|
||||||
|
.chain(std::iter::once(0))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
10
ostp-installer/src/wintun.rs
Normal file
10
ostp-installer/src/wintun.rs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
//! Wintun driver installation
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
pub fn install_wintun_driver() -> Result<()> {
|
||||||
|
// Wintun doesn't require manual driver installation
|
||||||
|
// The DLL handles driver installation automatically on first use
|
||||||
|
tracing::info!("Wintun DLL will auto-install driver on first use");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
100
ostp-installer/src/wizard.rs
Normal file
100
ostp-installer/src/wizard.rs
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
//! Wizard UI for installation process
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use native_windows_gui as nwg;
|
||||||
|
use native_windows_derive as nwd;
|
||||||
|
|
||||||
|
use crate::{install_wintun_dll, service, firewall};
|
||||||
|
|
||||||
|
#[derive(Default, nwd::NwgUi)]
|
||||||
|
pub struct InstallerWizard {
|
||||||
|
#[nwg_control(size: (600, 400), position: (300, 300), title: "OSTP Installer", flags: "WINDOW|VISIBLE")]
|
||||||
|
#[nwg_events(OnWindowClose: [InstallerWizard::exit])]
|
||||||
|
window: nwg::Window,
|
||||||
|
|
||||||
|
#[nwg_layout(parent: window, spacing: 1)]
|
||||||
|
grid: nwg::GridLayout,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Welcome to OSTP Installer", font: Some(&data.title_font))]
|
||||||
|
#[nwg_layout_item(layout: grid, row: 0, col: 0, col_span: 2)]
|
||||||
|
title: nwg::Label,
|
||||||
|
|
||||||
|
#[nwg_control(text: "This wizard will install OSTP VPN on your system.\n\nClick Next to continue.")]
|
||||||
|
#[nwg_layout_item(layout: grid, row: 1, col: 0, col_span: 2, row_span: 4)]
|
||||||
|
description: nwg::Label,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Next")]
|
||||||
|
#[nwg_layout_item(layout: grid, row: 5, col: 1)]
|
||||||
|
#[nwg_events(OnButtonClick: [InstallerWizard::next])]
|
||||||
|
next_button: nwg::Button,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Cancel")]
|
||||||
|
#[nwg_layout_item(layout: grid, row: 5, col: 0)]
|
||||||
|
#[nwg_events(OnButtonClick: [InstallerWizard::exit])]
|
||||||
|
cancel_button: nwg::Button,
|
||||||
|
|
||||||
|
#[nwg_resource(family: "Segoe UI", size: 18, weight: 700)]
|
||||||
|
title_font: nwg::Font,
|
||||||
|
|
||||||
|
step: std::cell::RefCell<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InstallerWizard {
|
||||||
|
fn next(&self) {
|
||||||
|
let mut step = self.step.borrow_mut();
|
||||||
|
*step += 1;
|
||||||
|
|
||||||
|
match *step {
|
||||||
|
1 => self.install_step(),
|
||||||
|
2 => self.finish_step(),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn install_step(&self) {
|
||||||
|
self.title.set_text("Installing...");
|
||||||
|
self.description.set_text("Please wait while OSTP is being installed.");
|
||||||
|
self.next_button.set_enabled(false);
|
||||||
|
|
||||||
|
// Perform installation
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
if let Err(e) = perform_installation() {
|
||||||
|
eprintln!("Installation error: {}", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn finish_step(&self) {
|
||||||
|
self.title.set_text("Installation Complete");
|
||||||
|
self.description.set_text("OSTP has been successfully installed.\n\nClick Finish to exit.");
|
||||||
|
self.next_button.set_text("Finish");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn exit(&self) {
|
||||||
|
nwg::stop_thread_dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_wizard() -> Result<()> {
|
||||||
|
nwg::init()?;
|
||||||
|
nwg::Font::set_global_family("Segoe UI")?;
|
||||||
|
|
||||||
|
let _app = InstallerWizard::default();
|
||||||
|
nwg::dispatch_thread_events();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn perform_installation() -> Result<()> {
|
||||||
|
tracing::info!("Step 1: Installing Wintun DLL");
|
||||||
|
install_wintun_dll()?;
|
||||||
|
|
||||||
|
tracing::info!("Step 2: Registering Windows Service");
|
||||||
|
service::install_service()?;
|
||||||
|
|
||||||
|
tracing::info!("Step 3: Configuring Firewall");
|
||||||
|
firewall::add_firewall_rules()?;
|
||||||
|
|
||||||
|
tracing::info!("Installation complete");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "ostp-setup"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
authors = ["ospab.team"]
|
|
||||||
description = "OSTP Windows Setup Wizard"
|
|
||||||
license = "Proprietary"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "ostp_setup_lib"
|
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
tauri-build = { version = "2", features = [] }
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tauri = { version = "2", features = [] }
|
|
||||||
tauri-plugin-shell = "2"
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
||||||
serde_json = "1"
|
|
||||||
base64 = "0.22"
|
|
||||||
aes-gcm = "0.10"
|
|
||||||
rand = "0.8"
|
|
||||||
sha2 = "0.10"
|
|
||||||
winreg = "0.52"
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
anyhow = "1"
|
|
||||||
thiserror = "2"
|
|
||||||
tracing = "0.1"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["custom-protocol"]
|
|
||||||
custom-protocol = ["tauri/custom-protocol"]
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
@@ -1,236 +0,0 @@
|
|||||||
//! Access Key parsing and validation
|
|
||||||
//!
|
|
||||||
//! Access Key format: ospab://<base64-encoded-data>
|
|
||||||
//! Decoded data: JSON with server, port, psk, and optional label
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// Parsed access key data
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct AccessKeyData {
|
|
||||||
pub server_ip: String,
|
|
||||||
pub port: u16,
|
|
||||||
pub psk: String,
|
|
||||||
pub label: Option<String>,
|
|
||||||
}
|
|
||||||
use aes_gcm::{
|
|
||||||
aead::{Aead, KeyInit},
|
|
||||||
Aes256Gcm, Nonce,
|
|
||||||
};
|
|
||||||
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
|
|
||||||
use sha2::{Digest, Sha256};
|
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
/// Key derivation salt (must match client)
|
|
||||||
const KEY_SALT: &[u8] = b"ospab.network.access.key.v1";
|
|
||||||
|
|
||||||
/// Static obfuscation key (XOR with device-specific data in production)
|
|
||||||
const OBFUSCATION_KEY: [u8; 32] = [
|
|
||||||
0x4f, 0x53, 0x50, 0x41, 0x42, 0x2e, 0x4e, 0x45,
|
|
||||||
0x54, 0x57, 0x4f, 0x52, 0x4b, 0x2e, 0x32, 0x30,
|
|
||||||
0x32, 0x36, 0x2e, 0x53, 0x45, 0x43, 0x55, 0x52,
|
|
||||||
0x45, 0x2e, 0x4b, 0x45, 0x59, 0x2e, 0x56, 0x31,
|
|
||||||
];
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum AccessKeyError {
|
|
||||||
#[error("Invalid access key format")]
|
|
||||||
InvalidFormat,
|
|
||||||
#[error("Invalid base64 encoding")]
|
|
||||||
Base64Error(#[from] base64::DecodeError),
|
|
||||||
#[error("Decryption failed")]
|
|
||||||
DecryptionFailed,
|
|
||||||
#[error("Invalid JSON data")]
|
|
||||||
JsonError(#[from] serde_json::Error),
|
|
||||||
#[error("Missing required field: {0}")]
|
|
||||||
MissingField(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Validate access key format (quick check)
|
|
||||||
pub fn validate(key: &str) -> bool {
|
|
||||||
if !key.starts_with("ospab://") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let encoded = &key[8..]; // Skip "ospab://"
|
|
||||||
URL_SAFE_NO_PAD.decode(encoded).is_ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parse and decrypt access key
|
|
||||||
pub fn parse(key: &str) -> Result<AccessKeyData, AccessKeyError> {
|
|
||||||
// Check prefix
|
|
||||||
if !key.starts_with("ospab://") {
|
|
||||||
return Err(AccessKeyError::InvalidFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
let encoded = &key[8..]; // Skip "ospab://"
|
|
||||||
let encrypted = URL_SAFE_NO_PAD.decode(encoded)?;
|
|
||||||
|
|
||||||
// Decrypt the data
|
|
||||||
let decrypted = decrypt_access_key(&encrypted)?;
|
|
||||||
|
|
||||||
// Parse JSON
|
|
||||||
let json: serde_json::Value = serde_json::from_slice(&decrypted)?;
|
|
||||||
|
|
||||||
// Extract fields
|
|
||||||
let server_ip = json["server"]
|
|
||||||
.as_str()
|
|
||||||
.ok_or_else(|| AccessKeyError::MissingField("server".into()))?
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let port = json["port"]
|
|
||||||
.as_u64()
|
|
||||||
.ok_or_else(|| AccessKeyError::MissingField("port".into()))? as u16;
|
|
||||||
|
|
||||||
let psk = json["psk"]
|
|
||||||
.as_str()
|
|
||||||
.ok_or_else(|| AccessKeyError::MissingField("psk".into()))?
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let label = json["label"].as_str().map(String::from);
|
|
||||||
|
|
||||||
Ok(AccessKeyData {
|
|
||||||
server_ip,
|
|
||||||
port,
|
|
||||||
psk,
|
|
||||||
label,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decrypt access key data using AES-256-GCM
|
|
||||||
fn decrypt_access_key(encrypted: &[u8]) -> Result<Vec<u8>, AccessKeyError> {
|
|
||||||
if encrypted.len() < 12 + 16 {
|
|
||||||
// Nonce (12) + Tag (16) minimum
|
|
||||||
return Err(AccessKeyError::InvalidFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Derive key from obfuscation key
|
|
||||||
let key = derive_key(&OBFUSCATION_KEY);
|
|
||||||
|
|
||||||
// Split nonce and ciphertext
|
|
||||||
let (nonce_bytes, ciphertext) = encrypted.split_at(12);
|
|
||||||
let nonce = Nonce::from_slice(nonce_bytes);
|
|
||||||
|
|
||||||
// Decrypt
|
|
||||||
let cipher = Aes256Gcm::new_from_slice(&key)
|
|
||||||
.map_err(|_| AccessKeyError::DecryptionFailed)?;
|
|
||||||
|
|
||||||
cipher
|
|
||||||
.decrypt(nonce, ciphertext)
|
|
||||||
.map_err(|_| AccessKeyError::DecryptionFailed)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Derive AES key from obfuscation key
|
|
||||||
fn derive_key(input: &[u8]) -> [u8; 32] {
|
|
||||||
let mut hasher = Sha256::new();
|
|
||||||
hasher.update(input);
|
|
||||||
hasher.update(KEY_SALT);
|
|
||||||
hasher.finalize().into()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create an access key (for server-side use)
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn create_access_key(
|
|
||||||
server: &str,
|
|
||||||
port: u16,
|
|
||||||
psk: &str,
|
|
||||||
label: Option<&str>,
|
|
||||||
) -> Result<String, AccessKeyError> {
|
|
||||||
use aes_gcm::aead::OsRng;
|
|
||||||
use rand::RngCore;
|
|
||||||
|
|
||||||
// Create JSON payload
|
|
||||||
let mut json = serde_json::json!({
|
|
||||||
"server": server,
|
|
||||||
"port": port,
|
|
||||||
"psk": psk
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(l) = label {
|
|
||||||
json["label"] = serde_json::Value::String(l.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
let plaintext = serde_json::to_vec(&json)?;
|
|
||||||
|
|
||||||
// Encrypt
|
|
||||||
let key = derive_key(&OBFUSCATION_KEY);
|
|
||||||
let cipher = Aes256Gcm::new_from_slice(&key)
|
|
||||||
.map_err(|_| AccessKeyError::DecryptionFailed)?;
|
|
||||||
|
|
||||||
// Generate random nonce
|
|
||||||
let mut nonce_bytes = [0u8; 12];
|
|
||||||
OsRng.fill_bytes(&mut nonce_bytes);
|
|
||||||
let nonce = Nonce::from_slice(&nonce_bytes);
|
|
||||||
|
|
||||||
let ciphertext = cipher
|
|
||||||
.encrypt(nonce, plaintext.as_slice())
|
|
||||||
.map_err(|_| AccessKeyError::DecryptionFailed)?;
|
|
||||||
|
|
||||||
// Combine nonce + ciphertext
|
|
||||||
let mut result = Vec::with_capacity(12 + ciphertext.len());
|
|
||||||
result.extend_from_slice(&nonce_bytes);
|
|
||||||
result.extend(ciphertext);
|
|
||||||
|
|
||||||
// Encode and format
|
|
||||||
let encoded = URL_SAFE_NO_PAD.encode(&result);
|
|
||||||
Ok(format!("ospab://{}", encoded))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Secure memory wipe for sensitive data
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct SecureString {
|
|
||||||
inner: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl SecureString {
|
|
||||||
pub fn new(s: String) -> Self {
|
|
||||||
Self { inner: s }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_str(&self) -> &str {
|
|
||||||
&self.inner
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for SecureString {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
// Overwrite memory before deallocation
|
|
||||||
unsafe {
|
|
||||||
let bytes = self.inner.as_bytes_mut();
|
|
||||||
for byte in bytes.iter_mut() {
|
|
||||||
std::ptr::write_volatile(byte, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_create_and_parse_access_key() {
|
|
||||||
let key = create_access_key(
|
|
||||||
"vpn.example.com",
|
|
||||||
8443,
|
|
||||||
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
|
||||||
Some("Test Server"),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert!(key.starts_with("ospab://"));
|
|
||||||
assert!(validate(&key));
|
|
||||||
|
|
||||||
let parsed = parse(&key).unwrap();
|
|
||||||
assert_eq!(parsed.server_ip, "vpn.example.com");
|
|
||||||
assert_eq!(parsed.port, 8443);
|
|
||||||
assert_eq!(parsed.label, Some("Test Server".to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_invalid_key() {
|
|
||||||
assert!(!validate("invalid://key"));
|
|
||||||
assert!(!validate("ospab://!!!invalid-base64!!!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
//! OSTP Setup Library
|
|
||||||
//!
|
|
||||||
//! This is the library interface for the setup wizard.
|
|
||||||
|
|
||||||
pub mod access_key;
|
|
||||||
pub mod service;
|
|
||||||
pub mod system_check;
|
|
||||||
pub mod wintun;
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
//! OSTP Setup Wizard - Rust Backend
|
|
||||||
//!
|
|
||||||
//! Handles Windows Service installation, wintun driver extraction,
|
|
||||||
//! and Access Key parsing for the OSTP Client.
|
|
||||||
|
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
||||||
|
|
||||||
mod access_key;
|
|
||||||
mod service;
|
|
||||||
mod wintun;
|
|
||||||
mod system_check;
|
|
||||||
|
|
||||||
use tauri::{command, AppHandle, Emitter, Manager};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
// Re-export types from modules
|
|
||||||
pub use access_key::AccessKeyData;
|
|
||||||
pub use system_check::SystemCheckResult;
|
|
||||||
|
|
||||||
/// Installation configuration from the wizard
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct InstallConfig {
|
|
||||||
pub access_key: String,
|
|
||||||
pub country: String,
|
|
||||||
pub install_path: PathBuf,
|
|
||||||
pub launch_on_startup: bool,
|
|
||||||
pub connect_now: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Installation progress update
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct ProgressUpdate {
|
|
||||||
pub step: u8,
|
|
||||||
pub total_steps: u8,
|
|
||||||
pub message: String,
|
|
||||||
pub percent: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct CountryOption {
|
|
||||||
pub code: String,
|
|
||||||
pub name: String,
|
|
||||||
pub recommended: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check system requirements
|
|
||||||
#[command]
|
|
||||||
async fn check_system() -> Result<SystemCheckResult, String> {
|
|
||||||
system_check::run_checks().await.map_err(|e| e.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parse and validate access key
|
|
||||||
#[command]
|
|
||||||
async fn parse_access_key(key: String) -> Result<AccessKeyData, String> {
|
|
||||||
access_key::parse(&key).map_err(|e| e.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Validate access key format without full parse
|
|
||||||
#[command]
|
|
||||||
fn validate_access_key(key: String) -> bool {
|
|
||||||
access_key::validate(&key)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get list of available countries for SNI
|
|
||||||
#[command]
|
|
||||||
fn get_countries() -> Vec<CountryOption> {
|
|
||||||
vec![
|
|
||||||
CountryOption { code: "RU".into(), name: "Russia".into(), recommended: true },
|
|
||||||
CountryOption { code: "DE".into(), name: "Germany".into(), recommended: false },
|
|
||||||
CountryOption { code: "NL".into(), name: "Netherlands".into(), recommended: false },
|
|
||||||
CountryOption { code: "US".into(), name: "United States".into(), recommended: false },
|
|
||||||
CountryOption { code: "SG".into(), name: "Singapore".into(), recommended: false },
|
|
||||||
CountryOption { code: "JP".into(), name: "Japan".into(), recommended: false },
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the full installation process
|
|
||||||
#[command]
|
|
||||||
async fn run_installation(
|
|
||||||
app: AppHandle,
|
|
||||||
config: InstallConfig,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
let window = app.get_webview_window("main").unwrap();
|
|
||||||
|
|
||||||
// Step 1: Extract wintun.dll
|
|
||||||
emit_progress(&window, 1, 5, "Extracting WinTUN driver...", 10);
|
|
||||||
wintun::extract_driver(&config.install_path)
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to extract wintun: {}", e))?;
|
|
||||||
|
|
||||||
// Step 2: Parse access key
|
|
||||||
emit_progress(&window, 2, 5, "Parsing access key...", 25);
|
|
||||||
let key_data = access_key::parse(&config.access_key)
|
|
||||||
.map_err(|e| format!("Invalid access key: {}", e))?;
|
|
||||||
|
|
||||||
// Step 3: Write configuration file
|
|
||||||
emit_progress(&window, 3, 5, "Writing configuration...", 45);
|
|
||||||
write_config(&config.install_path, &key_data, &config.country)
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to write config: {}", e))?;
|
|
||||||
|
|
||||||
// Step 4: Install Windows Service
|
|
||||||
emit_progress(&window, 4, 5, "Installing Windows Service...", 70);
|
|
||||||
service::install_service(&config.install_path)
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to install service: {}", e))?;
|
|
||||||
|
|
||||||
// Step 5: Configure startup
|
|
||||||
emit_progress(&window, 5, 5, "Configuring startup options...", 90);
|
|
||||||
if config.launch_on_startup {
|
|
||||||
service::enable_autostart()
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to enable autostart: {}", e))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit_progress(&window, 5, 5, "Installation complete!", 100);
|
|
||||||
|
|
||||||
// Optionally connect now
|
|
||||||
if config.connect_now {
|
|
||||||
service::start_service()
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("Failed to start service: {}", e))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Emit progress update to frontend
|
|
||||||
fn emit_progress(window: &tauri::WebviewWindow, step: u8, total: u8, msg: &str, percent: u8) {
|
|
||||||
let _ = window.emit("install-progress", ProgressUpdate {
|
|
||||||
step,
|
|
||||||
total_steps: total,
|
|
||||||
message: msg.to_string(),
|
|
||||||
percent,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Write OSTP client configuration file
|
|
||||||
async fn write_config(
|
|
||||||
install_path: &PathBuf,
|
|
||||||
key_data: &AccessKeyData,
|
|
||||||
country: &str,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
let config_path = install_path.join("ostp-client.json");
|
|
||||||
let config = serde_json::json!({
|
|
||||||
"server": format!("{}:{}", key_data.server_ip, key_data.port),
|
|
||||||
"psk": key_data.psk,
|
|
||||||
"country": country,
|
|
||||||
"dns": ["1.1.1.1", "8.8.8.8"],
|
|
||||||
"mtu": 1400
|
|
||||||
});
|
|
||||||
|
|
||||||
fs::create_dir_all(install_path)?;
|
|
||||||
fs::write(&config_path, serde_json::to_string_pretty(&config)?)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Uninstall the OSTP client
|
|
||||||
#[command]
|
|
||||||
async fn uninstall() -> Result<(), String> {
|
|
||||||
service::stop_service().await.map_err(|e| e.to_string())?;
|
|
||||||
service::uninstall_service().await.map_err(|e| e.to_string())?;
|
|
||||||
wintun::remove_driver().await.map_err(|e| e.to_string())?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get default installation path
|
|
||||||
#[command]
|
|
||||||
fn get_default_install_path() -> PathBuf {
|
|
||||||
PathBuf::from(r"C:\Program Files\Ospab Network\OSTP")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
tauri::Builder::default()
|
|
||||||
.plugin(tauri_plugin_shell::init())
|
|
||||||
.invoke_handler(tauri::generate_handler![
|
|
||||||
check_system,
|
|
||||||
parse_access_key,
|
|
||||||
validate_access_key,
|
|
||||||
get_countries,
|
|
||||||
run_installation,
|
|
||||||
uninstall,
|
|
||||||
get_default_install_path,
|
|
||||||
])
|
|
||||||
.run(tauri::generate_context!())
|
|
||||||
.expect("error while running tauri application");
|
|
||||||
}
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
//! Windows Service management for OSTP Client
|
|
||||||
//!
|
|
||||||
//! Installs, configures, and manages the OSTP client as a Windows Service.
|
|
||||||
//! Uses sc.exe for broader compatibility.
|
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
/// Service name
|
|
||||||
const SERVICE_NAME: &str = "OstpClient";
|
|
||||||
|
|
||||||
/// Service display name
|
|
||||||
const SERVICE_DISPLAY_NAME: &str = "Ospab Network OSTP Client";
|
|
||||||
|
|
||||||
/// Service description
|
|
||||||
const SERVICE_DESCRIPTION: &str =
|
|
||||||
"Provides secure, stealth VPN connectivity through the OSTP protocol.";
|
|
||||||
|
|
||||||
/// Install OSTP client as a Windows Service using sc.exe
|
|
||||||
pub async fn install_service(install_path: &PathBuf) -> Result<()> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
let executable_path = install_path.join("ostp-client.exe");
|
|
||||||
|
|
||||||
if !executable_path.exists() {
|
|
||||||
anyhow::bail!("ostp-client.exe not found at {:?}", executable_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
let config_path = install_path.join("ostp-client.json");
|
|
||||||
let bin_path = format!(
|
|
||||||
"\"{}\" --service --config \"{}\"",
|
|
||||||
executable_path.display(),
|
|
||||||
config_path.display()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create service
|
|
||||||
let output = Command::new("sc.exe")
|
|
||||||
.args([
|
|
||||||
"create",
|
|
||||||
SERVICE_NAME,
|
|
||||||
&format!("binPath= {}", bin_path),
|
|
||||||
&format!("DisplayName= {}", SERVICE_DISPLAY_NAME),
|
|
||||||
"start= auto",
|
|
||||||
"depend= Tcpip/Dnscache",
|
|
||||||
])
|
|
||||||
.output()
|
|
||||||
.context("Failed to run sc.exe create")?;
|
|
||||||
|
|
||||||
if !output.status.success() {
|
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
||||||
if !stderr.contains("1073") { // Service already exists
|
|
||||||
anyhow::bail!("Failed to create service: {}", stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set description
|
|
||||||
let _ = Command::new("sc.exe")
|
|
||||||
.args(["description", SERVICE_NAME, SERVICE_DESCRIPTION])
|
|
||||||
.output();
|
|
||||||
|
|
||||||
// Configure recovery options (restart on failure)
|
|
||||||
let _ = Command::new("sc.exe")
|
|
||||||
.args([
|
|
||||||
"failure",
|
|
||||||
SERVICE_NAME,
|
|
||||||
"reset= 86400",
|
|
||||||
"actions= restart/60000/restart/120000/restart/300000",
|
|
||||||
])
|
|
||||||
.output();
|
|
||||||
|
|
||||||
tracing::info!("Service {} installed successfully", SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
let _ = install_path;
|
|
||||||
anyhow::bail!("Windows Service installation is only supported on Windows");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start the OSTP service
|
|
||||||
pub async fn start_service() -> Result<()> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
let output = Command::new("sc.exe")
|
|
||||||
.args(["start", SERVICE_NAME])
|
|
||||||
.output()
|
|
||||||
.context("Failed to run sc.exe start")?;
|
|
||||||
|
|
||||||
if !output.status.success() {
|
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
||||||
if !stderr.contains("1056") { // Service already running
|
|
||||||
anyhow::bail!("Failed to start service: {}", stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!("Service {} started", SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stop the OSTP service
|
|
||||||
pub async fn stop_service() -> Result<()> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
let output = Command::new("sc.exe")
|
|
||||||
.args(["stop", SERVICE_NAME])
|
|
||||||
.output()
|
|
||||||
.context("Failed to run sc.exe stop")?;
|
|
||||||
|
|
||||||
if !output.status.success() {
|
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
||||||
if !stderr.contains("1062") { // Service not running
|
|
||||||
anyhow::bail!("Failed to stop service: {}", stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for service to stop
|
|
||||||
for _ in 0..30 {
|
|
||||||
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
|
|
||||||
if !is_running() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!("Service {} stopped", SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Uninstall the OSTP service
|
|
||||||
pub async fn uninstall_service() -> Result<()> {
|
|
||||||
// Stop the service first
|
|
||||||
stop_service().await.ok();
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
let output = Command::new("sc.exe")
|
|
||||||
.args(["delete", SERVICE_NAME])
|
|
||||||
.output()
|
|
||||||
.context("Failed to run sc.exe delete")?;
|
|
||||||
|
|
||||||
if !output.status.success() {
|
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
||||||
if !stderr.contains("1060") { // Service doesn't exist
|
|
||||||
anyhow::bail!("Failed to delete service: {}", stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!("Service {} uninstalled", SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Enable service to start at system startup
|
|
||||||
pub async fn enable_autostart() -> Result<()> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
Command::new("sc.exe")
|
|
||||||
.args(["config", SERVICE_NAME, "start= auto"])
|
|
||||||
.output()
|
|
||||||
.context("Failed to enable autostart")?;
|
|
||||||
|
|
||||||
tracing::info!("Autostart enabled for {}", SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Disable service autostart
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn disable_autostart() -> Result<()> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
Command::new("sc.exe")
|
|
||||||
.args(["config", SERVICE_NAME, "start= demand"])
|
|
||||||
.output()
|
|
||||||
.context("Failed to disable autostart")?;
|
|
||||||
|
|
||||||
tracing::info!("Autostart disabled for {}", SERVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if service is installed
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn is_installed() -> bool {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
Command::new("sc.exe")
|
|
||||||
.args(["query", SERVICE_NAME])
|
|
||||||
.output()
|
|
||||||
.map(|o| o.status.success())
|
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if service is running
|
|
||||||
pub fn is_running() -> bool {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
Command::new("sc.exe")
|
|
||||||
.args(["query", SERVICE_NAME])
|
|
||||||
.output()
|
|
||||||
.map(|o| {
|
|
||||||
let stdout = String::from_utf8_lossy(&o.stdout);
|
|
||||||
stdout.contains("RUNNING")
|
|
||||||
})
|
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get service status
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_status() -> Option<String> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
Command::new("sc.exe")
|
|
||||||
.args(["query", SERVICE_NAME])
|
|
||||||
.output()
|
|
||||||
.ok()
|
|
||||||
.and_then(|o| {
|
|
||||||
let stdout = String::from_utf8_lossy(&o.stdout);
|
|
||||||
if stdout.contains("RUNNING") {
|
|
||||||
Some("Running".to_string())
|
|
||||||
} else if stdout.contains("STOPPED") {
|
|
||||||
Some("Stopped".to_string())
|
|
||||||
} else if stdout.contains("PENDING") {
|
|
||||||
Some("Pending".to_string())
|
|
||||||
} else {
|
|
||||||
Some("Unknown".to_string())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
None
|
|
||||||
}
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
//! System requirements checking
|
|
||||||
//!
|
|
||||||
//! Verifies that the target system meets all requirements for OSTP Client.
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// System check result
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct SystemCheckResult {
|
|
||||||
pub wintun_installed: bool,
|
|
||||||
pub aes_ni_supported: bool,
|
|
||||||
pub admin_privileges: bool,
|
|
||||||
pub os_version: String,
|
|
||||||
}
|
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
/// Run all system checks
|
|
||||||
pub async fn run_checks() -> Result<SystemCheckResult> {
|
|
||||||
Ok(SystemCheckResult {
|
|
||||||
wintun_installed: check_wintun_installed(),
|
|
||||||
aes_ni_supported: check_aes_ni_support(),
|
|
||||||
admin_privileges: check_admin_privileges(),
|
|
||||||
os_version: get_os_version(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if wintun.dll is already installed
|
|
||||||
fn check_wintun_installed() -> bool {
|
|
||||||
crate::wintun::is_installed()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if CPU supports AES-NI instructions
|
|
||||||
fn check_aes_ni_support() -> bool {
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
{
|
|
||||||
// Check CPUID for AES-NI support
|
|
||||||
return is_x86_feature_detected!("aes");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
{
|
|
||||||
// ARM64 typically has crypto extensions
|
|
||||||
// Check for ARMv8 Crypto extensions
|
|
||||||
#[cfg(target_feature = "aes")]
|
|
||||||
return true;
|
|
||||||
|
|
||||||
#[cfg(not(target_feature = "aes"))]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback: assume software AES is acceptable
|
|
||||||
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if running with administrator privileges
|
|
||||||
fn check_admin_privileges() -> bool {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use std::ptr;
|
|
||||||
|
|
||||||
// Use Windows API to check elevation
|
|
||||||
unsafe {
|
|
||||||
let mut token_handle: *mut std::ffi::c_void = ptr::null_mut();
|
|
||||||
let current_process = GetCurrentProcess();
|
|
||||||
|
|
||||||
if OpenProcessToken(
|
|
||||||
current_process,
|
|
||||||
TOKEN_QUERY,
|
|
||||||
&mut token_handle,
|
|
||||||
) == 0 {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut elevation = TOKEN_ELEVATION { TokenIsElevated: 0 };
|
|
||||||
let mut size: u32 = std::mem::size_of::<TOKEN_ELEVATION>() as u32;
|
|
||||||
|
|
||||||
let result = GetTokenInformation(
|
|
||||||
token_handle,
|
|
||||||
TokenElevation,
|
|
||||||
&mut elevation as *mut _ as *mut _,
|
|
||||||
size,
|
|
||||||
&mut size,
|
|
||||||
);
|
|
||||||
|
|
||||||
CloseHandle(token_handle);
|
|
||||||
|
|
||||||
result != 0 && elevation.TokenIsElevated != 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
// On non-Windows, check if running as root
|
|
||||||
unsafe { libc::geteuid() == 0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get Windows version string
|
|
||||||
fn get_os_version() -> String {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use winreg::{enums::*, RegKey};
|
|
||||||
|
|
||||||
if let Ok(hklm) = RegKey::predef(HKEY_LOCAL_MACHINE)
|
|
||||||
.open_subkey(r"SOFTWARE\Microsoft\Windows NT\CurrentVersion")
|
|
||||||
{
|
|
||||||
let product_name: String = hklm.get_value("ProductName").unwrap_or_default();
|
|
||||||
let build: String = hklm.get_value("CurrentBuild").unwrap_or_default();
|
|
||||||
|
|
||||||
if !product_name.is_empty() {
|
|
||||||
return format!("{} (Build {})", product_name, build);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"Windows (Unknown Version)".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
"Non-Windows OS".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check minimum Windows version (Windows 10 1607+)
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn check_minimum_version() -> bool {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use winreg::{enums::*, RegKey};
|
|
||||||
|
|
||||||
if let Ok(hklm) = RegKey::predef(HKEY_LOCAL_MACHINE)
|
|
||||||
.open_subkey(r"SOFTWARE\Microsoft\Windows NT\CurrentVersion")
|
|
||||||
{
|
|
||||||
let build: String = hklm.get_value("CurrentBuild").unwrap_or_default();
|
|
||||||
if let Ok(build_num) = build.parse::<u32>() {
|
|
||||||
// Windows 10 1607 is build 14393
|
|
||||||
return build_num >= 14393;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check available disk space (need at least 50MB)
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn check_disk_space(path: &std::path::Path) -> bool {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use std::os::windows::ffi::OsStrExt;
|
|
||||||
use std::ffi::OsStr;
|
|
||||||
|
|
||||||
let path_wide: Vec<u16> = OsStr::new(path)
|
|
||||||
.encode_wide()
|
|
||||||
.chain(std::iter::once(0))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let mut free_bytes: u64 = 0;
|
|
||||||
let mut total_bytes: u64 = 0;
|
|
||||||
let mut total_free_bytes: u64 = 0;
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
if GetDiskFreeSpaceExW(
|
|
||||||
path_wide.as_ptr(),
|
|
||||||
&mut free_bytes,
|
|
||||||
&mut total_bytes,
|
|
||||||
&mut total_free_bytes,
|
|
||||||
) != 0 {
|
|
||||||
// Need at least 50MB
|
|
||||||
return free_bytes >= 50 * 1024 * 1024;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
true // Assume OK if check fails
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
let _ = path;
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Windows API bindings
|
|
||||||
#[cfg(windows)]
|
|
||||||
unsafe extern "system" {
|
|
||||||
fn GetCurrentProcess() -> *mut std::ffi::c_void;
|
|
||||||
fn OpenProcessToken(
|
|
||||||
process: *mut std::ffi::c_void,
|
|
||||||
access: u32,
|
|
||||||
token: *mut *mut std::ffi::c_void,
|
|
||||||
) -> i32;
|
|
||||||
fn GetTokenInformation(
|
|
||||||
token: *mut std::ffi::c_void,
|
|
||||||
info_class: u32,
|
|
||||||
info: *mut std::ffi::c_void,
|
|
||||||
info_len: u32,
|
|
||||||
return_len: *mut u32,
|
|
||||||
) -> i32;
|
|
||||||
fn CloseHandle(handle: *mut std::ffi::c_void) -> i32;
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn GetDiskFreeSpaceExW(
|
|
||||||
directory: *const u16,
|
|
||||||
free_bytes: *mut u64,
|
|
||||||
total_bytes: *mut u64,
|
|
||||||
total_free_bytes: *mut u64,
|
|
||||||
) -> i32;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
const TOKEN_QUERY: u32 = 0x0008;
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[allow(non_upper_case_globals)]
|
|
||||||
const TokenElevation: u32 = 20;
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[repr(C)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
struct TOKEN_ELEVATION {
|
|
||||||
TokenIsElevated: u32,
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
//! WinTUN driver extraction and management
|
|
||||||
//!
|
|
||||||
//! Extracts wintun.dll from embedded resources and installs the TUN adapter.
|
|
||||||
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use anyhow::{Context, Result};
|
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
/// Embedded wintun.dll (x64) - placeholder, actual DLL is in resources
|
|
||||||
const WINTUN_DLL: &[u8] = include_bytes!("../resources/wintun.dll");
|
|
||||||
|
|
||||||
/// WinTUN adapter GUID (consistent across installs)
|
|
||||||
#[allow(dead_code)]
|
|
||||||
const ADAPTER_GUID: &str = "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}";
|
|
||||||
|
|
||||||
/// TUN adapter name
|
|
||||||
#[allow(dead_code)]
|
|
||||||
const ADAPTER_NAME: &str = "ostp TUN";
|
|
||||||
|
|
||||||
/// Extract wintun.dll to installation directory
|
|
||||||
pub async fn extract_driver(install_path: &PathBuf) -> Result<()> {
|
|
||||||
let dll_path = install_path.join("wintun.dll");
|
|
||||||
|
|
||||||
// Create directory if needed
|
|
||||||
fs::create_dir_all(install_path)
|
|
||||||
.context("Failed to create installation directory")?;
|
|
||||||
|
|
||||||
// Check if already exists with correct version
|
|
||||||
if dll_path.exists() {
|
|
||||||
let existing = fs::read(&dll_path)?;
|
|
||||||
if existing == WINTUN_DLL {
|
|
||||||
return Ok(()); // Already up to date
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the DLL
|
|
||||||
fs::write(&dll_path, WINTUN_DLL)
|
|
||||||
.context("Failed to write wintun.dll")?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create the TUN adapter using wintun API
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn create_adapter(install_path: &PathBuf) -> Result<()> {
|
|
||||||
// Load wintun.dll dynamically
|
|
||||||
let dll_path = install_path.join("wintun.dll");
|
|
||||||
|
|
||||||
if !dll_path.exists() {
|
|
||||||
anyhow::bail!("wintun.dll not found at {:?}", dll_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use libloading to call WintunCreateAdapter
|
|
||||||
// This is a simplified version - full implementation would use the wintun crate
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
use std::ffi::OsStr;
|
|
||||||
use std::os::windows::ffi::OsStrExt;
|
|
||||||
|
|
||||||
// Convert strings to wide strings for Windows API
|
|
||||||
let _adapter_name: Vec<u16> = OsStr::new(ADAPTER_NAME)
|
|
||||||
.encode_wide()
|
|
||||||
.chain(std::iter::once(0))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let _tunnel_type: Vec<u16> = OsStr::new("Ospab")
|
|
||||||
.encode_wide()
|
|
||||||
.chain(std::iter::once(0))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
// Parse GUID
|
|
||||||
let _guid = parse_guid(ADAPTER_GUID)?;
|
|
||||||
|
|
||||||
// In production, we'd call:
|
|
||||||
// WintunCreateAdapter(adapter_name, tunnel_type, &guid)
|
|
||||||
// For now, we'll use the wintun crate when it's integrated
|
|
||||||
|
|
||||||
tracing::info!("TUN adapter creation would happen here");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Delete the TUN adapter
|
|
||||||
pub async fn delete_adapter() -> Result<()> {
|
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
// WintunDeleteAdapter would be called here
|
|
||||||
tracing::info!("TUN adapter deletion would happen here");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove wintun driver files
|
|
||||||
pub async fn remove_driver() -> Result<()> {
|
|
||||||
// Delete adapter first
|
|
||||||
delete_adapter().await?;
|
|
||||||
|
|
||||||
// Find and remove DLL from common locations
|
|
||||||
let paths = [
|
|
||||||
PathBuf::from(r"C:\Program Files\Ospab Network\OSTP\wintun.dll"),
|
|
||||||
];
|
|
||||||
|
|
||||||
for path in &paths {
|
|
||||||
if path.exists() {
|
|
||||||
fs::remove_file(path).ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if wintun is installed and working
|
|
||||||
pub fn is_installed() -> bool {
|
|
||||||
let system_dll = PathBuf::from(r"C:\Program Files\Ospab Network\OSTP\wintun.dll");
|
|
||||||
system_dll.exists()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get wintun version from DLL
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_version() -> Option<String> {
|
|
||||||
// Would extract version info from PE header
|
|
||||||
// For now, return embedded version
|
|
||||||
Some("0.14.1".to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parse a GUID string into bytes
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn parse_guid(s: &str) -> Result<[u8; 16]> {
|
|
||||||
let s = s.trim_matches(|c| c == '{' || c == '}');
|
|
||||||
let parts: Vec<&str> = s.split('-').collect();
|
|
||||||
|
|
||||||
if parts.len() != 5 {
|
|
||||||
anyhow::bail!("Invalid GUID format");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut guid = [0u8; 16];
|
|
||||||
|
|
||||||
// Parse each part
|
|
||||||
let d1 = u32::from_str_radix(parts[0], 16)?;
|
|
||||||
let d2 = u16::from_str_radix(parts[1], 16)?;
|
|
||||||
let d3 = u16::from_str_radix(parts[2], 16)?;
|
|
||||||
let d4 = u16::from_str_radix(parts[3], 16)?;
|
|
||||||
let d5 = u64::from_str_radix(parts[4], 16)?;
|
|
||||||
|
|
||||||
guid[0..4].copy_from_slice(&d1.to_le_bytes());
|
|
||||||
guid[4..6].copy_from_slice(&d2.to_le_bytes());
|
|
||||||
guid[6..8].copy_from_slice(&d3.to_le_bytes());
|
|
||||||
guid[8..10].copy_from_slice(&d4.to_be_bytes());
|
|
||||||
guid[10..16].copy_from_slice(&d5.to_be_bytes()[2..8]);
|
|
||||||
|
|
||||||
Ok(guid)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(windows)]
|
|
||||||
fn test_parse_guid() {
|
|
||||||
let guid = parse_guid(ADAPTER_GUID).unwrap();
|
|
||||||
assert_eq!(guid.len(), 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
|
||||||
"productName": "OSTP Setup",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"identifier": "network.ospab.ostp-setup",
|
|
||||||
"build": {
|
|
||||||
"beforeDevCommand": "",
|
|
||||||
"devUrl": "http://localhost:1420",
|
|
||||||
"beforeBuildCommand": "",
|
|
||||||
"frontendDist": "./ui"
|
|
||||||
},
|
|
||||||
"app": {
|
|
||||||
"withGlobalTauri": true,
|
|
||||||
"windows": [
|
|
||||||
{
|
|
||||||
"title": "Ospab Network - Setup Wizard",
|
|
||||||
"width": 600,
|
|
||||||
"height": 480,
|
|
||||||
"resizable": false,
|
|
||||||
"center": true,
|
|
||||||
"decorations": true,
|
|
||||||
"transparent": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"security": {
|
|
||||||
"csp": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' asset: https://asset.localhost data:"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bundle": {
|
|
||||||
"active": true,
|
|
||||||
"targets": ["nsis"],
|
|
||||||
"icon": [],
|
|
||||||
"resources": ["resources/*"]
|
|
||||||
},
|
|
||||||
"plugins": {
|
|
||||||
"shell": {
|
|
||||||
"open": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,360 +0,0 @@
|
|||||||
// OSTP Setup Wizard - Frontend Logic
|
|
||||||
const { invoke } = window.__TAURI__.core;
|
|
||||||
const { listen } = window.__TAURI__.event;
|
|
||||||
|
|
||||||
// State
|
|
||||||
let currentStep = 1;
|
|
||||||
const totalSteps = 5;
|
|
||||||
let systemCheckResult = null;
|
|
||||||
let countries = [];
|
|
||||||
let installPath = '';
|
|
||||||
|
|
||||||
// DOM Elements
|
|
||||||
const stepContents = document.querySelectorAll('.step-content');
|
|
||||||
const stepIndicators = document.querySelectorAll('.step-indicator .step');
|
|
||||||
const btnNext = document.getElementById('btnNext');
|
|
||||||
const btnBack = document.getElementById('btnBack');
|
|
||||||
const btnCancel = document.getElementById('btnCancel');
|
|
||||||
|
|
||||||
// Initialize
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
|
||||||
// Get default install path
|
|
||||||
try {
|
|
||||||
installPath = await invoke('get_default_install_path');
|
|
||||||
document.getElementById('installPath').value = installPath;
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to get install path:', e);
|
|
||||||
document.getElementById('installPath').value = 'C:\\Program Files\\Ospab Network\\OSTP';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load countries
|
|
||||||
try {
|
|
||||||
countries = await invoke('get_countries');
|
|
||||||
populateCountries();
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to load countries:', e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Listen for installation progress
|
|
||||||
listen('install-progress', (event) => {
|
|
||||||
updateProgress(event.payload);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Setup event listeners
|
|
||||||
setupEventListeners();
|
|
||||||
});
|
|
||||||
|
|
||||||
function setupEventListeners() {
|
|
||||||
btnNext.addEventListener('click', handleNext);
|
|
||||||
btnBack.addEventListener('click', handleBack);
|
|
||||||
btnCancel.addEventListener('click', handleCancel);
|
|
||||||
|
|
||||||
// Access key validation
|
|
||||||
const accessKeyInput = document.getElementById('accessKey');
|
|
||||||
accessKeyInput.addEventListener('input', debounce(validateAccessKey, 300));
|
|
||||||
accessKeyInput.addEventListener('paste', () => {
|
|
||||||
setTimeout(validateAccessKey, 100);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleNext() {
|
|
||||||
switch (currentStep) {
|
|
||||||
case 1:
|
|
||||||
// Welcome -> System Check
|
|
||||||
goToStep(2);
|
|
||||||
await runSystemCheck();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// System Check -> Configuration
|
|
||||||
if (canProceedFromSystemCheck()) {
|
|
||||||
goToStep(3);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// Configuration -> Installation
|
|
||||||
if (await validateConfiguration()) {
|
|
||||||
goToStep(4);
|
|
||||||
await runInstallation();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// Installation -> Finish (auto-transition on complete)
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
// Finish -> Close
|
|
||||||
await finishInstallation();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleBack() {
|
|
||||||
if (currentStep > 1 && currentStep !== 4) {
|
|
||||||
goToStep(currentStep - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCancel() {
|
|
||||||
if (confirm('Are you sure you want to cancel the installation?')) {
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function goToStep(step) {
|
|
||||||
// Update step indicators
|
|
||||||
stepIndicators.forEach((indicator, index) => {
|
|
||||||
indicator.classList.remove('active', 'completed');
|
|
||||||
if (index + 1 < step) {
|
|
||||||
indicator.classList.add('completed');
|
|
||||||
} else if (index + 1 === step) {
|
|
||||||
indicator.classList.add('active');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update content visibility
|
|
||||||
stepContents.forEach((content, index) => {
|
|
||||||
content.classList.remove('active');
|
|
||||||
if (index + 1 === step) {
|
|
||||||
content.classList.add('active');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update button states
|
|
||||||
btnBack.disabled = step === 1 || step === 4 || step === 5;
|
|
||||||
|
|
||||||
if (step === 5) {
|
|
||||||
btnNext.textContent = 'Finish';
|
|
||||||
} else if (step === 4) {
|
|
||||||
btnNext.disabled = true;
|
|
||||||
btnNext.textContent = 'Installing...';
|
|
||||||
} else {
|
|
||||||
btnNext.disabled = false;
|
|
||||||
btnNext.textContent = 'Next';
|
|
||||||
}
|
|
||||||
|
|
||||||
currentStep = step;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 2: System Check
|
|
||||||
async function runSystemCheck() {
|
|
||||||
const checkItems = {
|
|
||||||
checkAdmin: document.getElementById('checkAdmin'),
|
|
||||||
checkAesNi: document.getElementById('checkAesNi'),
|
|
||||||
checkWintun: document.getElementById('checkWintun'),
|
|
||||||
checkOs: document.getElementById('checkOs'),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Animate checking state
|
|
||||||
Object.values(checkItems).forEach(item => {
|
|
||||||
setCheckState(item, 'pending', '⏳', 'Checking...');
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Small delay for visual effect
|
|
||||||
await sleep(500);
|
|
||||||
|
|
||||||
systemCheckResult = await invoke('check_system');
|
|
||||||
|
|
||||||
// Update each check with results
|
|
||||||
setCheckState(
|
|
||||||
checkItems.checkAdmin,
|
|
||||||
systemCheckResult.admin_privileges ? 'success' : 'error',
|
|
||||||
systemCheckResult.admin_privileges ? '✓' : '✗',
|
|
||||||
systemCheckResult.admin_privileges ? 'Elevated' : 'Required'
|
|
||||||
);
|
|
||||||
await sleep(200);
|
|
||||||
|
|
||||||
setCheckState(
|
|
||||||
checkItems.checkAesNi,
|
|
||||||
systemCheckResult.aes_ni_supported ? 'success' : 'warning',
|
|
||||||
systemCheckResult.aes_ni_supported ? '✓' : '⚠',
|
|
||||||
systemCheckResult.aes_ni_supported ? 'Supported' : 'Software fallback'
|
|
||||||
);
|
|
||||||
await sleep(200);
|
|
||||||
|
|
||||||
setCheckState(
|
|
||||||
checkItems.checkWintun,
|
|
||||||
'success',
|
|
||||||
systemCheckResult.wintun_installed ? '✓' : '◯',
|
|
||||||
systemCheckResult.wintun_installed ? 'Installed' : 'Will be installed'
|
|
||||||
);
|
|
||||||
await sleep(200);
|
|
||||||
|
|
||||||
setCheckState(
|
|
||||||
checkItems.checkOs,
|
|
||||||
'success',
|
|
||||||
'✓',
|
|
||||||
systemCheckResult.os_version
|
|
||||||
);
|
|
||||||
|
|
||||||
// Enable next if admin check passed
|
|
||||||
if (!systemCheckResult.admin_privileges) {
|
|
||||||
btnNext.disabled = true;
|
|
||||||
alert('Administrator privileges are required. Please restart the installer as Administrator.');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('System check failed:', e);
|
|
||||||
Object.values(checkItems).forEach(item => {
|
|
||||||
setCheckState(item, 'error', '✗', 'Check failed');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCheckState(element, state, icon, status) {
|
|
||||||
const iconEl = element.querySelector('.check-icon');
|
|
||||||
const statusEl = element.querySelector('.check-status');
|
|
||||||
|
|
||||||
iconEl.className = `check-icon ${state}`;
|
|
||||||
iconEl.textContent = icon;
|
|
||||||
statusEl.textContent = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
function canProceedFromSystemCheck() {
|
|
||||||
return systemCheckResult && systemCheckResult.admin_privileges;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 3: Configuration
|
|
||||||
function populateCountries() {
|
|
||||||
const select = document.getElementById('country');
|
|
||||||
select.innerHTML = '';
|
|
||||||
|
|
||||||
countries.forEach(country => {
|
|
||||||
const option = document.createElement('option');
|
|
||||||
option.value = country.code;
|
|
||||||
option.textContent = country.name + (country.recommended ? ' (Recommended)' : '');
|
|
||||||
if (country.recommended) {
|
|
||||||
option.selected = true;
|
|
||||||
}
|
|
||||||
select.appendChild(option);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function validateAccessKey() {
|
|
||||||
const input = document.getElementById('accessKey');
|
|
||||||
const errorEl = document.getElementById('accessKeyError');
|
|
||||||
const value = input.value.trim();
|
|
||||||
|
|
||||||
if (!value) {
|
|
||||||
input.classList.remove('error');
|
|
||||||
errorEl.textContent = '';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const isValid = await invoke('validate_access_key', { key: value });
|
|
||||||
if (isValid) {
|
|
||||||
input.classList.remove('error');
|
|
||||||
errorEl.textContent = '';
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
input.classList.add('error');
|
|
||||||
errorEl.textContent = 'Invalid access key format';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
input.classList.add('error');
|
|
||||||
errorEl.textContent = 'Failed to validate key';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function validateConfiguration() {
|
|
||||||
const accessKey = document.getElementById('accessKey').value.trim();
|
|
||||||
const country = document.getElementById('country').value;
|
|
||||||
|
|
||||||
if (!accessKey) {
|
|
||||||
document.getElementById('accessKeyError').textContent = 'Access key is required';
|
|
||||||
document.getElementById('accessKey').classList.add('error');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!await validateAccessKey()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!country) {
|
|
||||||
alert('Please select a region');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 4: Installation
|
|
||||||
async function runInstallation() {
|
|
||||||
const config = {
|
|
||||||
access_key: document.getElementById('accessKey').value.trim(),
|
|
||||||
country: document.getElementById('country').value,
|
|
||||||
install_path: document.getElementById('installPath').value,
|
|
||||||
launch_on_startup: true, // Will be read from step 5
|
|
||||||
connect_now: true, // Will be read from step 5
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
await invoke('run_installation', { config });
|
|
||||||
// Success - move to step 5
|
|
||||||
goToStep(5);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Installation failed:', e);
|
|
||||||
alert('Installation failed: ' + e);
|
|
||||||
btnNext.disabled = false;
|
|
||||||
btnNext.textContent = 'Retry';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateProgress(progress) {
|
|
||||||
const { step, total_steps, message, percent } = progress;
|
|
||||||
|
|
||||||
// Update progress bar
|
|
||||||
document.getElementById('progressFill').style.width = `${percent}%`;
|
|
||||||
document.getElementById('progressText').textContent = `${percent}%`;
|
|
||||||
document.getElementById('installStatus').textContent = message;
|
|
||||||
|
|
||||||
// Update step indicators
|
|
||||||
const installSteps = document.querySelectorAll('.install-step');
|
|
||||||
installSteps.forEach((stepEl, index) => {
|
|
||||||
stepEl.classList.remove('active', 'completed');
|
|
||||||
const statusEl = stepEl.querySelector('.step-status');
|
|
||||||
|
|
||||||
if (index + 1 < step) {
|
|
||||||
stepEl.classList.add('completed');
|
|
||||||
statusEl.textContent = '✓';
|
|
||||||
} else if (index + 1 === step) {
|
|
||||||
stepEl.classList.add('active');
|
|
||||||
statusEl.textContent = '⏳';
|
|
||||||
} else {
|
|
||||||
statusEl.textContent = '○';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 5: Finish
|
|
||||||
async function finishInstallation() {
|
|
||||||
const connectNow = document.getElementById('optConnectNow').checked;
|
|
||||||
const launchStartup = document.getElementById('optLaunchStartup').checked;
|
|
||||||
|
|
||||||
// These would typically trigger additional backend calls
|
|
||||||
// For now, just close the installer
|
|
||||||
if (connectNow) {
|
|
||||||
// Service should already be started by installation
|
|
||||||
console.log('Connecting now...');
|
|
||||||
}
|
|
||||||
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utilities
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
function debounce(func, wait) {
|
|
||||||
let timeout;
|
|
||||||
return function executedFunction(...args) {
|
|
||||||
const later = () => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
func(...args);
|
|
||||||
};
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = setTimeout(later, wait);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Ospab Network - Setup Wizard</title>
|
|
||||||
<link rel="stylesheet" href="styles.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="wizard-container">
|
|
||||||
<!-- Header -->
|
|
||||||
<header class="wizard-header">
|
|
||||||
<div class="logo">
|
|
||||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
||||||
<circle cx="16" cy="16" r="14" stroke="#6366f1" stroke-width="2"/>
|
|
||||||
<path d="M10 16l4 4 8-8" stroke="#6366f1" stroke-width="2" stroke-linecap="round"/>
|
|
||||||
</svg>
|
|
||||||
<span>Ospab Network</span>
|
|
||||||
</div>
|
|
||||||
<div class="step-indicator" id="stepIndicator">
|
|
||||||
<span class="step active">1</span>
|
|
||||||
<span class="step">2</span>
|
|
||||||
<span class="step">3</span>
|
|
||||||
<span class="step">4</span>
|
|
||||||
<span class="step">5</span>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Step 1: Welcome -->
|
|
||||||
<section class="step-content active" id="step1">
|
|
||||||
<div class="step-icon">
|
|
||||||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none">
|
|
||||||
<circle cx="32" cy="32" r="28" stroke="#6366f1" stroke-width="3"/>
|
|
||||||
<path d="M20 32l8 8 16-16" stroke="#6366f1" stroke-width="3" stroke-linecap="round"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<h1>Welcome to Ospab Network</h1>
|
|
||||||
<p class="description">
|
|
||||||
This wizard will guide you through the installation of the OSTP Client,
|
|
||||||
providing secure and stealth VPN connectivity.
|
|
||||||
</p>
|
|
||||||
<div class="features">
|
|
||||||
<div class="feature">
|
|
||||||
<span class="feature-icon">🔒</span>
|
|
||||||
<span>Military-grade encryption</span>
|
|
||||||
</div>
|
|
||||||
<div class="feature">
|
|
||||||
<span class="feature-icon">👁️</span>
|
|
||||||
<span>Stealth protocol (DPI bypass)</span>
|
|
||||||
</div>
|
|
||||||
<div class="feature">
|
|
||||||
<span class="feature-icon">⚡</span>
|
|
||||||
<span>High-speed connections</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Step 2: System Check -->
|
|
||||||
<section class="step-content" id="step2">
|
|
||||||
<h1>System Requirements</h1>
|
|
||||||
<p class="description">Checking your system compatibility...</p>
|
|
||||||
|
|
||||||
<div class="check-list" id="checkList">
|
|
||||||
<div class="check-item" id="checkAdmin">
|
|
||||||
<span class="check-icon pending">⏳</span>
|
|
||||||
<span class="check-label">Administrator privileges</span>
|
|
||||||
<span class="check-status"></span>
|
|
||||||
</div>
|
|
||||||
<div class="check-item" id="checkAesNi">
|
|
||||||
<span class="check-icon pending">⏳</span>
|
|
||||||
<span class="check-label">AES-NI CPU support</span>
|
|
||||||
<span class="check-status"></span>
|
|
||||||
</div>
|
|
||||||
<div class="check-item" id="checkWintun">
|
|
||||||
<span class="check-icon pending">⏳</span>
|
|
||||||
<span class="check-label">WinTUN driver</span>
|
|
||||||
<span class="check-status"></span>
|
|
||||||
</div>
|
|
||||||
<div class="check-item" id="checkOs">
|
|
||||||
<span class="check-icon pending">⏳</span>
|
|
||||||
<span class="check-label">Operating system</span>
|
|
||||||
<span class="check-status"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Step 3: Configuration -->
|
|
||||||
<section class="step-content" id="step3">
|
|
||||||
<h1>Configuration</h1>
|
|
||||||
<p class="description">Enter your access credentials and preferences.</p>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="accessKey">Access Key</label>
|
|
||||||
<input type="text" id="accessKey" placeholder="ospab://..." autocomplete="off">
|
|
||||||
<span class="input-hint">Paste the access key provided by your administrator</span>
|
|
||||||
<span class="input-error" id="accessKeyError"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="country">Region</label>
|
|
||||||
<select id="country">
|
|
||||||
<option value="">Loading...</option>
|
|
||||||
</select>
|
|
||||||
<span class="input-hint">Select the region for optimal server mimicry</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="installPath">Installation Path</label>
|
|
||||||
<div class="path-input">
|
|
||||||
<input type="text" id="installPath" readonly>
|
|
||||||
<button type="button" class="btn-browse" id="btnBrowse">Browse</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Step 4: Installation Progress -->
|
|
||||||
<section class="step-content" id="step4">
|
|
||||||
<h1>Installing</h1>
|
|
||||||
<p class="description" id="installStatus">Preparing installation...</p>
|
|
||||||
|
|
||||||
<div class="progress-container">
|
|
||||||
<div class="progress-bar">
|
|
||||||
<div class="progress-fill" id="progressFill" style="width: 0%"></div>
|
|
||||||
</div>
|
|
||||||
<span class="progress-text" id="progressText">0%</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="install-steps" id="installSteps">
|
|
||||||
<div class="install-step" data-step="1">
|
|
||||||
<span class="step-status">⏳</span>
|
|
||||||
<span>Extracting WinTUN driver</span>
|
|
||||||
</div>
|
|
||||||
<div class="install-step" data-step="2">
|
|
||||||
<span class="step-status">⏳</span>
|
|
||||||
<span>Validating access key</span>
|
|
||||||
</div>
|
|
||||||
<div class="install-step" data-step="3">
|
|
||||||
<span class="step-status">⏳</span>
|
|
||||||
<span>Writing configuration</span>
|
|
||||||
</div>
|
|
||||||
<div class="install-step" data-step="4">
|
|
||||||
<span class="step-status">⏳</span>
|
|
||||||
<span>Installing Windows Service</span>
|
|
||||||
</div>
|
|
||||||
<div class="install-step" data-step="5">
|
|
||||||
<span class="step-status">⏳</span>
|
|
||||||
<span>Configuring startup</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Step 5: Finish -->
|
|
||||||
<section class="step-content" id="step5">
|
|
||||||
<div class="step-icon success">
|
|
||||||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none">
|
|
||||||
<circle cx="32" cy="32" r="28" stroke="#10b981" stroke-width="3"/>
|
|
||||||
<path d="M20 32l8 8 16-16" stroke="#10b981" stroke-width="3" stroke-linecap="round"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<h1>Installation Complete!</h1>
|
|
||||||
<p class="description">
|
|
||||||
OSTP Client has been successfully installed on your system.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="finish-options">
|
|
||||||
<label class="checkbox-container">
|
|
||||||
<input type="checkbox" id="optConnectNow" checked>
|
|
||||||
<span class="checkmark"></span>
|
|
||||||
<span>Connect now</span>
|
|
||||||
</label>
|
|
||||||
<label class="checkbox-container">
|
|
||||||
<input type="checkbox" id="optLaunchStartup" checked>
|
|
||||||
<span class="checkmark"></span>
|
|
||||||
<span>Launch on system startup</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Footer / Navigation -->
|
|
||||||
<footer class="wizard-footer">
|
|
||||||
<button class="btn btn-secondary" id="btnBack" disabled>Back</button>
|
|
||||||
<div class="spacer"></div>
|
|
||||||
<button class="btn btn-secondary" id="btnCancel">Cancel</button>
|
|
||||||
<button class="btn btn-primary" id="btnNext">Next</button>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="app.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,444 +0,0 @@
|
|||||||
:root {
|
|
||||||
--bg-primary: #0f0f14;
|
|
||||||
--bg-secondary: #1a1a24;
|
|
||||||
--bg-tertiary: #252532;
|
|
||||||
--text-primary: #f5f5f7;
|
|
||||||
--text-secondary: #a1a1aa;
|
|
||||||
--text-muted: #71717a;
|
|
||||||
--accent: #6366f1;
|
|
||||||
--accent-hover: #818cf8;
|
|
||||||
--success: #10b981;
|
|
||||||
--error: #ef4444;
|
|
||||||
--warning: #f59e0b;
|
|
||||||
--border: #27272a;
|
|
||||||
--shadow: rgba(0, 0, 0, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
|
|
||||||
background: var(--bg-primary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
min-height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wizard-container {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 600px;
|
|
||||||
min-height: 480px;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border-radius: 12px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
box-shadow: 0 20px 60px var(--shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header */
|
|
||||||
.wizard-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 20px 24px;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-indicator {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-indicator .step {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
color: var(--text-muted);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-indicator .step.active {
|
|
||||||
background: var(--accent);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-indicator .step.completed {
|
|
||||||
background: var(--success);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Step Content */
|
|
||||||
.step-content {
|
|
||||||
flex: 1;
|
|
||||||
padding: 32px 24px;
|
|
||||||
display: none;
|
|
||||||
flex-direction: column;
|
|
||||||
animation: fadeIn 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-content.active {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from { opacity: 0; transform: translateY(10px); }
|
|
||||||
to { opacity: 1; transform: translateY(0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-content h1 {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 600;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-content .description {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-bottom: 24px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-icon {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Features List (Welcome) */
|
|
||||||
.features {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feature {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 12px 16px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feature-icon {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check List (System Check) */
|
|
||||||
.check-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 14px 16px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border-radius: 8px;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-item .check-icon {
|
|
||||||
font-size: 18px;
|
|
||||||
min-width: 24px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-item .check-icon.success { color: var(--success); }
|
|
||||||
.check-item .check-icon.error { color: var(--error); }
|
|
||||||
.check-item .check-icon.pending { color: var(--text-muted); }
|
|
||||||
|
|
||||||
.check-item .check-label {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-item .check-status {
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Form Elements */
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input,
|
|
||||||
.form-group select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px 14px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: 8px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 14px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input:focus,
|
|
||||||
.form-group select:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: var(--accent);
|
|
||||||
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input.error {
|
|
||||||
border-color: var(--error);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group .input-hint {
|
|
||||||
display: block;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-muted);
|
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group .input-error {
|
|
||||||
display: block;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--error);
|
|
||||||
margin-top: 6px;
|
|
||||||
min-height: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.path-input {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.path-input input {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-browse {
|
|
||||||
padding: 12px 16px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: 8px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-browse:hover {
|
|
||||||
background: var(--accent);
|
|
||||||
border-color: var(--accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Progress */
|
|
||||||
.progress-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
flex: 1;
|
|
||||||
height: 8px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border-radius: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-fill {
|
|
||||||
height: 100%;
|
|
||||||
background: linear-gradient(90deg, var(--accent), var(--accent-hover));
|
|
||||||
border-radius: 4px;
|
|
||||||
transition: width 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-text {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--accent);
|
|
||||||
min-width: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.install-steps {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.install-step {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 10px 14px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 14px;
|
|
||||||
opacity: 0.6;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.install-step.active {
|
|
||||||
opacity: 1;
|
|
||||||
background: rgba(99, 102, 241, 0.15);
|
|
||||||
border-left: 3px solid var(--accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.install-step.completed {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.install-step .step-status {
|
|
||||||
min-width: 20px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finish Options */
|
|
||||||
.finish-options {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 12px 16px;
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
border-radius: 8px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container:hover {
|
|
||||||
background: var(--bg-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container input {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container .checkmark {
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
border: 2px solid var(--border);
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container input:checked + .checkmark {
|
|
||||||
background: var(--accent);
|
|
||||||
border-color: var(--accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container input:checked + .checkmark::after {
|
|
||||||
content: '✓';
|
|
||||||
color: white;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Footer */
|
|
||||||
.wizard-footer {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 16px 24px;
|
|
||||||
border-top: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.spacer {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
padding: 10px 24px;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: var(--accent);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover:not(:disabled) {
|
|
||||||
background: var(--accent-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover:not(:disabled) {
|
|
||||||
background: var(--bg-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success state icon */
|
|
||||||
.step-icon.success svg circle {
|
|
||||||
stroke: var(--success);
|
|
||||||
}
|
|
||||||
|
|
||||||
.step-icon.success svg path {
|
|
||||||
stroke: var(--success);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scrollbar */
|
|
||||||
::-webkit-scrollbar {
|
|
||||||
width: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-track {
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: var(--border);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: var(--text-muted);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user