17 lines
1.2 KiB
PowerShell
17 lines
1.2 KiB
PowerShell
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
$project = Split-Path $PSScriptRoot -Parent
|
||
|
|
$exe = [IO.Path]::GetFullPath((Join-Path $project 'dist\MusicBridge-win-x64\app\MusicBridge.Agent.exe'))
|
||
|
|
$script = Join-Path $PSScriptRoot 'Firewall.ps1'
|
||
|
|
$rules = @(& $script -Action Preview -ProgramPath $exe -Port 18765)
|
||
|
|
if ($rules.Count -ne 2) { throw 'Expected two rules.' }
|
||
|
|
foreach ($rule in $rules) {
|
||
|
|
if ($rule.Profile -ne 'Private' -or $rule.RemoteAddress -ne 'LocalSubnet' -or $rule.Program -ne $exe -or
|
||
|
|
$rule.Direction -ne 'Inbound' -or $rule.Action -ne 'Allow' -or $rule.EdgeTraversalPolicy -ne 'Block') { throw 'Rule scope is too broad.' }
|
||
|
|
}
|
||
|
|
if (($rules | Where-Object Protocol -eq TCP).LocalPort -ne 18765) { throw 'HTTPS port mismatch.' }
|
||
|
|
if (($rules | Where-Object Protocol -eq UDP).LocalPort -ne 5353) { throw 'mDNS port mismatch.' }
|
||
|
|
$again = @(& $script -Action Preview -ProgramPath $exe -Port 8765)
|
||
|
|
if (($rules.Name -join ',') -ne ($again.Name -join ',')) { throw 'Changing port would leave old rule names behind.' }
|
||
|
|
& $script -Action Apply -ProgramPath $exe -WhatIf
|
||
|
|
Write-Host 'PASS: private profile, local subnet, executable binding, ports, stable names and dry-run. No firewall changes.'
|