mirror of
https://github.com/andrey271192/ssh-manage.git
synced 2026-09-20 11:55:37 +00:00
fix: Windows download — TLS12 + WebClient fallback
Invoke-WebRequest fails without TLS12 on some Windows. Use System.Net.WebClient with explicit TLS12 and User-Agent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,9 @@ New-Item -ItemType Directory -Path $localDir | Out-Null
|
|||||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
if (-not $scriptDir) { $scriptDir = Get-Location }
|
if (-not $scriptDir) { $scriptDir = Get-Location }
|
||||||
|
|
||||||
|
# Ensure TLS 1.2 for GitHub downloads
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
$filesToGet = @("ssh_manager.py", "gen_icon.py")
|
$filesToGet = @("ssh_manager.py", "gen_icon.py")
|
||||||
foreach ($f in $filesToGet) {
|
foreach ($f in $filesToGet) {
|
||||||
$localFile = Join-Path $scriptDir $f
|
$localFile = Join-Path $scriptDir $f
|
||||||
@@ -84,10 +87,20 @@ foreach ($f in $filesToGet) {
|
|||||||
} else {
|
} else {
|
||||||
Write-Host "[*] Downloading $f from GitHub..." -ForegroundColor Yellow
|
Write-Host "[*] Downloading $f from GitHub..." -ForegroundColor Yellow
|
||||||
try {
|
try {
|
||||||
Invoke-WebRequest -Uri "$REPO_RAW/$f" -OutFile $destFile -UseBasicParsing
|
$url = "$REPO_RAW/$f"
|
||||||
Write-Host "[OK] $f (downloaded)" -ForegroundColor Green
|
Write-Host " URL: $url" -ForegroundColor DarkGray
|
||||||
|
$wc = New-Object System.Net.WebClient
|
||||||
|
$wc.Headers.Add("User-Agent", "PCA-SSH-Installer")
|
||||||
|
$wc.DownloadFile($url, $destFile)
|
||||||
|
if (Test-Path $destFile) {
|
||||||
|
$sz = (Get-Item $destFile).Length
|
||||||
|
Write-Host "[OK] $f ($sz bytes)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
throw "File not saved"
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "[FAIL] Cannot download $f" -ForegroundColor Red
|
Write-Host "[FAIL] Cannot download $f : $_" -ForegroundColor Red
|
||||||
|
Write-Host "Try manual download: https://github.com/andrey271192/ssh-manage" -ForegroundColor Yellow
|
||||||
Read-Host "Press Enter"
|
Read-Host "Press Enter"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
СПОСОБ 1 — Одна команда (рекомендуется)
|
СПОСОБ 1 — Одна команда (рекомендуется)
|
||||||
Скопируй и вставь в PowerShell:
|
Скопируй и вставь в PowerShell:
|
||||||
|
|
||||||
irm https://raw.githubusercontent.com/andrey271192/ssh-manage/main/full_install.ps1 -OutFile $env:TEMP\pca_install.ps1; powershell -ExecutionPolicy Bypass -File $env:TEMP\pca_install.ps1
|
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $wc=New-Object Net.WebClient; $wc.Headers.Add('User-Agent','PCA'); $wc.DownloadFile('https://raw.githubusercontent.com/andrey271192/ssh-manage/main/full_install.ps1',"$env:TEMP\pca_install.ps1"); powershell -ExecutionPolicy Bypass -File $env:TEMP\pca_install.ps1
|
||||||
|
|
||||||
Что произойдёт:
|
Что произойдёт:
|
||||||
- Скачает установщик с GitHub
|
- Скачает установщик с GitHub
|
||||||
|
|||||||
Reference in New Issue
Block a user