refactor(discovery): use ping for discovery and fill MAC via SSH

This commit is contained in:
12600k-rog-d4
2026-08-12 21:45:51 +08:00
parent 906bb54aaa
commit 175c5e8c6c
21 changed files with 542 additions and 310 deletions

View File

@@ -6,14 +6,18 @@ import "fmt"
// 公共类型 — 全包共用,唯一来源
// ============================
// Device 设备MAC 为唯一标识)
// 当前仅 IP/MAC 两个字段,后续按需扩展
// Device 设备
// 发现阶段以 IP 标识(仅做 ping 可达性探测MAC 在 SSH 登录后回填,
// 空 = 尚未获取。键map key始终为 IP。
type Device struct {
IP string // 当前 IPDHCP 可能变化)
MAC string // 物理地址,唯一标识,空 = 无法获取
MAC string // 物理地址,SSH 阶段回填,空 = 尚未获取
}
// Label 设备显示名(用于日志/报告)
func (d Device) Label() string {
return fmt.Sprintf("%s (%s)", d.MAC, d.IP)
if d.MAC != "" {
return fmt.Sprintf("%s (%s)", d.IP, d.MAC)
}
return d.IP
}