proxy-pilot 0.7.0

Core-agnostic proxy health monitor, automatic failover daemon, and multi-channel alerting tool for Linux servers.
Documentation
$ErrorActionPreference = "Stop"

$Repo = "amirhosein2004/proxy-pilot"
$Version = if ($env:PROXY_PILOT_VERSION) { $env:PROXY_PILOT_VERSION } else { "latest" }
$AssetName = "proxy-pilot-windows-amd64.exe"
$BinDir = Join-Path $env:LOCALAPPDATA "proxy-pilot\bin"
$BinPath = Join-Path $BinDir "proxy-pilot.exe"
$ConfigDir = Join-Path $env:APPDATA "proxy-pilot"
$ConfigPath = Join-Path $ConfigDir "config.yaml"

$BaseUrl = if ($Version -eq "latest") {
    "https://github.com/$Repo/releases/latest/download"
} else {
    "https://github.com/$Repo/releases/download/$Version"
}

$TmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ("proxy-pilot-" + [System.Guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $TmpDir -Force | Out-Null

try {
    $BinTmp = Join-Path $TmpDir $AssetName
    $ShaTmp = Join-Path $TmpDir "$AssetName.sha256"

    Write-Host "==> Downloading $AssetName ($Version)..."
    Invoke-WebRequest -Uri "$BaseUrl/$AssetName" -OutFile $BinTmp
    Invoke-WebRequest -Uri "$BaseUrl/$AssetName.sha256" -OutFile $ShaTmp

    Write-Host "==> Verifying SHA-256 checksum..."
    $ExpectedHash = (Get-Content $ShaTmp -Raw).Trim().Split()[0].ToLower()
    $ActualHash = (Get-FileHash $BinTmp -Algorithm SHA256).Hash.ToLower()
    if ($ActualHash -ne $ExpectedHash) {
        throw "SHA-256 mismatch! Expected $ExpectedHash, got $ActualHash"
    }

    New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
    Copy-Item $BinTmp $BinPath -Force

    $UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
    if ($UserPath -notlike "*$BinDir*") {
        $NewPath = if ($UserPath) { "$UserPath;$BinDir" } else { $BinDir }
        [Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
        $env:Path = "$env:Path;$BinDir"
        Write-Host "==> Added $BinDir to user PATH."
    }

    New-Item -ItemType Directory -Path $ConfigDir -Force | Out-Null
    if (-not (Test-Path $ConfigPath)) {
        Write-Host "==> Creating default config at $ConfigPath..."
        Invoke-WebRequest -Uri "https://raw.githubusercontent.com/$Repo/main/config.example.yaml" -OutFile $ConfigPath
    } else {
        Write-Host "==> Existing $ConfigPath preserved."
    }

    Write-Host ""
    $InstalledVersion = & $BinPath --version
    Write-Host "proxy-pilot installed successfully ($InstalledVersion) at $BinPath!"
    Write-Host "Next steps:"
    Write-Host "  1. Import your vless:// links:  proxy-pilot import --config `"$ConfigPath`""
    Write-Host "  2. Run the daemon:              proxy-pilot run --config `"$ConfigPath`""
} finally {
    Remove-Item -Path $TmpDir -Recurse -Force -ErrorAction SilentlyContinue
}