feat: Добавлена установка и управление sing-box, настройка Discord и общие системные утилиты для задач и брандмауэра.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user