feat: Добавлены скрипты для установки Sing-box и Discord, а также для просмотра логов.

This commit is contained in:
2025-12-31 12:26:17 +03:00
parent e1f71f95ad
commit 479a7232b1
4 changed files with 193 additions and 6 deletions

View File

@@ -107,11 +107,12 @@ function Install-ProxiFyre {
function Configure-And-Start {
param($TargetApps, $ProxyAddr)
# Конфиг
# Конфиг (гарантируем, что appNames - массив)
$appNamesArray = @($TargetApps)
$cfg = @{
logLevel = "Info"
proxies = @(@{
appNames = $TargetApps
appNames = $appNamesArray
socks5ProxyEndpoint = $ProxyAddr
supportedProtocols = @("TCP", "UDP")
})
@@ -182,12 +183,74 @@ function Configure-And-Start {
Write-Success "Готово! Служба стабильна."
}
function Get-AppPath {
Write-Host "`n📁 Укажите путь до папки с приложением" -ForegroundColor Yellow
Write-Host " (Будут проксированы все .exe из этой папки)" -ForegroundColor Gray
# Стандартные пути установки Discord-клиентов
$defaultPaths = @{
"Discord" = "$env:LOCALAPPDATA\Discord"
"Discord PTB" = "$env:LOCALAPPDATA\DiscordPTB"
"Discord Canary" = "$env:LOCALAPPDATA\DiscordCanary"
"Vesktop" = "$env:LOCALAPPDATA\vesktop"
"Lightcord" = "$env:LOCALAPPDATA\Lightcord"
}
$suggestions = @()
foreach ($app in $defaultPaths.Keys) {
if (Test-Path $defaultPaths[$app]) {
$suggestions += @{ Name = $app; Path = $defaultPaths[$app] }
}
}
if ($suggestions.Count -gt 0) {
Write-Host "`n Найденные приложения:" -ForegroundColor Cyan
for ($i = 0; $i -lt $suggestions.Count; $i++) {
Write-Host " [$($i+1)] $($suggestions[$i].Name): $($suggestions[$i].Path)" -ForegroundColor Gray
}
Write-Host " [c] Указать свой путь" -ForegroundColor Gray
$choice = Read-Host "`n Выберите"
if ($choice -match "^\d+$" -and [int]$choice -ge 1 -and [int]$choice -le $suggestions.Count) {
return @($suggestions[[int]$choice - 1].Path)
}
}
# Ручной ввод пути
while ($true) {
$path = Read-Host " Путь до папки"
if ([string]::IsNullOrWhiteSpace($path)) {
Write-Warning "Путь не указан"
continue
}
if (Test-Path $path) {
$exeCount = (Get-ChildItem $path -Filter "*.exe" -Recurse -ErrorAction SilentlyContinue).Count
if ($exeCount -gt 0) {
Write-Success "Найдено $exeCount исполняемых файлов"
return @($path)
}
else {
Write-Warning "В папке не найдено .exe файлов"
}
}
else {
Write-Error "Папка не существует: $path"
}
$retry = Read-Host " Попробовать другой путь? (y/n)"
if ($retry -ne 'y') { return $null }
}
}
function Select-Apps {
Write-Host "`n🎮 Какие приложения проксировать?" -ForegroundColor Yellow
$appOpts = [Ordered]@{
"1" = "Discord"
"2" = "Vesktop"
"3" = "Discord + Vesktop"
"1" = "Discord (по имени процесса)"
"2" = "Vesktop (по имени процесса)"
"3" = "Discord + Vesktop (по имени процесса)"
"4" = "Указать путь до папки приложения"
}
$appChoice = Show-Menu -Options $appOpts
@@ -196,6 +259,7 @@ function Select-Apps {
"1" { @("Discord", "Update") }
"2" { @("Vesktop") }
"3" { @("Vesktop", "Discord", "Update") }
"4" { Get-AppPath }
default { @("Discord", "Update") }
}
return $result

View File

@@ -68,7 +68,7 @@ function New-SingboxConfig {
param($Outbound, $Port)
return @{
log = @{ level = "info"; timestamp = $true }
log = @{ level = "info"; timestamp = $true; output = "$InstallDir\singbox.log" }
dns = @{ independent_cache = $true }
inbounds = @(
@{

121
scripts/view-logs.ps1 Normal file
View File

@@ -0,0 +1,121 @@
# ==========================================
# 📜 LOG VIEWER
# ==========================================
# View logs from sing-box and ProxiFyre
param([switch]$Follow)
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$ScriptDir\lib\Common.ps1"
$SingboxLog = "C:\Tools\sing-box\singbox.log"
$ProxiFyreLog = "C:\Tools\ProxiFyre"
function Show-LogFile {
param(
[string]$Path,
[string]$Title,
[int]$Lines = 30,
[string]$Color = "Gray"
)
if (Test-Path $Path) {
Write-Host "`n═══ $Title ═══" -ForegroundColor Cyan
$content = Get-Content $Path -Tail $Lines -ErrorAction SilentlyContinue
if ($content) {
$content | ForEach-Object { Write-Host " $_" -ForegroundColor $Color }
}
else {
Write-Host " (Лог пустой)" -ForegroundColor DarkGray
}
}
else {
Write-Host "`n═══ $Title ═══" -ForegroundColor Cyan
Write-Host " (Файл не найден: $Path)" -ForegroundColor DarkGray
}
}
function Tail-Logs {
Write-Host "`n📜 Режим отслеживания логов (Ctrl+C для выхода)" -ForegroundColor Yellow
Write-Host " sing-box: $SingboxLog" -ForegroundColor DarkGray
Write-Host " ProxiFyre: $ProxiFyreLog\*.log" -ForegroundColor DarkGray
Write-Host ""
$sbPos = 0
$pfPos = 0
$pfLogFile = $null
# Initial positions
if (Test-Path $SingboxLog) { $sbPos = (Get-Item $SingboxLog).Length }
$pfLogFile = Get-ChildItem "$ProxiFyreLog\*.log" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1
if ($pfLogFile) { $pfPos = $pfLogFile.Length }
try {
while ($true) {
Start-Sleep -Milliseconds 500
# Sing-box
if (Test-Path $SingboxLog) {
$newSize = (Get-Item $SingboxLog).Length
if ($newSize -gt $sbPos) {
$content = Get-Content $SingboxLog -Tail 20 -ErrorAction SilentlyContinue
# Show only new lines (approximate)
$content | Select-Object -Last ([math]::Max(1, [math]::Ceiling(($newSize - $sbPos) / 100))) | ForEach-Object {
Write-Host "[SB] $_" -ForegroundColor Green
}
$sbPos = $newSize
}
}
# ProxiFyre
$pfLogFile = Get-ChildItem "$ProxiFyreLog\*.log" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1
if ($pfLogFile) {
$newSize = $pfLogFile.Length
if ($newSize -gt $pfPos) {
$content = Get-Content $pfLogFile.FullName -Tail 20 -ErrorAction SilentlyContinue
$content | Select-Object -Last ([math]::Max(1, [math]::Ceiling(($newSize - $pfPos) / 100))) | ForEach-Object {
Write-Host "[PF] $_" -ForegroundColor Yellow
}
$pfPos = $newSize
}
}
}
}
catch {
Write-Host "`nОстановлено." -ForegroundColor Gray
}
}
# --- MAIN ---
Write-Header "ПРОСМОТР ЛОГОВ" -ClearScreen
$opts = [Ordered]@{
"1" = "Показать последние логи"
"2" = "Следить за логами в реальном времени (tail -f)"
"b" = "Назад"
}
$choice = Show-Menu -Options $opts
switch ($choice) {
"1" {
Show-LogFile -Path $SingboxLog -Title "SING-BOX (VPN)" -Lines 50 -Color "Green"
$pfLog = Get-ChildItem "$ProxiFyreLog\*.log" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime | Select-Object -Last 1
if ($pfLog) {
Show-LogFile -Path $pfLog.FullName -Title "PROXIFYRE (Discord)" -Lines 50 -Color "Yellow"
}
else {
Write-Host "`n═══ PROXIFYRE (Discord) ═══" -ForegroundColor Cyan
Write-Host " (Логов не найдено в $ProxiFyreLog)" -ForegroundColor DarkGray
}
Write-Host ""
Read-Host "Нажмите Enter для выхода"
}
"2" {
Tail-Logs
}
"b" { exit }
}