@echo off
REM WireGuard Configuration Generator for Tailscale Clone
REM Usage: generate-wg-config.bat "windows-node" "private-key" "10.0.0.3" "10.9.2.100"

if "%4"=="" (
    echo Usage: generate-wg-config.bat "NodeName" "PrivateKey" "IP" "ControllerIP"
    echo Example: generate-wg-config.bat "windows-node" "7cbd4de93860de96aea191ec5630461616cce1baddd700cd370cdcf1de309d80" "10.0.0.3" "10.9.2.100"
    exit /b 1
)

set NODE_NAME=%1
set PRIVATE_KEY=%2
set IP=%3
set CONTROLLER_IP=%4
set OUTPUT_FILE=wireguard.conf

echo [Interface] > %OUTPUT_FILE%
echo PrivateKey = %PRIVATE_KEY% >> %OUTPUT_FILE%
echo Address = %IP%/24 >> %OUTPUT_FILE%
echo DNS = 8.8.8.8, 8.8.4.4 >> %OUTPUT_FILE%
echo. >> %OUTPUT_FILE%
echo # Tailscale Clone Network Configuration >> %OUTPUT_FILE%
echo # This interface will be configured by the controller >> %OUTPUT_FILE%
echo # Peers will be added automatically when other nodes connect >> %OUTPUT_FILE%

echo.
echo WireGuard configuration generated: %OUTPUT_FILE%
echo.
echo To import this configuration:
echo 1. Open WireGuard Windows client
echo 2. Click 'Import tunnel(s) from file'
echo 3. Select the file: %OUTPUT_FILE%
echo 4. The tunnel will be created with the name: wg0
echo.
echo Note: The controller will automatically configure peers as nodes connect. 