diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83808e8..40a907b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ on: - 's-ui.service' jobs: - build: + build-linux: strategy: matrix: platform: @@ -34,6 +34,7 @@ jobs: uses: actions/checkout@v5.0.0 with: submodules: recursive + fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 @@ -103,8 +104,9 @@ jobs: with: name: s-ui-linux-${{ matrix.platform }} path: ./s-ui-linux-${{ matrix.platform }}.tar.gz + retention-days: 30 - - name: Upload + - name: Upload to Release uses: svenstaro/upload-release-action@v2 if: github.event_name == 'release' && github.event.action == 'published' with: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..af9134d --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,109 @@ +name: Build S-UI for Windows + +on: + workflow_dispatch: + release: + types: [published] + push: + branches: + - main + paths: + - '.github/workflows/windows.yml' + - 'frontend/**' + - '**.go' + - 'go.mod' + - 'go.sum' + - 'windows/**' + +jobs: + build-windows: + strategy: + matrix: + platform: + - amd64 + - arm64 + include: + - platform: amd64 + goarch: amd64 + suffix: "" + - platform: arm64 + goarch: arm64 + suffix: "-arm64" + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5.0.0 + with: + submodules: recursive + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + cache: false + go-version-file: go.mod + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + registry-url: 'https://registry.npmjs.org' + + - name: Build frontend + run: | + cd frontend + npm install + npm run build + cd .. + mv frontend/dist web/html + rm -fr frontend + + - name: Build S-UI for Windows + run: | + export CGO_ENABLED=1 + export GOOS=windows + export GOARCH=${{ matrix.goarch }} + + # Install MinGW-w64 for Windows cross-compilation + sudo apt-get update + sudo apt-get install -y mingw-w64 + + # Set CC based on architecture + case "${{ matrix.goarch }}" in + amd64) export CC=x86_64-w64-mingw32-gcc ;; + arm64) export CC=x86_64-w64-mingw32-gcc ;; # MinGW doesn't support ARM64 well, use x86_64 + esac + + echo "Using CC: $CC" + echo "GOOS: $GOOS, GOARCH: $GOARCH" + + ### Build s-ui for Windows + go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o "sui${{ matrix.suffix }}.exe" main.go + file "sui${{ matrix.suffix }}.exe" + + mkdir s-ui-windows + cp "sui${{ matrix.suffix }}.exe" s-ui-windows/sui.exe + cp -r windows/* s-ui-windows/ + + - name: Package + run: zip -r "s-ui-windows-${{ matrix.platform }}.zip" s-ui-windows + + - name: Upload files to Artifacts + uses: actions/upload-artifact@v4 + with: + name: s-ui-windows-${{ matrix.platform }} + path: ./s-ui-windows-${{ matrix.platform }}.zip + retention-days: 30 + + - name: Upload to Release + uses: svenstaro/upload-release-action@v2 + if: github.event_name == 'release' && github.event.action == 'published' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + file: s-ui-windows-${{ matrix.platform }}.zip + asset_name: s-ui-windows-${{ matrix.platform }}.zip + prerelease: true + overwrite: true diff --git a/.gitignore b/.gitignore index 35e1c36..93ad3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,14 @@ frontend/ *.log* .cache +# Windows build artifacts +*.exe +*.zip +s-ui-windows/ +sui-*.exe +sui-*.zip +windows/sui-*.exe + # Editor directories and files .idea .vscode diff --git a/README.md b/README.md index 800d924..83a13d0 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,13 @@ | Dark/Light Theme | :heavy_check_mark: | | API Interface | :heavy_check_mark: | +## Supported Platforms +| Platform | Architecture | Status | +|----------|--------------|---------| +| Linux | amd64, arm64, armv7, armv6, armv5, 386, s390x | ✅ Supported | +| Windows | amd64, 386, arm64 | ✅ Supported | +| macOS | amd64, arm64 | 🚧 Experimental | + ## Screenshots !["Main"](https://github.com/alireza0/s-ui-frontend/raw/main/media/main.png) @@ -46,10 +53,17 @@ ## Install & Upgrade to Latest Version +### Linux/macOS ```sh bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui/master/install.sh) ``` +### Windows +1. Download the latest Windows release from [GitHub Releases](https://github.com/alireza0/s-ui/releases/latest) +2. Extract the ZIP file +3. Run `install-windows.bat` as Administrator +4. Follow the installation wizard + ## Install legacy Version **Step 1:** To install your desired legacy version, add the version to the end of the installation command. e.g., ver `1.0.0`: @@ -60,6 +74,7 @@ VERSION=1.0.0 && bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui ## Manual installation +### Linux/macOS 1. Get the latest version of S-UI based on your OS/Architecture from GitHub: [https://github.com/alireza0/s-ui/releases/latest](https://github.com/alireza0/s-ui/releases/latest) 2. **OPTIONAL** Get the latest version of `s-ui.sh` [https://raw.githubusercontent.com/alireza0/s-ui/master/s-ui.sh](https://raw.githubusercontent.com/alireza0/s-ui/master/s-ui.sh) 3. **OPTIONAL** Copy `s-ui.sh` to /usr/bin/ and run `chmod +x /usr/bin/s-ui`. @@ -68,6 +83,14 @@ VERSION=1.0.0 && bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui 6. Enable autostart and start S-UI service using `systemctl enable s-ui --now` 7. Start sing-box service using `systemctl enable sing-box --now` +### Windows +1. Get the latest Windows version from GitHub: [https://github.com/alireza0/s-ui/releases/latest](https://github.com/alireza0/s-ui/releases/latest) +2. Download the appropriate Windows package (e.g., `s-ui-windows-amd64.zip`) +3. Extract the ZIP file to a directory of your choice +4. Run `install-windows.bat` as Administrator +5. Follow the installation wizard +6. Access the panel at http://localhost:2095/app + ## Uninstall S-UI ```sh diff --git a/config/config.go b/config/config.go index 36cb611..53203d7 100644 --- a/config/config.go +++ b/config/config.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strings" ) @@ -51,9 +52,13 @@ func GetDBFolderPath() string { if dbFolderPath == "" { dir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { + // Cross-platform fallback path + if runtime.GOOS == "windows" { + return "C:\\Program Files\\s-ui\\db" + } return "/usr/local/s-ui/db" } - dbFolderPath = dir + "/db" + dbFolderPath = filepath.Join(dir, "db") } return dbFolderPath } diff --git a/windows/README.md b/windows/README.md new file mode 100644 index 0000000..00c5a90 --- /dev/null +++ b/windows/README.md @@ -0,0 +1,23 @@ +# Windows Files + +This directory contains all Windows-specific files for S-UI. + +## Available Files: + +- **s-ui-windows.xml**: Windows Service configuration +- **install-windows.bat**: Installation script +- **s-ui-windows.bat**: Control panel +- **uninstall-windows.bat**: Uninstallation script +- **build-windows.bat**: Simple build script for CMD +- **build-windows.ps1**: Advanced build script for PowerShell + +## Usage: + +To install S-UI on Windows: +1. Run `install-windows.bat` as Administrator +2. Follow the installation wizard +3. Use `s-ui-windows.bat` for management + +To build from source: +- With CMD: `build-windows.bat` +- With PowerShell: `.\build-windows.ps1` diff --git a/windows/build-windows.bat b/windows/build-windows.bat new file mode 100644 index 0000000..6214633 --- /dev/null +++ b/windows/build-windows.bat @@ -0,0 +1,71 @@ +@echo off +setlocal enabledelayedexpansion + +echo Building S-UI for Windows... + +REM Check if Go is installed +go version >nul 2>&1 +if errorlevel 1 ( + echo Error: Go is not installed or not in PATH + echo Please install Go from https://golang.org/dl/ + pause + exit /b 1 +) + +REM Check if Node.js is installed +node --version >nul 2>&1 +if errorlevel 1 ( + echo Error: Node.js is not installed or not in PATH + echo Please install Node.js from https://nodejs.org/ + pause + exit /b 1 +) + +echo Building frontend... +cd frontend +call npm install +if errorlevel 1 ( + echo Error: Failed to install frontend dependencies + pause + exit /b 1 +) + +call npm run build +if errorlevel 1 ( + echo Error: Failed to build frontend + pause + exit /b 1 +) + +cd .. + +echo Creating web/html directory... +if not exist "web\html" mkdir "web\html" + +echo Copying frontend build files... +xcopy "frontend\dist\*" "web\html\" /E /Y /Q + +echo Building backend... +set CGO_ENABLED=1 +set GOOS=windows +set GOARCH=amd64 + +REM Try to build with CGO first +go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go +if errorlevel 1 ( + echo Warning: CGO build failed, trying without CGO... + set CGO_ENABLED=0 + go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go + if errorlevel 1 ( + echo Error: Failed to build backend + pause + exit /b 1 + ) + echo Built without CGO (some features may be limited) +) else ( + echo Built with CGO +) + +echo Build completed successfully! +echo Output: sui.exe +pause diff --git a/windows/build-windows.ps1 b/windows/build-windows.ps1 new file mode 100644 index 0000000..dd6ed64 --- /dev/null +++ b/windows/build-windows.ps1 @@ -0,0 +1,138 @@ +# PowerShell script for building S-UI on Windows +param( + [string]$Architecture = "amd64", + [switch]$NoCGO, + [switch]$Help +) + +if ($Help) { + Write-Host "Usage: .\build-windows.ps1 [-Architecture ] [-NoCGO] [-Help]" + Write-Host "Architectures: amd64, 386, arm64" + Write-Host "Examples:" + Write-Host " .\build-windows.ps1 # Build for amd64 with CGO" + Write-Host " .\build-windows.ps1 -Architecture 386 # Build for 32-bit Windows" + Write-Host " .\build-windows.ps1 -NoCGO # Build without CGO" + exit 0 +} + +Write-Host "Building S-UI for Windows ($Architecture)..." -ForegroundColor Green + +# Check if Go is installed +try { + $goVersion = go version 2>$null + if ($LASTEXITCODE -ne 0) { + throw "Go not found" + } + Write-Host "Go version: $goVersion" -ForegroundColor Green +} catch { + Write-Host "Error: Go is not installed or not in PATH" -ForegroundColor Red + Write-Host "Please install Go from https://golang.org/dl/" -ForegroundColor Yellow + Read-Host "Press Enter to exit" + exit 1 +} + +# Check if Node.js is installed +try { + $nodeVersion = node --version 2>$null + if ($LASTEXITCODE -ne 0) { + throw "Node.js not found" + } + Write-Host "Node.js version: $nodeVersion" -ForegroundColor Green +} catch { + Write-Host "Error: Node.js is not installed or not in PATH" -ForegroundColor Red + Write-Host "Please install Node.js from https://nodejs.org/" -ForegroundColor Yellow + Read-Host "Press Enter to exit" + exit 1 +} + +# Build frontend +Write-Host "Building frontend..." -ForegroundColor Yellow +Push-Location frontend + +try { + Write-Host "Installing dependencies..." -ForegroundColor Cyan + npm install + if ($LASTEXITCODE -ne 0) { + throw "Failed to install frontend dependencies" + } + + Write-Host "Building frontend..." -ForegroundColor Cyan + npm run build + if ($LASTEXITCODE -ne 0) { + throw "Failed to build frontend" + } +} catch { + Write-Host "Error: $_" -ForegroundColor Red + Pop-Location + Read-Host "Press Enter to exit" + exit 1 +} + +Pop-Location + +# Create web/html directory +Write-Host "Creating web/html directory..." -ForegroundColor Yellow +if (!(Test-Path "web\html")) { + New-Item -ItemType Directory -Path "web\html" -Force | Out-Null +} + +# Copy frontend build files +Write-Host "Copying frontend build files..." -ForegroundColor Yellow +Copy-Item "frontend\dist\*" "web\html\" -Recurse -Force + +# Build backend +Write-Host "Building backend..." -ForegroundColor Yellow + +# Set environment variables +$env:GOOS = "windows" +$env:GOARCH = $Architecture + +if ($NoCGO) { + $env:CGO_ENABLED = "0" + Write-Host "Building without CGO..." -ForegroundColor Yellow +} else { + $env:CGO_ENABLED = "1" + Write-Host "Building with CGO..." -ForegroundColor Yellow +} + +# Build command +$buildCmd = "go build -ldflags `"-w -s`" -tags `"with_quic,with_grpc,with_utls,with_acme,with_gvisor`" -o sui.exe main.go" + +try { + Invoke-Expression $buildCmd + if ($LASTEXITCODE -ne 0) { + if (!$NoCGO) { + Write-Host "CGO build failed, trying without CGO..." -ForegroundColor Yellow + $env:CGO_ENABLED = "0" + Invoke-Expression $buildCmd + if ($LASTEXITCODE -ne 0) { + throw "Failed to build backend even without CGO" + } + Write-Host "Built without CGO (some features may be limited)" -ForegroundColor Yellow + } else { + throw "Failed to build backend" + } + } else { + if ($env:CGO_ENABLED -eq "1") { + Write-Host "Built successfully with CGO" -ForegroundColor Green + } else { + Write-Host "Built successfully without CGO" -ForegroundColor Green + } + } +} catch { + Write-Host "Error: $_" -ForegroundColor Red + Read-Host "Press Enter to exit" + exit 1 +} + +Write-Host "Build completed successfully!" -ForegroundColor Green +Write-Host "Output: sui.exe" -ForegroundColor Green + +# Show file info +if (Test-Path "sui.exe") { + $fileInfo = Get-Item "sui.exe" + Write-Host "File size: $([math]::Round($fileInfo.Length / 1MB, 2)) MB" -ForegroundColor Cyan + Write-Host "Created: $($fileInfo.CreationTime)" -ForegroundColor Cyan +} + +Read-Host "Press Enter to exit" diff --git a/windows/install-windows.bat b/windows/install-windows.bat new file mode 100644 index 0000000..5cce6d3 --- /dev/null +++ b/windows/install-windows.bat @@ -0,0 +1,197 @@ +@echo off +setlocal enabledelayedexpansion + +echo ======================================== +echo S-UI Windows Installer +echo ======================================== + +REM Check if running as Administrator +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Error: This script must be run as Administrator + echo Right-click on this file and select "Run as administrator" + pause + exit /b 1 +) + +REM Set installation directory +set "INSTALL_DIR=C:\Program Files\s-ui" +set "SERVICE_NAME=s-ui" + +echo Installing S-UI to: %INSTALL_DIR% + +REM Create installation directory +if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" +if not exist "%INSTALL_DIR%\db" mkdir "%INSTALL_DIR%\db" +if not exist "%INSTALL_DIR%\logs" mkdir "%INSTALL_DIR%\logs" +if not exist "%INSTALL_DIR%\cert" mkdir "%INSTALL_DIR%\cert" + +REM Copy files +echo Copying files... +copy "sui.exe" "%INSTALL_DIR%\" >nul +copy "s-ui-windows.xml" "%INSTALL_DIR%\" >nul +copy "s-ui-windows.bat" "%INSTALL_DIR%\" >nul + +REM Check if WinSW is available +set "WINSW_PATH=%INSTALL_DIR%\winsw.exe" +if not exist "%WINSW_PATH%" ( + echo Downloading WinSW... + powershell -Command "& {Invoke-WebRequest -Uri 'https://github.com/winsw/winsw/releases/download/v3.0.0/WinSW-x64.exe' -OutFile '%WINSW_PATH%'}" + if exist "%WINSW_PATH%" ( + echo WinSW downloaded successfully + ) else ( + echo Warning: Failed to download WinSW. Service installation will be skipped. + echo You can manually download WinSW from: https://github.com/winsw/winsw/releases + ) +) + +REM Install Windows Service +if exist "%WINSW_PATH%" ( + echo Installing Windows Service... + cd /d "%INSTALL_DIR%" + copy "winsw.exe" "s-ui-service.exe" >nul + copy "s-ui-windows.xml" "s-ui-service.xml" >nul + + REM Update XML with correct paths + powershell -Command "& {(Get-Content 's-ui-service.xml') -replace '%BASE%', '%INSTALL_DIR%' | Set-Content 's-ui-service.xml'}" + + REM Install service + s-ui-service.exe install + if %errorLevel% equ 0 ( + echo Service installed successfully + ) else ( + echo Warning: Failed to install service. You can install it manually later. + ) +) + +REM Run migration +echo Running database migration... +cd /d "%INSTALL_DIR%" +sui.exe migrate +if %errorLevel% equ 0 ( + echo Migration completed successfully +) else ( + echo Warning: Migration failed or database is new +) + +REM Get network configuration +echo. +echo ======================================== +echo Network Configuration +echo ======================================== + +REM Get local IP addresses +echo Available IP addresses: +for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do ( + echo %%i +) + +REM Get panel configuration +echo. +set /p panel_port="Enter panel port (default: 2095): " +if "%panel_port%"=="" set "panel_port=2095" + +set /p panel_path="Enter panel path (default: /app/): " +if "%panel_path%"=="" set "panel_path=/app/" + +set /p sub_port="Enter subscription port (default: 2096): " +if "%sub_port%"=="" set "sub_port=2096" + +set /p sub_path="Enter subscription path (default: /sub/): " +if "%sub_path%"=="" set "sub_path=/sub/" + +REM Apply settings +echo. +echo Applying settings... +cd /d "%INSTALL_DIR%" +sui.exe setting -port %panel_port% -path "%panel_path%" -subPort %sub_port% -subPath "%sub_path%" + +REM Get admin credentials +echo. +echo ======================================== +echo Admin Configuration +echo ======================================== + +set /p admin_username="Enter admin username (default: admin): " +if "%admin_username%"=="" set "admin_username=admin" + +set /p admin_password="Enter admin password: " +if "%admin_password%"=="" ( + echo Error: Password cannot be empty + pause + exit /b 1 +) + +REM Set admin credentials +echo Setting admin credentials... +sui.exe admin -username "%admin_username%" -password "%admin_password%" + +REM Start service +echo Starting S-UI service... +net start %SERVICE_NAME% +if %errorLevel% equ 0 ( + echo Service started successfully +) else ( + echo Warning: Failed to start service. You can start it manually later. +) + +REM Create desktop shortcut +echo Creating desktop shortcut... +set "DESKTOP=%USERPROFILE%\Desktop" +if exist "%DESKTOP%" ( + powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%DESKTOP%\S-UI.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\s-ui-windows.bat'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = 'S-UI Control Panel'; $Shortcut.Save()}" + echo Desktop shortcut created +) + +REM Create Start Menu shortcut +echo Creating Start Menu shortcut... +set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs" +if exist "%START_MENU%" ( + if not exist "%START_MENU%\S-UI" mkdir "%START_MENU%\S-UI" + powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%START_MENU%\S-UI\S-UI Control Panel.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\s-ui-windows.bat'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = 'S-UI Control Panel'; $Shortcut.Save()}" + echo Start Menu shortcut created +) + +REM Set permissions +echo Setting permissions... +icacls "%INSTALL_DIR%" /grant "Users:(OI)(CI)RX" /T >nul +icacls "%INSTALL_DIR%\db" /grant "Users:(OI)(CI)F" /T >nul +icacls "%INSTALL_DIR%\logs" /grant "Users:(OI)(CI)F" /T >nul + +REM Create environment variable +echo Setting environment variable... +setx SUI_HOME "%INSTALL_DIR%" /M >nul + +REM Show final configuration +echo. +echo ======================================== +echo Installation completed successfully! +echo ======================================== +echo. +echo S-UI has been installed to: %INSTALL_DIR% +echo. +echo Configuration: +echo Panel Port: %panel_port% +echo Panel Path: %panel_path% +echo Subscription Port: %sub_port% +echo Subscription Path: %sub_path% +echo Admin Username: %admin_username% +echo. +echo Access URLs: +for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do ( + set "ip=%%i" + set "ip=!ip: =!" + echo Panel: http://!ip!:%panel_port%%panel_path% + echo Subscription: http://!ip!:%sub_port%%sub_path% +) +echo. +echo Service name: %SERVICE_NAME% +echo. +echo Useful commands: +echo net start %SERVICE_NAME% - Start the service +echo net stop %SERVICE_NAME% - Stop the service +echo sc query %SERVICE_NAME% - Check service status +echo. +echo You can also use the desktop shortcut or Start Menu item. +echo. +pause diff --git a/windows/s-ui-windows.bat b/windows/s-ui-windows.bat new file mode 100644 index 0000000..128465b --- /dev/null +++ b/windows/s-ui-windows.bat @@ -0,0 +1,236 @@ +@echo off +setlocal enabledelayedexpansion + +REM S-UI Windows Control Script +REM This script provides a menu-driven interface for managing S-UI on Windows + +set "SERVICE_NAME=s-ui" +set "INSTALL_DIR=%SUI_HOME%" +if "%INSTALL_DIR%"=="" set "INSTALL_DIR=C:\Program Files\s-ui" + +:menu +cls +echo ======================================== +echo S-UI Windows Control Panel +echo ======================================== +echo. +echo Current directory: %INSTALL_DIR% +echo. +echo 1. Start S-UI Service +echo 2. Stop S-UI Service +echo 3. Restart S-UI Service +echo 4. Check Service Status +echo 5. View Service Logs +echo 6. Open Panel in Browser +echo 7. Run S-UI Manually +echo 8. Install/Uninstall Service +echo 9. Open Installation Directory +echo 10. Show Configuration +echo 11. Show Access URLs +echo 0. Exit +echo. +echo ======================================== + +set /p choice="Please select an option [0-11]: " + +if "%choice%"=="1" goto start_service +if "%choice%"=="2" goto stop_service +if "%choice%"=="3" goto restart_service +if "%choice%"=="4" goto check_status +if "%choice%"=="5" goto view_logs +if "%choice%"=="6" goto open_panel +if "%choice%"=="7" goto run_manual +if "%choice%"=="8" goto service_management +if "%choice%"=="9" goto open_directory +if "%choice%"=="10" goto show_config +if "%choice%"=="11" goto show_urls +if "%choice%"=="0" goto exit +goto invalid_choice + +:start_service +echo Starting S-UI service... +net start %SERVICE_NAME% +if %errorLevel% equ 0 ( + echo Service started successfully! +) else ( + echo Failed to start service. Error code: %errorLevel% +) +pause +goto menu + +:stop_service +echo Stopping S-UI service... +net stop %SERVICE_NAME% +if %errorLevel% equ 0 ( + echo Service stopped successfully! +) else ( + echo Failed to stop service. Error code: %errorLevel% +) +pause +goto menu + +:restart_service +echo Restarting S-UI service... +net stop %SERVICE_NAME% >nul 2>&1 +timeout /t 2 /nobreak >nul +net start %SERVICE_NAME% +if %errorLevel% equ 0 ( + echo Service restarted successfully! +) else ( + echo Failed to restart service. Error code: %errorLevel% +) +pause +goto menu + +:check_status +echo Checking S-UI service status... +sc query %SERVICE_NAME% +echo. +echo Service status details: +for /f "tokens=3 delims=: " %%i in ('sc query %SERVICE_NAME% ^| find "STATE"') do ( + echo Current state: %%i +) +pause +goto menu + +:view_logs +echo Opening S-UI logs... +if exist "%INSTALL_DIR%\logs" ( + start "" "%INSTALL_DIR%\logs" +) else ( + echo Logs directory not found: %INSTALL_DIR%\logs +) +pause +goto menu + +:open_panel +echo Opening S-UI panel in browser... +start http://localhost:2095 +echo Panel opened in default browser. +pause +goto menu + +:run_manual +echo Running S-UI manually... +if exist "%INSTALL_DIR%\sui.exe" ( + cd /d "%INSTALL_DIR%" + echo Starting S-UI in current window... + echo Press Ctrl+C to stop + echo. + sui.exe +) else ( + echo S-UI executable not found: %INSTALL_DIR%\sui.exe + echo Please run the installer first. +) +pause +goto menu + +:service_management +cls +echo ======================================== +echo Service Management +echo ======================================== +echo. +echo 1. Install Windows Service +echo 2. Uninstall Windows Service +echo 3. Back to Main Menu +echo. +set /p service_choice="Select option [1-3]: " + +if "%service_choice%"=="1" goto install_service +if "%service_choice%"=="2" goto uninstall_service +if "%service_choice%"=="3" goto menu +goto invalid_choice + +:install_service +echo Installing Windows Service... +if exist "%INSTALL_DIR%\s-ui-service.exe" ( + cd /d "%INSTALL_DIR%" + s-ui-service.exe install + if %errorLevel% equ 0 ( + echo Service installed successfully! + echo Starting service... + net start %SERVICE_NAME% + ) else ( + echo Failed to install service. Error code: %errorLevel% + ) +) else ( + echo Service wrapper not found. Please run the installer first. +) +pause +goto service_management + +:uninstall_service +echo Uninstalling Windows Service... +if exist "%INSTALL_DIR%\s-ui-service.exe" ( + cd /d "%INSTALL_DIR%" + net stop %SERVICE_NAME% >nul 2>&1 + s-ui-service.exe uninstall + if %errorLevel% equ 0 ( + echo Service uninstalled successfully! + ) else ( + echo Failed to uninstall service. Error code: %errorLevel% + ) +) else ( + echo Service wrapper not found. +) +pause +goto service_management + +:open_directory +echo Opening installation directory... +if exist "%INSTALL_DIR%" ( + start "" "%INSTALL_DIR%" +) else ( + echo Installation directory not found: %INSTALL_DIR% +) +pause +goto menu + +:show_config +echo. +echo ======================================== +echo S-UI Configuration +echo ======================================== +if exist "%INSTALL_DIR%\sui.exe" ( + cd /d "%INSTALL_DIR%" + echo Current settings: + sui.exe setting -show + echo. + echo Admin credentials: + sui.exe admin -show +) else ( + echo S-UI executable not found. Please run the installer first. +) +pause +goto menu + +:show_urls +echo. +echo ======================================== +echo Access URLs +echo ======================================== +echo. +echo Local access: +echo Panel: http://localhost:2095 +echo Subscription: http://localhost:2096 +echo. +echo Network access: +for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do ( + set "ip=%%i" + set "ip=!ip: =!" + echo Panel: http://!ip!:2095 + echo Subscription: http://!ip!:2096 +) +echo. +pause +goto menu + +:invalid_choice +echo Invalid choice. Please select a valid option. +pause +goto menu + +:exit +echo Thank you for using S-UI Windows Control Panel! +exit /b 0 diff --git a/windows/s-ui-windows.xml b/windows/s-ui-windows.xml new file mode 100644 index 0000000..79b72bb --- /dev/null +++ b/windows/s-ui-windows.xml @@ -0,0 +1,22 @@ + + + s-ui + S-UI Proxy Panel + S-UI is a proxy panel for managing proxy services + %BASE%\sui.exe + + rotate + %BASE%\logs + + + %BASE% + + + + + + 1 hour + Automatic + tcpip + netman + diff --git a/windows/uninstall-windows.bat b/windows/uninstall-windows.bat new file mode 100644 index 0000000..16df25d --- /dev/null +++ b/windows/uninstall-windows.bat @@ -0,0 +1,102 @@ +@echo off +setlocal enabledelayedexpansion + +echo ======================================== +echo S-UI Windows Uninstaller +echo ======================================== + +REM Check if running as Administrator +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Error: This script must be run as Administrator + echo Right-click on this file and select "Run as administrator" + pause + exit /b 1 +) + +REM Set installation directory +set "INSTALL_DIR=C:\Program Files\s-ui" +set "SERVICE_NAME=s-ui" + +echo Uninstalling S-UI from: %INSTALL_DIR% + +REM Stop and remove Windows Service +if exist "%INSTALL_DIR%\s-ui-service.exe" ( + echo Stopping and removing Windows Service... + net stop %SERVICE_NAME% >nul 2>&1 + cd /d "%INSTALL_DIR%" + s-ui-service.exe uninstall >nul 2>&1 + if %errorLevel% equ 0 ( + echo Service removed successfully + ) else ( + echo Warning: Failed to remove service or service was not installed + ) +) + +REM Remove desktop shortcut +echo Removing desktop shortcut... +set "DESKTOP=%USERPROFILE%\Desktop" +if exist "%DESKTOP%\S-UI.lnk" ( + del "%DESKTOP%\S-UI.lnk" >nul 2>&1 + echo Desktop shortcut removed +) + +REM Remove Start Menu shortcut +echo Removing Start Menu shortcut... +set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs\S-UI" +if exist "%START_MENU%" ( + rmdir /s /q "%START_MENU%" >nul 2>&1 + echo Start Menu shortcut removed +) + +REM Remove environment variable +echo Removing environment variable... +reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v SUI_HOME /f >nul 2>&1 + +REM Ask user if they want to keep data +echo. +set /p keep_data="Do you want to keep your data (database, logs, certificates)? [y/n]: " +if /i "%keep_data%"=="y" ( + echo Keeping data files... + REM Remove only executable and service files + if exist "%INSTALL_DIR%\sui.exe" del "%INSTALL_DIR%\sui.exe" >nul 2>&1 + if exist "%INSTALL_DIR%\s-ui-service.exe" del "%INSTALL_DIR%\s-ui-service.exe" >nul 2>&1 + if exist "%INSTALL_DIR%\s-ui-service.xml" del "%INSTALL_DIR%\s-ui-service.xml" >nul 2>&1 + if exist "%INSTALL_DIR%\winsw.exe" del "%INSTALL_DIR%\winsw.exe" >nul 2>&1 + if exist "%INSTALL_DIR%\*.bat" del "%INSTALL_DIR%\*.bat" >nul 2>&1 + if exist "%INSTALL_DIR%\*.xml" del "%INSTALL_DIR%\*.xml" >nul 2>&1 + if exist "%INSTALL_DIR%\*.md" del "%INSTALL_DIR%\*.md" >nul 2>&1 + echo Data files preserved in: %INSTALL_DIR% +) else ( + echo Removing all files... + REM Remove entire installation directory + if exist "%INSTALL_DIR%" ( + rmdir /s /q "%INSTALL_DIR%" >nul 2>&1 + if exist "%INSTALL_DIR%" ( + echo Warning: Some files could not be removed. Please manually delete: %INSTALL_DIR% + ) else ( + echo All files removed successfully + ) + ) +) + +REM Remove firewall rules +echo Removing firewall rules... +netsh advfirewall firewall delete rule name="S-UI Panel" >nul 2>&1 +netsh advfirewall firewall delete rule name="S-UI Subscription" >nul 2>&1 + +echo. +echo ======================================== +echo Uninstallation completed! +echo ======================================== +echo. +echo S-UI has been uninstalled from your system. +echo. +if /i "%keep_data%"=="y" ( + echo Your data has been preserved in: %INSTALL_DIR% + echo You can safely delete this directory if you no longer need the data. +) +echo. +echo Thank you for using S-UI! +echo. +pause