Skip to content

Commit 7ec2a24

Browse files
Jean Avilaclaude
andcommitted
fix(launcher-ps1): adiciona /shutdown e /rede-dashboard.js ao backend elevado
O projeto tem dois servidores para a porta 7777 -- o Node (v10/launcher.js) e este, em PowerShell, usado quando o app sobe elevado. As duas rotas existiam so no Node, entao ativar pelo caminho elevado quebrava exatamente as duas entregas recentes: o painel de Diagnostico de Rede nunca carregava o script e o botao Parar respondia 404. /shutdown usa a mesma autorizacao do /run (Test-PrivilegedClient) e responde antes de parar o listener, para o cliente receber a confirmacao. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 8e4ad03 commit 7ec2a24

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

MestreDoPC-Launcher.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,21 @@ try {
336336
continue
337337
}
338338

339+
# GET /rede-dashboard.js — o painel de Diagnostico de Rede. Sem esta rota o
340+
# backend elevado servia o index.html mas nao o script, e o painel nunca
341+
# aparecia quando o app rodava como Administrador.
342+
if ($req.HttpMethod -eq "GET" -and $req.Url.AbsolutePath -eq "/rede-dashboard.js") {
343+
$redePath = [System.IO.Path]::GetFullPath((Join-Path $V10_HTML "..\rede-dashboard.js"))
344+
if (Test-Path $redePath) {
345+
$res.Headers["Cache-Control"] = "no-store"
346+
Write-FileResponse -Response $res -Path $redePath -ContentType "application/javascript; charset=utf-8"
347+
} else {
348+
$res.StatusCode = 404
349+
$res.Close()
350+
}
351+
continue
352+
}
353+
339354
if ($req.HttpMethod -eq "GET" -and $req.Url.AbsolutePath -eq "/favicon.png") {
340355
$res.Headers["Cache-Control"] = "public, max-age=604800, immutable"
341356
Write-FileResponse -Response $res -Path (Join-Path $PROJECT_DIR "favicon.png") -ContentType "image/png"
@@ -392,6 +407,20 @@ try {
392407
continue
393408
}
394409

410+
# POST /shutdown — encerra o launcher pelo botao "Parar" da interface.
411+
# Mesma autorizacao do /run (Test-PrivilegedClient). Responde antes de sair
412+
# para o cliente receber a confirmacao; o $listener.Stop() encerra o loop.
413+
if ($req.HttpMethod -eq "POST" -and $req.Url.AbsolutePath -eq "/shutdown") {
414+
if (-not (Test-PrivilegedClient -Request $req)) {
415+
Write-JsonResponse -Response $res -Payload @{ success = $false; output = "Cliente nao autorizado." } -StatusCode 403
416+
continue
417+
}
418+
Write-JsonResponse -Response $res -Payload @{ success = $true; output = "Launcher encerrando."; pid = $PID }
419+
Write-Host "Encerrando launcher por solicitacao da interface."
420+
try { $listener.Stop() } catch {}
421+
break
422+
}
423+
395424
# POST /open-terminal — abre um terminal no mesmo contexto elevado do launcher
396425
if ($req.HttpMethod -eq "POST" -and $req.Url.AbsolutePath -eq "/open-terminal") {
397426
if (-not (Test-PrivilegedClient -Request $req)) {

0 commit comments

Comments
 (0)