# ProxVN client installer for Windows # irm https://proxvn.io.vn/install.ps1 | iex $ErrorActionPreference = 'Stop' $base = if ($env:PROXVN_BASE) { $env:PROXVN_BASE } else { 'https://proxvn.io.vn' } $base = $base.TrimEnd('/') $sourceUri = [Uri]$base if (-not $sourceUri.IsAbsoluteUri -or $sourceUri.Scheme -ne 'https' -or $sourceUri.Query -or $sourceUri.Fragment) { throw 'Nguồn tải phải là địa chỉ HTTPS hợp lệ' } [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 if (-not [Environment]::Is64BitOperatingSystem) { throw 'ProxVN chỉ hỗ trợ Windows 64-bit' } $dir = Join-Path $env:LOCALAPPDATA 'ProxVN' $exe = Join-Path $dir 'proxvn.exe' $file = 'proxvn-windows-amd64.exe' $temporary = Join-Path ([IO.Path]::GetTempPath()) ('proxvn-' + [Guid]::NewGuid().ToString('N')) $download = Join-Path $temporary $file Write-Host '' Write-Host ' ProxVN Tunnel — đang cài đặt cho Windows' -ForegroundColor Cyan $ProgressPreference = 'SilentlyContinue' try { New-Item -ItemType Directory -Path $temporary | Out-Null # Use the canonical HTTPS source and reject redirects, including TLS downgrades. $sums = (Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -TimeoutSec 300 -Uri "$base/bin/SHA256SUMS-client.txt").Content $escapedFile = [regex]::Escape($file) $entries = @($sums -split '\r?\n' | Where-Object { $_ -match ("\s\*?" + $escapedFile + '\s*$') }) if ($entries.Count -ne 1 -or $entries[0] -notmatch ('^(?[0-9a-fA-F]{64})[ \t]+\*?' + $escapedFile + '[ \t]*$')) { throw "Checksum SHA-256 cho $file bị thiếu hoặc không hợp lệ" } $want = $Matches['hash'].ToLowerInvariant() Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -TimeoutSec 300 -Uri "$base/bin/client/$file" -OutFile $download $got = (Get-FileHash $download -Algorithm SHA256).Hash.ToLowerInvariant() if ($want -ne $got) { throw 'Checksum không khớp — file tải về có thể bị hỏng' } Write-Host ' Đã kiểm tra checksum SHA-256' New-Item -ItemType Directory -Force -Path $dir | Out-Null Move-Item -Force $download $exe } finally { if (Test-Path -LiteralPath $temporary) { Remove-Item -LiteralPath $temporary -Recurse -Force } } Unblock-File $exe -ErrorAction SilentlyContinue $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (($userPath -split ';') -notcontains $dir) { [Environment]::SetEnvironmentVariable('Path', "$userPath;$dir", 'User') $env:Path = "$env:Path;$dir" Write-Host " Đã thêm $dir vào PATH (mở cửa sổ mới để dùng)" } Write-Host " Đã cài: $exe" -ForegroundColor Green Write-Host ' Tự tải bản tương thích; áp dụng ở lần chạy tiếp theo. Tắt bằng PROXVN_AUTO_UPDATE=false.' Write-Host '' Write-Host ' Bắt đầu:' Write-Host ' proxvn # hướng dẫn từng bước' Write-Host ' proxvn http 3000 # web -> https://xxx.proxvn.io.vn' Write-Host ' proxvn tcp 3389 # Remote Desktop' Write-Host '' Write-Host " Tài liệu: $base/docs/"