feat: Добавлена установка и управление sing-box, настройка Discord и общие системные утилиты для задач и брандмауэра.

This commit is contained in:
2025-12-29 13:52:31 +03:00
parent f04d04fa61
commit 2b60df6f7f
7 changed files with 370 additions and 113 deletions

View File

@@ -2,6 +2,25 @@
# 🛠️ COMMON UTILS
# ==========================================
# --- ГЛОБАЛЬНЫЕ НАСТРОЙКИ ---
# Режим отладки (передаётся через -Debug)
if (-not (Test-Path variable:script:DebugMode)) {
$script:DebugMode = $false
}
function Set-DebugMode {
param([bool]$Enabled)
$script:DebugMode = $Enabled
if ($Enabled) {
Write-Host " 🔧 Debug режим включён" -ForegroundColor Magenta
}
}
function Get-DebugMode {
return $script:DebugMode
}
# --- ЦВЕТА И ВЫВОД ---
function Write-Step { param($msg) Write-Host "`n📦 $msg" -ForegroundColor Cyan }
@@ -10,8 +29,20 @@ function Write-Warning { param($msg) Write-Host " ⚠️ $msg" -ForegroundColo
function Write-Error { param($msg) Write-Host "$msg" -ForegroundColor Red }
function Write-Info { param($msg) Write-Host " $msg" -ForegroundColor Gray }
function Write-DebugLog {
param($msg)
if ($script:DebugMode) {
Write-Host " [DEBUG] $msg" -ForegroundColor DarkGray
}
}
function Write-Header {
param($Title)
param($Title, [switch]$ClearScreen)
if ($ClearScreen -and -not $script:DebugMode) {
Clear-Host
}
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " $Title" -ForegroundColor Cyan
@@ -19,6 +50,36 @@ function Write-Header {
Write-Host ""
}
# --- ЗАПУСК КОМАНД ---
function Invoke-Silent {
param(
[string]$FilePath,
[string]$Arguments,
[switch]$Wait
)
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = $FilePath
$psi.Arguments = $Arguments
$psi.UseShellExecute = $false
$psi.CreateNoWindow = $true
if (-not $script:DebugMode) {
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
}
$process = [System.Diagnostics.Process]::Start($psi)
if ($Wait) {
$process.WaitForExit()
return $process.ExitCode
}
return $process
}
# --- ПОЛЕЗНЫЕ ФУНКЦИИ ---
function Get-ScriptDirectory {
@@ -55,5 +116,3 @@ function Show-Menu {
return Read-Host "$Prompt"
}

View File

@@ -4,24 +4,6 @@
# --- СИСТЕМНАЯ ИНФОРМАЦИЯ ---
function Get-HWID {
param([string]$StoreDir)
$hwidFile = "$StoreDir\hwid"
if (Test-Path $hwidFile) {
return (Get-Content $hwidFile -Raw).Trim()
}
$hwid = [System.Guid]::NewGuid().ToString("N").Substring(0, 16)
if (!(Test-Path $StoreDir)) {
New-Item -ItemType Directory -Path $StoreDir -Force | Out-Null
}
Set-Content -Path $hwidFile -Value $hwid
return $hwid
}
function Get-SystemInfo {
return @{
os = "windows"

View File

@@ -2,74 +2,94 @@
# 🎮 DISCORD PROXY SETUP
# ==========================================
param([switch]$Force)
param(
[switch]$Force,
[switch]$Debug
)
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$ScriptDir\lib\Common.ps1"
. "$ScriptDir\lib\Net.ps1"
. "$ScriptDir\lib\System.ps1"
Write-Header "НАСТРОЙКА DISCORD / VESKTOP"
if ($Debug) { Set-DebugMode -Enabled $true }
Write-Header "НАСТРОЙКА DISCORD / VESKTOP" -ClearScreen
Ensure-Admin
$InstallPath = "C:\Tools\ProxiFyre"
$ConfigPath = "$InstallPath\app-config.json"
$DriverUrl = "https://github.com/wiresock/ndisapi/releases/download/v3.6.2/Windows.Packet.Filter.3.6.2.1.x64.msi"
$AppUrl = "https://github.com/wiresock/proxifyre/releases/download/v2.1.4/ProxiFyre-v2.1.4-x64-signed.zip"
# Проверка Sing-box
$singboxStatus = Get-TaskStatus -Name "SingBoxProxy"
$localProxy = "127.0.0.1:1080"
$useLocal = $false
# --- ФУНКЦИИ ---
if ($singboxStatus -eq "Running") {
Write-Info "Обнаружен работающий Native Sing-box."
$useLocal = $true
}
else {
Write-Warning "Native Sing-box не запущен!"
Write-Host " Для работы голосовых звонков он необходим." -ForegroundColor Gray
Write-Host " Вы можете вернуться в главное меню и настроить его." -ForegroundColor Gray
if ((Read-Host " Продолжить настройку БЕЗ него (голос может не работать)? (y/n)") -ne 'y') { exit }
function Test-ProxyConnection {
param([string]$ProxyAddr)
Write-Info "Проверка подключения к прокси $ProxyAddr..."
try {
$parts = $ProxyAddr -split ":"
$host_ = $parts[0]
$port = [int]$parts[1]
# 1. Проверяем TCP соединение
$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.Connect($host_, $port)
$tcp.Close()
Write-Success "TCP соединение установлено"
# 2. Пробуем получить внешний IP через прокси (используем curl для SOCKS5)
try {
$result = & curl.exe -s -x "socks5://$ProxyAddr" "http://v4.ident.me" --connect-timeout 5 2>$null
if ($result -match "^\d+\.\d+\.\d+\.\d+$") {
Write-Success "Внешний IP через прокси: $result"
return $true
}
}
catch {}
Write-Warning "TCP работает, но не удалось получить IP. Возможно прокси не полностью настроен."
return $true
}
catch {
Write-Error "Не удалось подключиться к $ProxyAddr"
Write-Host " Убедитесь, что прокси запущен и доступен." -ForegroundColor Gray
return $false
}
}
# Меню выбора приложений
Write-Host "`n🎮 Какие приложения проксировать?" -ForegroundColor Yellow
$appOpts = [Ordered]@{
"1" = "Discord"
"2" = "Vesktop"
"3" = "Discord + Vesktop"
}
$appChoice = Show-Menu -Options $appOpts
$targetApps = switch ($appChoice) {
"1" { @("Discord") }
"2" { @("Vesktop") }
"3" { @("Vesktop", "Discord") }
default { @("Discord") }
function Get-CurrentConfig {
if (Test-Path $ConfigPath) {
try {
$cfg = Get-Content $ConfigPath -Raw | ConvertFrom-Json
return @{
Apps = $cfg.proxies[0].appNames -join ", "
Proxy = $cfg.proxies[0].socks5ProxyEndpoint
}
}
catch {}
}
return $null
}
$proxyAddr = $localProxy
if (!$useLocal) {
$proxyAddr = Read-Host "Введите адрес прокси (хост:порт) [Enter для $localProxy]"
if ([string]::IsNullOrWhiteSpace($proxyAddr)) { $proxyAddr = $localProxy }
}
function Install-ProxiFyre {
# Установка драйвера
Write-Step "Установка драйвера..."
$msi = "$env:TEMP\WinpkFilter.msi"
if (Download-File -Url $DriverUrl -Destination $msi) {
Start-Process msiexec.exe -ArgumentList "/i `"$msi`" /qn /norestart" -Wait
Write-Success "Драйвер готов"
}
# Установка драйвера
Write-Step "Установка драйвера..."
$msi = "$env:TEMP\WinpkFilter.msi"
if (Download-File -Url $DriverUrl -Destination $msi) {
Start-Process msiexec.exe -ArgumentList "/i `"$msi`" /qn /norestart" -Wait
Write-Success "Драйвер готов"
}
# Установка ProxiFyre
Write-Step "Установка ProxiFyre..."
if (!(Test-Path $InstallPath) -or $Force) {
# Установка ProxiFyre
Write-Step "Установка ProxiFyre..."
New-Item -ItemType Directory -Path $InstallPath -Force | Out-Null
$zip = "$env:TEMP\ProxiFyre.zip"
if (Download-File -Url $AppUrl -Destination $zip) {
Expand-Archive -Path $zip -DestinationPath $InstallPath -Force
# Handle update folder structure if needed, simplified here assuming flat or check generic
$exe = Get-ChildItem $InstallPath -Recurse -Filter "ProxiFyre.exe" | Select -First 1
if ($exe.DirectoryName -ne $InstallPath) {
Copy-Item "$($exe.DirectoryName)\*" $InstallPath -Recurse -Force
@@ -78,23 +98,177 @@ if (!(Test-Path $InstallPath) -or $Force) {
}
}
# Конфиг
$cfg = @{
logLevel = "Info"
proxies = @(@{
appNames = $targetApps
socks5ProxyEndpoint = $proxyAddr
supportedProtocols = @("TCP", "UDP")
})
excludes = @()
function Configure-And-Start {
param($TargetApps, $ProxyAddr)
# Конфиг
$cfg = @{
logLevel = "Info"
proxies = @(@{
appNames = $TargetApps
socks5ProxyEndpoint = $ProxyAddr
supportedProtocols = @("TCP", "UDP")
})
excludes = @()
}
$cfg | ConvertTo-Json -Depth 5 | Set-Content $ConfigPath -Encoding UTF8
# Служба
Write-Step "Перезапуск службы..."
if (Get-DebugMode) {
& "$InstallPath\ProxiFyre.exe" stop
& "$InstallPath\ProxiFyre.exe" install
& "$InstallPath\ProxiFyre.exe" start
}
else {
& "$InstallPath\ProxiFyre.exe" stop 2>&1 | Out-Null
& "$InstallPath\ProxiFyre.exe" install 2>&1 | Out-Null
& "$InstallPath\ProxiFyre.exe" start 2>&1 | Out-Null
}
Write-Success "Готово! Discord должен работать через прокси."
}
$cfg | ConvertTo-Json -Depth 5 | Set-Content "$InstallPath\app-config.json" -Encoding UTF8
# Служба
Write-Step "Перезапуск службы..."
Start-Process "$InstallPath\ProxiFyre.exe" -ArgumentList "stop" -Wait -NoNewWindow
Start-Process "$InstallPath\ProxiFyre.exe" -ArgumentList "install" -Wait -NoNewWindow
Start-Process "$InstallPath\ProxiFyre.exe" -ArgumentList "start" -Wait -NoNewWindow
function Select-Apps {
Write-Host "`n🎮 Какие приложения проксировать?" -ForegroundColor Yellow
$appOpts = [Ordered]@{
"1" = "Discord"
"2" = "Vesktop"
"3" = "Discord + Vesktop"
}
$appChoice = Show-Menu -Options $appOpts
$result = switch ($appChoice) {
"1" { @("Discord") }
"2" { @("Vesktop") }
"3" { @("Vesktop", "Discord") }
default { @("Discord") }
}
return $result
}
Write-Success "Готово! Discord должен работать через прокси."
function Get-ProxyAddress {
# Проверяем локальный sing-box
$singboxStatus = Get-TaskStatus -Name "SingBoxProxy"
$localProxy = "127.0.0.1:1080"
if ($singboxStatus -eq "Running") {
Write-Info "Обнаружен работающий VPN клиент (Sing-box)."
Write-Host " Рекомендуется использовать локальный прокси: " -NoNewline -ForegroundColor Gray
Write-Host $localProxy -ForegroundColor Green
$useLocal = Read-Host " Использовать локальный? (y/n) [y]"
if ($useLocal -ne 'n') {
return $localProxy
}
}
else {
Write-Warning "VPN клиент не запущен!"
Write-Host " Вы можете указать адрес удалённого прокси." -ForegroundColor Gray
}
# Запрашиваем адрес
while ($true) {
$proxyAddr = Read-Host "`n Введите адрес прокси (IP:порт)"
if ([string]::IsNullOrWhiteSpace($proxyAddr)) {
Write-Warning "Адрес не указан"
continue
}
if ($proxyAddr -notmatch "^[\d\.]+:\d+$") {
Write-Error "Неверный формат. Ожидается: IP:порт (например 192.168.1.100:1080)"
continue
}
# Проверяем подключение
if (Test-ProxyConnection -ProxyAddr $proxyAddr) {
return $proxyAddr
}
$retry = Read-Host " Попробовать другой адрес? (y/n)"
if ($retry -ne 'y') { return $null }
}
}
# --- MAIN ---
$isInstalled = Test-Path "$InstallPath\ProxiFyre.exe"
$discSvc = Get-Service -Name "ProxiFyreService" -ErrorAction SilentlyContinue
$currentConfig = Get-CurrentConfig
if ($isInstalled -and $currentConfig -and -not $Force) {
# Уже установлено — показываем меню управления
Write-Info "ProxiFyre уже установлен."
Write-Host ""
Write-Host " Статус: " -NoNewline -ForegroundColor Gray
if ($discSvc.Status -eq 'Running') {
Write-Host "АКТИВЕН" -ForegroundColor Green
}
else {
Write-Host "ОСТАНОВЛЕН" -ForegroundColor Yellow
}
Write-Host " Приложения: $($currentConfig.Apps)" -ForegroundColor Gray
Write-Host " Прокси: $($currentConfig.Proxy)" -ForegroundColor Gray
Write-Host ""
$opts = [Ordered]@{
"1" = "Изменить настройки (приложения/прокси)"
"2" = "Проверить подключение к прокси"
"3" = "Перезапустить службу"
"4" = "Остановить службу"
"5" = "Переустановить"
"b" = "Назад"
}
$action = Show-Menu -Options $opts
switch ($action) {
"1" {
$targetApps = Select-Apps
$proxyAddr = Get-ProxyAddress
if ($proxyAddr) {
Configure-And-Start -TargetApps $targetApps -ProxyAddr $proxyAddr
}
}
"2" {
Test-ProxyConnection -ProxyAddr $currentConfig.Proxy | Out-Null
}
"3" {
Write-Step "Перезапуск службы..."
Start-Process "$InstallPath\ProxiFyre.exe" -ArgumentList "stop" -Wait -NoNewWindow
Start-Process "$InstallPath\ProxiFyre.exe" -ArgumentList "start" -Wait -NoNewWindow
Write-Success "Перезапущено!"
}
"4" {
Start-Process "$InstallPath\ProxiFyre.exe" -ArgumentList "stop" -Wait -NoNewWindow
Write-Success "Остановлено!"
}
"5" {
$Force = $true
}
"b" { exit }
}
if (-not $Force) {
Start-Sleep -Seconds 2
exit
}
}
# --- НОВАЯ УСТАНОВКА ---
if (-not $isInstalled -or $Force) {
Install-ProxiFyre
}
$targetApps = Select-Apps
$proxyAddr = Get-ProxyAddress
if (-not $proxyAddr) {
Write-Error "Прокси не настроен. Выход."
Start-Sleep -Seconds 2
exit
}
Configure-And-Start -TargetApps $targetApps -ProxyAddr $proxyAddr
Start-Sleep -Seconds 3

View File

@@ -4,6 +4,7 @@
param(
[switch]$Force,
[switch]$Debug,
[string]$SubscriptionUrl = ""
)
@@ -158,7 +159,9 @@ function Parse-VlessUrl {
# --- MAIN ---
Write-Header "NATIVE SING-BOX (UDP ПОДДЕРЖКА)"
if ($Debug) { Set-DebugMode -Enabled $true }
Write-Header "NATIVE SING-BOX (UDP ПОДДЕРЖКА)" -ClearScreen
$taskStatus = Get-TaskStatus -Name $TaskName

View File

@@ -2,11 +2,15 @@
# 🗑️ UNINSTALL ALL (CLEANUP)
# ==========================================
param([switch]$Debug)
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$ScriptDir\lib\Common.ps1"
. "$ScriptDir\lib\System.ps1"
Write-Header "ПОЛНОЕ УДАЛЕНИЕ"
if ($Debug) { Set-DebugMode -Enabled $true }
Write-Header "ПОЛНОЕ УДАЛЕНИЕ" -ClearScreen
Ensure-Admin
@@ -27,11 +31,17 @@ if (Test-Path "C:\Tools\sing-box") {
Write-Success "Файлы удалены"
}
Write-Step "Удаление Discrod Proxy (ProxiFyre)..."
Write-Step "Удаление Discord Proxy (ProxiFyre)..."
$pfDir = "C:\Tools\ProxiFyre"
if (Test-Path "$pfDir\ProxiFyre.exe") {
Start-Process "$pfDir\ProxiFyre.exe" -ArgumentList "uninstall" -Wait -NoNewWindow
if (Get-DebugMode) {
& "$pfDir\ProxiFyre.exe" uninstall
}
else {
& "$pfDir\ProxiFyre.exe" uninstall 2>&1 | Out-Null
}
Start-Sleep -Seconds 2
Write-Success "Служба удалена"
}
if (Test-Path $pfDir) {