Initial commit: 网络拓扑发现系统
- 支持Cisco、华为、H3C、ASA、Linux、Windows设备 - SSH远程采集设备信息 - 自动发现网络拓扑(LLDP/CDP) - Web可视化界面 - 支持旧版SSH加密算法兼容
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
مرجع در شماره جدید
Block a user