Files
Your Name 44f7fef1f8 v1.0.1: 多拓扑管理、Web SSH终端、扫描进度修复、拓扑连线优化
- 修复扫描进度条不动的问题(分4阶段更新进度)
- 新增Web SSH远程终端(xterm.js + WebSocket)
- 新增多拓扑管理(创建/切换拓扑、全局设备池)
- 简化新建拓扑流程(仅需名称,创建后选择设备)
- 修复拓扑Builder设备去重(按IP去重)
- 修复启动时拓扑设备不加载到Builder的问题
- 优化MAC前缀匹配(避免歧义前缀导致错误连线)
- 拓扑连线改为无向(去除箭头)
- 设备详情面板加宽到600px
2026-04-26 13:25:19 +08:00

110 líneas
3.5 KiB
Go

package models
import "time"
// DeviceType 设备类型
type DeviceType string
const (
DeviceTypeCisco DeviceType = "cisco"
DeviceTypeHuawei DeviceType = "huawei"
DeviceTypeH3C DeviceType = "h3c"
DeviceTypeASA DeviceType = "asa"
DeviceTypeLinux DeviceType = "linux"
DeviceTypeWindows DeviceType = "windows"
)
// Device 网络设备
type Device struct {
ID string `json:"id"`
IP string `json:"ip"`
Type DeviceType `json:"type"`
Hostname string `json:"hostname"`
OSVersion string `json:"os_version"`
Uptime string `json:"uptime"`
Interfaces []Interface `json:"interfaces"`
Neighbors []Neighbor `json:"neighbors"`
MACAddresses []string `json:"mac_addresses,omitempty"` // 设备的所有MAC地址(用于邻居匹配)
LastScanned time.Time `json:"last_scanned"`
ScanStatus string `json:"scan_status"` // success, failed, pending
ErrorMessage string `json:"error_message,omitempty"`
}
// Interface 网络接口
type Interface struct {
Name string `json:"name"`
Description string `json:"description"`
IP string `json:"ip"`
Mask string `json:"mask"`
MAC string `json:"mac"`
Status string `json:"status"` // up, down, admin down
Speed string `json:"speed"`
Duplex string `json:"duplex"`
MTU int `json:"mtu"`
InBytes int64 `json:"in_bytes"`
OutBytes int64 `json:"out_bytes"`
InPackets int64 `json:"in_packets"`
OutPackets int64 `json:"out_packets"`
}
// Neighbor 邻居设备信息
type Neighbor struct {
LocalInterface string `json:"local_interface"`
RemoteDevice string `json:"remote_device"`
RemoteIP string `json:"remote_ip"`
RemoteMAC string `json:"remote_mac,omitempty"` // MAC地址(用于拓扑匹配)
RemoteInterface string `json:"remote_interface"`
Protocol string `json:"protocol"` // CDP, LLDP, ARP
}
// ScanTask 扫描任务
type ScanTask struct {
ID string `json:"id"`
Status string `json:"status"` // running, completed, failed
Progress int `json:"progress"`
TotalDevices int `json:"total_devices"`
ScannedDevices int `json:"scanned_devices"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Devices []Device `json:"devices"`
ErrorMessage string `json:"error_message,omitempty"`
}
// TopologyGraph 拓扑图数据
type TopologyGraph struct {
Nodes []TopologyNode `json:"nodes"`
Edges []TopologyEdge `json:"edges"`
}
// TopologyNode 拓扑节点
type TopologyNode struct {
ID string `json:"id"`
IP string `json:"ip"`
Hostname string `json:"hostname"`
Type string `json:"type"`
Icon string `json:"icon"`
}
// TopologyEdge 拓扑边
type TopologyEdge struct {
ID string `json:"id"`
Source string `json:"source"`
Target string `json:"target"`
SourceInterface string `json:"source_interface"`
TargetInterface string `json:"target_interface"`
Protocol string `json:"protocol"`
}
// Topology 网络拓扑(一个拓扑包含多个设备)
type Topology struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ScanRange string `json:"scan_range"`
SSHPort int `json:"ssh_port"`
Username string `json:"username"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeviceCount int `json:"device_count"`
}