fix: Windows client config fails if backend not installed (#3)

Add directory existence checks in New-PaqetConfig and New-GfkConfig
before writing config files. Shows friendly error message instead of
"Could not find a part of the path" exception.

Reported-by: @SamDevApi
This commit is contained in:
SamNet-dev
2026-02-04 15:07:56 -06:00
parent 8f634a5de0
commit ff6acb9cfb

View File

@@ -386,6 +386,12 @@ transport:
key: "$SecretKey"
"@
# Ensure install directory exists
if (-not (Test-Path $InstallDir)) {
Write-Err "Paqet is not installed. Please install paqet first (option 1)."
return $false
}
[System.IO.File]::WriteAllText($ConfigFile, $config)
Save-Settings -Backend "paqet" -ServerAddr $Server
Write-Success "Configuration saved"
@@ -558,6 +564,12 @@ quic_private_key = "key.pem"
socks_port = $SocksPort
"@
# Ensure GFK directory exists
if (-not (Test-Path $GfkDir)) {
Write-Err "GFK is not installed. Please install GFK first (option 2)."
return $false
}
[System.IO.File]::WriteAllText("$GfkDir\parameters.py", $params)
Save-Settings -Backend "gfk" -ServerAddr $ServerIP -SocksPort $SocksPort
Write-Success "GFK configuration saved"
@@ -922,10 +934,11 @@ function Show-Menu {
$server = Read-Host " Server address (e.g., 1.2.3.4:8443)"
$key = Read-Host " Encryption key (16+ chars)"
if ($server -and $key) {
New-PaqetConfig -Server $server -SecretKey $key
if (New-PaqetConfig -Server $server -SecretKey $key) {
Write-Host ""
Write-Host " Your SOCKS5 proxy: 127.0.0.1:1080" -ForegroundColor Green
}
}
} else {
Write-Host ""
Write-Host " GFK CONFIGURATION" -ForegroundColor Yellow
@@ -934,12 +947,13 @@ function Show-Menu {
$server = Read-Host " Server IP (e.g., 1.2.3.4)"
$auth = Read-Host " Auth code (from server setup)"
if ($server -and $auth) {
New-GfkConfig -ServerIP $server -AuthCode $auth -SocksPort "14000"
if (New-GfkConfig -ServerIP $server -AuthCode $auth -SocksPort "14000") {
Write-Host ""
Write-Host " Your SOCKS5 proxy: 127.0.0.1:14000" -ForegroundColor Green
}
}
}
}
"4" {
if (-not $backend) {
Write-Warn "Install a backend first"