@echo off
REM BestPerf — Windows peer firewall setup. Run ONCE per Windows peer, as Administrator
REM (right-click -> "Run as administrator"). Adds PORT-RANGE inbound allow rules so the
REM measurement traffic is permitted regardless of the binary's name/path — this survives
REM binary renames/rebuilds (a per-program rule would NOT, and was the cause of TCP being
REM silently blocked after the fr-* -> bperf-* rename).
REM
REM Ports: UDP 39700-39899 (light probes + load), TCP 39800-39899 (TCP throughput),
REM        TCP 8768 (the control console, only needed if peers reach this machine's GUI).

echo Adding BestPerf inbound firewall rules...
netsh advfirewall firewall delete rule name="BestPerf UDP" >nul 2>&1
netsh advfirewall firewall delete rule name="BestPerf TCP" >nul 2>&1
netsh advfirewall firewall delete rule name="BestPerf Console" >nul 2>&1
netsh advfirewall firewall add rule name="BestPerf UDP" dir=in action=allow protocol=UDP localport=39700-39899
netsh advfirewall firewall add rule name="BestPerf TCP" dir=in action=allow protocol=TCP localport=39800-39899
netsh advfirewall firewall add rule name="BestPerf Console" dir=in action=allow protocol=TCP localport=8768
echo Done. Current BestPerf rules:
netsh advfirewall firewall show rule name="BestPerf UDP" | findstr /I "Rule LocalPort Action Enabled"
netsh advfirewall firewall show rule name="BestPerf TCP" | findstr /I "Rule LocalPort Action Enabled"
