From d7a3b20da909fe3b7ece4024a653886788b1cb5e Mon Sep 17 00:00:00 2001 From: Dokril Date: Tue, 30 Dec 2025 21:08:02 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D1=8B?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=20=D1=81=D0=B5=D1=82=D1=8C=D1=8E,=20=D1=81=D0=B8=D1=81?= =?UTF-8?q?=D1=82=D0=B5=D0=BC=D0=BD=D1=8B=D0=BC=D0=B8=20=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D1=82=D0=B0=D0=BC=D0=B8=20=D0=B8=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8=20Discord.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/lib/Net.ps1 | 4 +++ scripts/lib/System.ps1 | 37 ++++++++++++++++++++++++++ scripts/setup-discord.ps1 | 56 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/scripts/lib/Net.ps1 b/scripts/lib/Net.ps1 index 1a0922f..74ca1a0 100644 --- a/scripts/lib/Net.ps1 +++ b/scripts/lib/Net.ps1 @@ -72,6 +72,9 @@ function Download-File { $stream.Close() $resp.Close() + # Unblock file to prevent "Mark of the Web" issues + Unblock-File -Path $Destination -ErrorAction SilentlyContinue + return $true } catch { @@ -80,6 +83,7 @@ function Download-File { } } + function Get-SubscriptionData { param( [string]$Url, diff --git a/scripts/lib/System.ps1 b/scripts/lib/System.ps1 index 217713e..58c8795 100644 --- a/scripts/lib/System.ps1 +++ b/scripts/lib/System.ps1 @@ -2,6 +2,7 @@ # 🖥️ SYSTEM UTILS # ========================================== + # --- СИСТЕМНАЯ ИНФОРМАЦИЯ --- function Get-SystemInfo { @@ -11,6 +12,42 @@ function Get-SystemInfo { } } +function Ensure-VCRedist { + Write-Info "Проверка Visual C++ Redistributable..." + + # Check registry for VC++ 2015-2022 (x64) + # Key: HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64 + $regPath = "HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" + if (Test-Path $regPath) { + $installed = (Get-ItemProperty -Path $regPath).Installed + if ($installed -eq 1) { + Write-Success "Visual C++ Redistributable уже установлен." + return + } + } + + Write-Warning "Visual C++ Redistributable не найден. Устанавливаю..." + + $vcUrl = "https://aka.ms/vs/17/release/vc_redist.x64.exe" + $vcFile = "$env:TEMP\vc_redist.x64.exe" + + if (Download-File -Url $vcUrl -Destination $vcFile) { + Write-Step "Установка библиотек Visual C++..." + $process = Start-Process -FilePath $vcFile -ArgumentList "/install", "/quiet", "/norestart" -PassThru -Wait + + if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 3010) { + # 3010 = reboot required (usually works without immediate reboot) + Write-Success "Библиотеки установлены!" + } + else { + Write-Error "Ошибка установки VC++ (Код: $($process.ExitCode))" + Write-Host " Попробуйте установить вручную: https://aka.ms/vs/17/release/vc_redist.x64.exe" + } + + Remove-Item $vcFile -Force -ErrorAction SilentlyContinue + } +} + # --- DOCKER --- function Test-Docker { diff --git a/scripts/setup-discord.ps1 b/scripts/setup-discord.ps1 index 4f5918c..d1db638 100644 --- a/scripts/setup-discord.ps1 +++ b/scripts/setup-discord.ps1 @@ -76,6 +76,12 @@ function Get-CurrentConfig { } function Install-ProxiFyre { + # 0. Остановка старых процессов (чтобы файлы не были заблокированы) + Write-Step "Остановка старых процессов..." + Stop-Service "ProxiFyreService" -Force -ErrorAction SilentlyContinue + Stop-Process -Name "ProxiFyre" -Force -ErrorAction SilentlyContinue + Start-Sleep -Seconds 2 + # Установка драйвера Write-Step "Установка драйвера..." $msi = "$env:TEMP\WinpkFilter.msi" @@ -126,7 +132,54 @@ function Configure-And-Start { & "$InstallPath\ProxiFyre.exe" start 2>&1 | Out-Null } - Write-Success "Готово! Discord должен работать через прокси." + # Мониторинг запуска (10 сек) + Write-Info "Проверка стабильности запуска (10 сек)..." + $lastLogSize = 0 + $logFile = $null + + for ($i = 1; $i -le 10; $i++) { + Start-Sleep -Seconds 1 + + # 1. Ищем файл логов (если еще не нашли) + if (-not $logFile) { + $logFile = Get-ChildItem "$InstallPath\*.log" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1 + } + + # 2. Выводим новые строки лога + if ($logFile) { + try { + $stream = [System.IO.File]::Open($logFile.FullName, 'Open', 'Read', 'ReadWrite') + if ($stream.Length -gt $lastLogSize) { + $stream.Seek($lastLogSize, 'Begin') | Out-Null + $reader = New-Object System.IO.StreamReader($stream) + $content = $reader.ReadToEnd() + $newPos = $stream.Position # Сохраняем позицию + $reader.Dispose() # Закрывает поток + $lastLogSize = $newPos + + if (-not [string]::IsNullOrWhiteSpace($content)) { + $content -split "`r`n" | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ForEach-Object { + Write-Host " LOG: $_" -ForegroundColor DarkGray + } + } + } + else { + $stream.Dispose() + } + } + catch {} + } + + # 3. Проверяем статус службы + $svc = Get-Service -Name "ProxiFyreService" -ErrorAction SilentlyContinue + if ($svc.Status -ne 'Running') { + Write-Error "Служба упала при запуске! (Код 1064 или другая ошибка)" + Write-Host " Попробуйте запустить вручную для диагностики." -ForegroundColor Gray + return + } + } + + Write-Success "Готово! Служба стабильна." } function Select-Apps { @@ -258,6 +311,7 @@ if ($isInstalled -and $currentConfig -and -not $Force) { # --- НОВАЯ УСТАНОВКА --- if (-not $isInstalled -or $Force) { + Ensure-VCRedist Install-ProxiFyre }