refactor(discovery): use ping for discovery and fill MAC via SSH
This commit is contained in:
@@ -1,23 +1,18 @@
|
||||
package discovery
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"auto-check/pkg/model"
|
||||
)
|
||||
|
||||
// Devices 设备表(IP → 设备),每轮 Discover() 后更新,包级公开
|
||||
var Devices = make(map[string]model.Device)
|
||||
|
||||
// Discover 扫描并更新包级 Devices map(过滤无 MAC 设备,保留上次状态延续)
|
||||
// Discover 扫描并更新包级 Devices map
|
||||
func (s *Scanner) Discover() {
|
||||
scanned := s.Scan()
|
||||
Devices = make(map[string]model.Device, len(scanned))
|
||||
devices := make(map[string]model.Device, len(scanned))
|
||||
for _, dev := range scanned {
|
||||
if dev.MAC == "" {
|
||||
fmt.Printf(" [!] %s 无 MAC(ARP 未解析),下轮重试\n", dev.IP)
|
||||
continue
|
||||
}
|
||||
Devices[dev.IP] = dev
|
||||
devices[dev.IP] = dev
|
||||
}
|
||||
Devices = devices
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user