feat: Windows Setup Wizard (ostp-setup) with Tauri

- Tauri 2.0 based graphical installer
- Access Key parsing with AES-256-GCM encryption
- Windows Service installation via sc.exe
- WinTUN driver extraction from embedded resources
- System requirements checking (admin, AES-NI, OS version)
- Modern dark UI with step-by-step wizard flow
- Country/region selection for SNI mimicry
This commit is contained in:
2026-01-01 21:49:37 +03:00
parent 320e5fee85
commit 7e1c87e70b
21 changed files with 10916 additions and 41 deletions

360
ostp-setup/ui/app.js Normal file
View File

@@ -0,0 +1,360 @@
// 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);
};
}

190
ostp-setup/ui/index.html Normal file
View File

@@ -0,0 +1,190 @@
<!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>

444
ostp-setup/ui/styles.css Normal file
View File

@@ -0,0 +1,444 @@
: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);
}