@echo off
title Port Forward 40600 to localhost
setlocal

:: ============================
:: Settings
:: ============================
set "LISTEN_PORT=40600"         :: External port
set "TARGET_IP=127.0.0.1"       :: Internal destination
set "TARGET_PORT=40600"         :: Internal port

:: ============================
:: Elevate if not admin
:: ============================
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo [!] Requesting administrative privileges...
    powershell -Command "Start-Process '%~f0' -Verb runAs"
    exit /b
)

:: ============================
:: Add port proxy
:: ============================
echo [*] Setting up port forwarding...
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=%LISTEN_PORT% connectaddress=%TARGET_IP% connectport=%TARGET_PORT%

:: ============================
:: Open firewall
:: ============================
echo [*] Adding firewall rule...
netsh advfirewall firewall add rule name="Forward_HTTP_%LISTEN_PORT%" dir=in action=allow protocol=TCP localport=%LISTEN_PORT%

echo [✓] Done. You can now access:
echo     http://localhost:%LISTEN_PORT%/api/pay
echo     from another device on the same LAN.

pause
