v1.0.1: 多拓扑管理、Web SSH终端、扫描进度修复、拓扑连线优化
- 修复扫描进度条不动的问题(分4阶段更新进度) - 新增Web SSH远程终端(xterm.js + WebSocket) - 新增多拓扑管理(创建/切换拓扑、全局设备池) - 简化新建拓扑流程(仅需名称,创建后选择设备) - 修复拓扑Builder设备去重(按IP去重) - 修复启动时拓扑设备不加载到Builder的问题 - 优化MAC前缀匹配(避免歧义前缀导致错误连线) - 拓扑连线改为无向(去除箭头) - 设备详情面板加宽到600px
This commit is contained in:
@@ -4,9 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"network-topology-discovery/pkg/models"
|
||||
"os"
|
||||
"sync"
|
||||
"network-topology-discovery/pkg/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -17,8 +17,13 @@ type Storage struct {
|
||||
devices map[string]models.Device
|
||||
}
|
||||
|
||||
// NewStorage 创建存储实例
|
||||
// NewStorage 创建存储实例(兼容旧版,使用默认文件)
|
||||
func NewStorage(filePath string) (*Storage, error) {
|
||||
return NewStorageForTopology(filePath)
|
||||
}
|
||||
|
||||
// NewStorageForTopology 为特定拓扑创建存储实例
|
||||
func NewStorageForTopology(filePath string) (*Storage, error) {
|
||||
s := &Storage{
|
||||
filePath: filePath,
|
||||
devices: make(map[string]models.Device),
|
||||
@@ -36,6 +41,24 @@ func NewStorage(filePath string) (*Storage, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// SetFilePath 切换存储文件路径(用于切换拓扑)
|
||||
func (s *Storage) SetFilePath(filePath string) error {
|
||||
s.mu.Lock()
|
||||
s.filePath = filePath
|
||||
s.devices = make(map[string]models.Device)
|
||||
s.mu.Unlock()
|
||||
|
||||
// 重新加载数据
|
||||
if err := s.load(); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("failed to load storage: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Storage switched to: %s", filePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
// load 从文件加载数据
|
||||
func (s *Storage) load() error {
|
||||
data, err := os.ReadFile(s.filePath)
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"network-topology-discovery/pkg/models"
|
||||
)
|
||||
|
||||
// TopologyStorage 拓扑存储管理
|
||||
type TopologyStorage struct {
|
||||
mu sync.RWMutex
|
||||
dataDir string
|
||||
topologies map[string]*models.Topology
|
||||
currentTopoID string
|
||||
}
|
||||
|
||||
// NewTopologyStorage 创建拓扑存储
|
||||
func NewTopologyStorage(dataDir string) (*TopologyStorage, error) {
|
||||
s := &TopologyStorage{
|
||||
dataDir: dataDir,
|
||||
topologies: make(map[string]*models.Topology),
|
||||
}
|
||||
|
||||
// 确保数据目录存在
|
||||
if err := os.MkdirAll(dataDir, 0755); err != nil {
|
||||
return nil, fmt.Errorf("failed to create data directory: %w", err)
|
||||
}
|
||||
|
||||
// 加载拓扑元数据
|
||||
if err := s.loadMeta(); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("failed to load topology meta: %w", err)
|
||||
}
|
||||
log.Printf("Creating new topology storage at %s", dataDir)
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// loadMeta 加载拓扑元数据
|
||||
func (s *TopologyStorage) loadMeta() error {
|
||||
metaFile := filepath.Join(s.dataDir, "topologies.json")
|
||||
data, err := os.ReadFile(metaFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var topos []models.Topology
|
||||
if err := json.Unmarshal(data, &topos); err != nil {
|
||||
return fmt.Errorf("failed to parse topology meta: %w", err)
|
||||
}
|
||||
|
||||
for i := range topos {
|
||||
s.topologies[topos[i].ID] = &topos[i]
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d topologies from meta", len(topos))
|
||||
return nil
|
||||
}
|
||||
|
||||
// saveMeta 保存拓扑元数据
|
||||
func (s *TopologyStorage) saveMeta() error {
|
||||
topos := make([]models.Topology, 0, len(s.topologies))
|
||||
for _, topo := range s.topologies {
|
||||
topos = append(topos, *topo)
|
||||
}
|
||||
|
||||
data, err := json.MarshalIndent(topos, "", " ")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal topologies: %w", err)
|
||||
}
|
||||
|
||||
metaFile := filepath.Join(s.dataDir, "topologies.json")
|
||||
if err := os.WriteFile(metaFile, data, 0644); err != nil {
|
||||
return fmt.Errorf("failed to write topology meta: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateTopology 创建新拓扑
|
||||
func (s *TopologyStorage) CreateTopology(name, description, scanRange string, sshPort int, username string) (*models.Topology, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
topo := &models.Topology{
|
||||
ID: generateID(),
|
||||
Name: name,
|
||||
Description: description,
|
||||
ScanRange: scanRange,
|
||||
SSHPort: sshPort,
|
||||
Username: username,
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
DeviceCount: 0,
|
||||
}
|
||||
|
||||
s.topologies[topo.ID] = topo
|
||||
|
||||
// 创建该拓扑的设备文件
|
||||
deviceFile := filepath.Join(s.dataDir, topo.ID+"_devices.json")
|
||||
if _, err := os.Stat(deviceFile); os.IsNotExist(err) {
|
||||
if err := os.WriteFile(deviceFile, []byte("[]"), 0644); err != nil {
|
||||
return nil, fmt.Errorf("failed to create device file: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 保存元数据
|
||||
if err := s.saveMeta(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("Topology created: %s (%s)", topo.Name, topo.ID)
|
||||
return topo, nil
|
||||
}
|
||||
|
||||
// GetTopology 获取拓扑
|
||||
func (s *TopologyStorage) GetTopology(id string) (*models.Topology, error) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
topo, exists := s.topologies[id]
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("topology not found: %s", id)
|
||||
}
|
||||
|
||||
return topo, nil
|
||||
}
|
||||
|
||||
// GetAllTopologies 获取所有拓扑
|
||||
func (s *TopologyStorage) GetAllTopologies() ([]models.Topology, error) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
topos := make([]models.Topology, 0, len(s.topologies))
|
||||
for _, topo := range s.topologies {
|
||||
topos = append(topos, *topo)
|
||||
}
|
||||
|
||||
return topos, nil
|
||||
}
|
||||
|
||||
// UpdateTopology 更新拓扑
|
||||
func (s *TopologyStorage) UpdateTopology(id string, updates map[string]interface{}) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
topo, exists := s.topologies[id]
|
||||
if !exists {
|
||||
return fmt.Errorf("topology not found: %s", id)
|
||||
}
|
||||
|
||||
if name, ok := updates["name"].(string); ok {
|
||||
topo.Name = name
|
||||
}
|
||||
if desc, ok := updates["description"].(string); ok {
|
||||
topo.Description = desc
|
||||
}
|
||||
if scanRange, ok := updates["scan_range"].(string); ok {
|
||||
topo.ScanRange = scanRange
|
||||
}
|
||||
if sshPort, ok := updates["ssh_port"].(float64); ok {
|
||||
topo.SSHPort = int(sshPort)
|
||||
}
|
||||
if username, ok := updates["username"].(string); ok {
|
||||
topo.Username = username
|
||||
}
|
||||
|
||||
topo.UpdatedAt = time.Now()
|
||||
|
||||
return s.saveMeta()
|
||||
}
|
||||
|
||||
// DeleteTopology 删除拓扑及其所有数据
|
||||
func (s *TopologyStorage) DeleteTopology(id string) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if _, exists := s.topologies[id]; !exists {
|
||||
return fmt.Errorf("topology not found: %s", id)
|
||||
}
|
||||
|
||||
// 删除设备文件
|
||||
deviceFile := filepath.Join(s.dataDir, id+"_devices.json")
|
||||
if err := os.Remove(deviceFile); err != nil && !os.IsNotExist(err) {
|
||||
log.Printf("Warning: failed to delete device file for topology %s: %v", id, err)
|
||||
}
|
||||
|
||||
delete(s.topologies, id)
|
||||
|
||||
// 更新当前拓扑
|
||||
if s.currentTopoID == id {
|
||||
s.currentTopoID = ""
|
||||
}
|
||||
|
||||
return s.saveMeta()
|
||||
}
|
||||
|
||||
// SetCurrentTopology 设置当前拓扑
|
||||
func (s *TopologyStorage) SetCurrentTopology(id string) error {
|
||||
if _, err := s.GetTopology(id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.currentTopoID = id
|
||||
log.Printf("Current topology set to: %s", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCurrentTopologyID 获取当前拓扑ID
|
||||
func (s *TopologyStorage) GetCurrentTopologyID() string {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return s.currentTopoID
|
||||
}
|
||||
|
||||
// GetDeviceFilePath 获取拓扑的设备文件路径
|
||||
func (s *TopologyStorage) GetDeviceFilePath(topoID string) string {
|
||||
return filepath.Join(s.dataDir, topoID+"_devices.json")
|
||||
}
|
||||
|
||||
// generateID 生成唯一ID
|
||||
func generateID() string {
|
||||
b := make([]byte, 16)
|
||||
rand.Read(b)
|
||||
return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
return true // 允许所有来源
|
||||
},
|
||||
}
|
||||
|
||||
// TerminalSession 终端会话
|
||||
type TerminalSession struct {
|
||||
sshClient *ssh.Client
|
||||
sshSession *ssh.Session
|
||||
stdin io.Writer
|
||||
stdout io.Reader
|
||||
wsConn *websocket.Conn
|
||||
done chan struct{}
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// ConnectSSH 建立SSH连接并创建交互式Shell
|
||||
func ConnectSSH(host string, port int, username, password string) (*TerminalSession, error) {
|
||||
config := &ssh.ClientConfig{
|
||||
User: username,
|
||||
Auth: []ssh.AuthMethod{ssh.Password(password)},
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
Timeout: 10 * time.Second,
|
||||
Config: ssh.Config{
|
||||
Ciphers: []string{
|
||||
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
||||
"aes128-gcm@openssh.com", "aes256-gcm@openssh.com",
|
||||
"chacha20-poly1305@openssh.com",
|
||||
"aes128-cbc", "aes256-cbc",
|
||||
},
|
||||
KeyExchanges: []string{
|
||||
"curve25519-sha256", "curve25519-sha256@libssh.org",
|
||||
"ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521",
|
||||
"diffie-hellman-group14-sha256", "diffie-hellman-group16-sha512",
|
||||
"diffie-hellman-group14-sha1", "diffie-hellman-group1-sha1",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", host, port)
|
||||
client, err := ssh.Dial("tcp", addr, config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("SSH连接失败: %w", err)
|
||||
}
|
||||
|
||||
session, err := client.NewSession()
|
||||
if err != nil {
|
||||
client.Close()
|
||||
return nil, fmt.Errorf("创建SSH会话失败: %w", err)
|
||||
}
|
||||
|
||||
// 获取 stdin 管道
|
||||
stdin, err := session.StdinPipe()
|
||||
if err != nil {
|
||||
session.Close()
|
||||
client.Close()
|
||||
return nil, fmt.Errorf("获取stdin失败: %w", err)
|
||||
}
|
||||
|
||||
// 获取 stdout 管道
|
||||
stdout, err := session.StdoutPipe()
|
||||
if err != nil {
|
||||
session.Close()
|
||||
client.Close()
|
||||
return nil, fmt.Errorf("获取stdout失败: %w", err)
|
||||
}
|
||||
|
||||
// 也获取 stderr
|
||||
session.Stderr = io.Discard
|
||||
|
||||
// 请求 PTY(xterm 终端)
|
||||
modes := ssh.TerminalModes{
|
||||
ssh.ECHO: 1,
|
||||
ssh.TTY_OP_ISPEED: 14400,
|
||||
ssh.TTY_OP_OSPEED: 14400,
|
||||
}
|
||||
if err := session.RequestPty("xterm", 40, 120, modes); err != nil {
|
||||
session.Close()
|
||||
client.Close()
|
||||
return nil, fmt.Errorf("请求PTY失败: %w", err)
|
||||
}
|
||||
|
||||
// 启动 Shell
|
||||
if err := session.Shell(); err != nil {
|
||||
session.Close()
|
||||
client.Close()
|
||||
return nil, fmt.Errorf("启动Shell失败: %w", err)
|
||||
}
|
||||
|
||||
return &TerminalSession{
|
||||
sshClient: client,
|
||||
sshSession: session,
|
||||
stdin: stdin,
|
||||
stdout: stdout,
|
||||
done: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// HandleTerminal 处理WebSocket终端连接
|
||||
func HandleTerminal(w http.ResponseWriter, r *http.Request, host string, port int, username, password string) {
|
||||
// 建立 SSH 连接
|
||||
session, err := ConnectSSH(host, port, username, password)
|
||||
if err != nil {
|
||||
log.Printf("[终端] SSH连接失败 %s: %v", host, err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
// 升级为 WebSocket
|
||||
wsConn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
session.Close()
|
||||
log.Printf("[终端] WebSocket升级失败: %v", err)
|
||||
return
|
||||
}
|
||||
session.wsConn = wsConn
|
||||
|
||||
log.Printf("[终端] 已连接到 %s (%s)", host, username)
|
||||
|
||||
// 启动 SSH -> WebSocket 的数据转发
|
||||
go session.sshToWs()
|
||||
// 启动 WebSocket -> SSH 的数据转发
|
||||
go session.wsToSsh()
|
||||
// 等待结束
|
||||
<-session.done
|
||||
|
||||
session.Close()
|
||||
log.Printf("[终端] 已断开 %s", host)
|
||||
}
|
||||
|
||||
// sshToWs 从SSH读取输出并转发到WebSocket
|
||||
func (s *TerminalSession) sshToWs() {
|
||||
buf := make([]byte, 8192)
|
||||
for {
|
||||
select {
|
||||
case <-s.done:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
n, err := s.stdout.Read(buf)
|
||||
if err != nil {
|
||||
log.Printf("[终端] SSH读取结束: %v", err)
|
||||
s.closeDone()
|
||||
return
|
||||
}
|
||||
|
||||
if n > 0 {
|
||||
s.mu.Lock()
|
||||
err := s.wsConn.WriteMessage(websocket.TextMessage, buf[:n])
|
||||
s.mu.Unlock()
|
||||
if err != nil {
|
||||
log.Printf("[终端] WebSocket写入失败: %v", err)
|
||||
s.closeDone()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wsToSsh 从WebSocket读取输入并转发到SSH
|
||||
func (s *TerminalSession) wsToSsh() {
|
||||
for {
|
||||
select {
|
||||
case <-s.done:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
_, message, err := s.wsConn.ReadMessage()
|
||||
if err != nil {
|
||||
log.Printf("[终端] WebSocket读取失败: %v", err)
|
||||
s.closeDone()
|
||||
return
|
||||
}
|
||||
|
||||
if len(message) > 0 {
|
||||
// 解析JSON消息格式(xterm.js发送的)
|
||||
var msg map[string]interface{}
|
||||
if err := json.Unmarshal(message, &msg); err == nil {
|
||||
if input, ok := msg["input"].(string); ok {
|
||||
_, err := s.stdin.Write([]byte(input))
|
||||
if err != nil {
|
||||
log.Printf("[终端] SSH写入失败: %v", err)
|
||||
s.closeDone()
|
||||
return
|
||||
}
|
||||
}
|
||||
// 处理resize消息
|
||||
if msg["type"] == "resize" {
|
||||
if cols, ok := msg["cols"].(float64); ok {
|
||||
if rows, ok := msg["rows"].(float64); ok {
|
||||
_ = s.sshSession.WindowChange(int(rows), int(cols))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 原始二进制数据,直接写入
|
||||
_, err := s.stdin.Write(message)
|
||||
if err != nil {
|
||||
s.closeDone()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// closeDone 安全关闭
|
||||
func (s *TerminalSession) closeDone() {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
select {
|
||||
case <-s.done:
|
||||
// 已经关闭
|
||||
default:
|
||||
close(s.done)
|
||||
}
|
||||
}
|
||||
|
||||
// Close 关闭会话
|
||||
func (s *TerminalSession) Close() {
|
||||
s.closeDone()
|
||||
if s.wsConn != nil {
|
||||
s.wsConn.Close()
|
||||
}
|
||||
if s.sshSession != nil {
|
||||
s.sshSession.Close()
|
||||
}
|
||||
if s.sshClient != nil {
|
||||
s.sshClient.Close()
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,14 @@ func NewBuilder() *Builder {
|
||||
return &Builder{}
|
||||
}
|
||||
|
||||
// AddDevice 添加设备
|
||||
// AddDevice 添加设备(按IP去重)
|
||||
func (b *Builder) AddDevice(device models.Device) {
|
||||
for i, existing := range b.devices {
|
||||
if existing.IP == device.IP {
|
||||
b.devices[i] = device // 覆盖更新
|
||||
return
|
||||
}
|
||||
}
|
||||
b.devices = append(b.devices, device)
|
||||
}
|
||||
|
||||
@@ -141,18 +147,25 @@ func (b *Builder) Build() models.TopologyGraph {
|
||||
}
|
||||
}
|
||||
|
||||
// 策略3b: 通过MAC前缀匹配(新增)
|
||||
// 当精确MAC匹配失败时,尝试通过MAC前缀匹配(适用于同一设备的多个接口)
|
||||
// 策略3b: 通过MAC前缀匹配(改进:排除歧义前缀)
|
||||
// 当精确MAC匹配失败时,尝试通过MAC前缀匹配
|
||||
// 但如果同一前缀匹配到多台设备,则跳过(避免错误连接)
|
||||
if targetIP == "" && neighbor.RemoteMAC != "" {
|
||||
neighborMACPrefix := getMACPrefix(neighbor.RemoteMAC)
|
||||
fmt.Printf(" Trying MAC prefix match: %s (prefix: %s)\n", neighbor.RemoteMAC, neighborMACPrefix)
|
||||
|
||||
// 先统计有多少台设备匹配此MAC前缀
|
||||
type prefixMatch struct {
|
||||
ip string
|
||||
matchingMACs int
|
||||
}
|
||||
var matches []prefixMatch
|
||||
|
||||
for _, d := range b.devices {
|
||||
if d.IP == device.IP {
|
||||
continue // 跳过自己
|
||||
}
|
||||
|
||||
// 检查该设备的MAC地址是否有相同前缀
|
||||
matchingMACs := 0
|
||||
for _, mac := range d.MACAddresses {
|
||||
if getMACPrefix(mac) == neighborMACPrefix {
|
||||
@@ -160,18 +173,20 @@ func (b *Builder) Build() models.TopologyGraph {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果该设备有多个MAC地址使用相同前缀,说明是同一台设备
|
||||
if matchingMACs >= 3 { // 至少3个MAC使用相同前缀
|
||||
// 进一步验证:检查是否在同一网段
|
||||
if getSubnet(d.IP) == getSubnet(device.IP) {
|
||||
targetIP = d.IP
|
||||
matchMethod = fmt.Sprintf("MAC-prefix(%s)", neighborMACPrefix)
|
||||
fmt.Printf(" ✓ Matched by MAC prefix: %s (device has %d MACs with prefix %s, same subnet) -> %s\n",
|
||||
neighbor.RemoteMAC, matchingMACs, neighborMACPrefix, d.IP)
|
||||
break
|
||||
}
|
||||
if matchingMACs >= 3 {
|
||||
matches = append(matches, prefixMatch{ip: d.IP, matchingMACs: matchingMACs})
|
||||
}
|
||||
}
|
||||
|
||||
// 只在唯一匹配时使用前缀匹配
|
||||
if len(matches) == 1 && getSubnet(matches[0].ip) == getSubnet(device.IP) {
|
||||
targetIP = matches[0].ip
|
||||
matchMethod = fmt.Sprintf("MAC-prefix(%s)", neighborMACPrefix)
|
||||
fmt.Printf(" ✓ Matched by MAC prefix: %s (device has %d MACs with prefix %s, same subnet) -> %s\n",
|
||||
neighbor.RemoteMAC, matches[0].matchingMACs, neighborMACPrefix, targetIP)
|
||||
} else if len(matches) > 1 {
|
||||
fmt.Printf(" ✗ Skipping MAC prefix match: %d devices share prefix %s (ambiguous)\n", len(matches), neighborMACPrefix)
|
||||
}
|
||||
}
|
||||
|
||||
// 策略4: 通过本地接口IP网段匹配(新增)
|
||||
|
||||
Reference in New Issue
Block a user