mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 20:21:52 +08:00
perf: 六项性能优化
- DNS 解析缓存:sync.Map 缓存避免重复系统调用 - 凭据测试 TCP 预检:不可达目标直接跳过全部凭据 - Web 探测 HTTP Client 复用:全局共享连接池 - 端口扫描 Bloom Filter 去重:替代 map 降低内存 - 进度条 atomic 累加 + 50ms 节流渲染:消除锁竞争 - 服务探针预解码:Init 时预编译,运行时零解码开销
This commit is contained in:
+26
-7
@@ -219,9 +219,14 @@ func (s *SmartPortInfoScanner) tryProbeList(probes []*Probe, usedProbes map[stri
|
||||
}
|
||||
usedProbes[probe.Name] = struct{}{}
|
||||
|
||||
probeData, err := DecodeData(probe.Data)
|
||||
if err != nil {
|
||||
continue
|
||||
// 优先使用预解码数据
|
||||
probeData := probe.DecodedData
|
||||
if probeData == nil {
|
||||
var err error
|
||||
probeData, err = DecodeData(probe.Data)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 TotalWaitMS 设置动态超时
|
||||
@@ -282,8 +287,15 @@ func (s *SmartPortInfoScanner) performSSLSecondStage(serviceInfo *ServiceInfo) *
|
||||
continue
|
||||
}
|
||||
|
||||
probeData, err := DecodeData(probe.Data)
|
||||
if err != nil || len(probeData) == 0 {
|
||||
probeData := probe.DecodedData
|
||||
if probeData == nil {
|
||||
var decErr error
|
||||
probeData, decErr = DecodeData(probe.Data)
|
||||
if decErr != nil || len(probeData) == 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if len(probeData) == 0 {
|
||||
continue
|
||||
}
|
||||
response := s.info.Connect(probeData)
|
||||
@@ -317,8 +329,15 @@ func (s *SmartPortInfoScanner) tryHTTPSProbe() *ServiceInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
probeData, err := DecodeData(probe.Data)
|
||||
if err != nil || len(probeData) == 0 {
|
||||
probeData := probe.DecodedData
|
||||
if probeData == nil {
|
||||
var decErr error
|
||||
probeData, decErr = DecodeData(probe.Data)
|
||||
if decErr != nil || len(probeData) == 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if len(probeData) == 0 {
|
||||
return nil
|
||||
}
|
||||
response := s.info.Connect(probeData)
|
||||
|
||||
Reference in New Issue
Block a user