90d2a230a3
- 将批处理脚本改为英文输出 - 添加UTF-8编码支持(chcp 65001) - 添加go.mod存在性检查 - 创建详细的Windows使用说明文档
70 lignes
1.8 KiB
Batchfile
70 lignes
1.8 KiB
Batchfile
@echo off
|
|
chcp 65001 >nul 2>&1
|
|
echo ========================================
|
|
echo Network Topology Discovery System - Build Script
|
|
echo ========================================
|
|
echo.
|
|
|
|
REM Check if go.mod exists
|
|
if not exist go.mod (
|
|
echo Error: go.mod not found!
|
|
echo Please run this script from the project root directory.
|
|
echo.
|
|
echo Current directory: %CD%
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo [1/3] Cleaning old files...
|
|
if exist network-topology.exe del network-topology.exe
|
|
|
|
echo.
|
|
echo [2/3] Building program...
|
|
set GOOS=windows
|
|
set GOARCH=amd64
|
|
go build -o network-topology.exe -ldflags="-s -w" ./cmd
|
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
echo.
|
|
echo Build failed!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo.
|
|
echo [3/3] Creating config file example...
|
|
if not exist config.json (
|
|
echo Creating default config file...
|
|
echo {> config.json
|
|
echo "scan_ranges": ["192.168.1.0/24"],>> config.json
|
|
echo "devices": [],>> config.json
|
|
echo "ssh": {>> config.json
|
|
echo "timeout": 10,>> config.json
|
|
echo "max_retries": 3,>> config.json
|
|
echo "port": 22>> config.json
|
|
echo },>> config.json
|
|
echo "web": {>> config.json
|
|
echo "port": 8080,>> config.json
|
|
echo "host": "0.0.0.0">> config.json
|
|
echo },>> config.json
|
|
echo "scanner": {>> config.json
|
|
echo "concurrency": 10,>> config.json
|
|
echo "timeout": 2>> config.json
|
|
echo }>> config.json
|
|
echo }>> config.json
|
|
)
|
|
|
|
echo.
|
|
echo ========================================
|
|
echo Build Complete!
|
|
echo ========================================
|
|
echo.
|
|
echo Usage:
|
|
echo network-topology.exe (Use default config)
|
|
echo network-topology.exe config.json (Use specified config)
|
|
echo.
|
|
echo Web UI: http://localhost:8080
|
|
echo.
|
|
pause
|