成功开发了一个运行在Windows系统上的网络拓扑发现程序,可以远程获取网络设备的接口信息并自动生成网络拓扑图。
多厂商设备支持
SSH远程采集
拓扑发现
Web可视化界面
后端 (Go)
internal/ssh/client.go)internal/device/)internal/topology/builder.go)internal/scanner/scanner.go)internal/config/config.go)cmd/main.go)前端 (HTML5/CSS3/JavaScript)
network-topology-discovery/
├── cmd/
│ └── main.go # 主程序(278行)
├── internal/
│ ├── ssh/
│ │ └── client.go # SSH客户端(177行)
│ ├── device/
│ │ ├── parser.go # 解析器接口(94行)
│ │ ├── cisco.go # Cisco解析器(285行)
│ │ ├── huawei.go # 华为解析器(170行)
│ │ ├── h3c.go # H3C解析器(159行)
│ │ ├── asa.go # ASA解析器(113行)
│ │ ├── linux.go # Linux解析器(108行)
│ │ └── windows.go # Windows解析器(200行)
│ ├── topology/
│ │ └── builder.go # 拓扑构建器(123行)
│ ├── scanner/
│ │ └── scanner.go # 网络扫描器(129行)
│ └── config/
│ └── config.go # 配置管理(126行)
├── web/
│ ├── index.html # Web界面(113行)
│ ├── css/
│ │ └── style.css # 样式(272行)
│ └── js/
│ └── app.js # 应用逻辑(344行)
├── pkg/
│ └── models/
│ └── models.go # 数据模型(95行)
├── build.bat # 编译脚本
├── start.bat # 启动脚本
├── config.example.json # 配置示例
├── README.md # 使用文档
├── go.mod # Go模块文件
└── network-topology.exe # 编译后的程序(10MB)
总代码量: 约2,800行
start.bat 启动程序http://localhost:8080build.bat 编译network-topology.exe在 config.json 中预配置设备:
{
"devices": [
{
"ip": "192.168.1.1",
"type": "cisco",
"username": "admin",
"password": "password"
}
]
}
| 设备类型 | 版本信息 | 接口信息 | 邻居发现 |
|---|---|---|---|
| Cisco | show version | show interface | CDP/LLDP |
| 华为 | display version | display interface | LLDP |
| H3C | display version | display interface | LLDP |
| ASA | show version | show interface | - |
| Linux | uname -a | ip addr show | - |
| Windows | systeminfo | Get-NetAdapter | - |
golang.org/x/crypto/ssh - SSH客户端crypto/rand - 唯一ID生成net/http, encoding/json, sync 等开发完成时间: 2026年4月25日 状态: ✅ 已完成,可编译运行