fix: 修复 Hub 广播 data race 和端口扫描潜在死锁,清理死代码

- hub.go: broadcast 路径 RLock 改 Lock,修复并发 delete/close 竞争
- port_scan.go: pool.Invoke 失败时释放 wg 和 semaphore,防止死锁
- web_scanner.go: 删除只写不读的 fingerprintCache
- webtitle.go: 移除对已删除 SetFingerprints 的调用
- keylogger.go: 删除未使用的 stopChan 和 isRunning 字段
This commit is contained in:
ZacharyZcR
2026-04-27 19:04:26 +08:00
parent b35dbe4972
commit 1fe8bb5182
5 changed files with 6 additions and 39 deletions
+4 -1
View File
@@ -252,7 +252,10 @@ func slidingWindowSchedule(iter *SocketIterator, pool *AdaptivePool, wg *sync.Wa
port: port,
semaphore: semaphore,
}
_ = pool.Invoke(task)
if err := pool.Invoke(task); err != nil {
<-semaphore
wg.Done()
}
}
// 等待所有任务完成
-24
View File
@@ -276,30 +276,6 @@ func IsMarkedWebService(host string, port int) bool {
return exists
}
// ===============================
// 指纹缓存
// ===============================
// 指纹缓存 - 存储 host:port → 指纹列表的映射
var (
fingerprintCache = make(map[string][]string)
fingerprintCacheMutex sync.RWMutex
)
// SetFingerprints 存储目标的指纹信息
func SetFingerprints(host string, port int, fingerprints []string) {
if len(fingerprints) == 0 {
return
}
cacheKey := fmt.Sprintf("%s:%d", host, port)
fingerprintCacheMutex.Lock()
defer fingerprintCacheMutex.Unlock()
fingerprintCache[cacheKey] = fingerprints
}
// ===============================
// Web扫描策略
// ===============================