| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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"`
- VLAN string `json:"vlan"` // VLAN信息(PVID/Access/Trunk)
- 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"`
- }
|