mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 20:21:52 +08:00
feat: 统一服务缓存 + 指纹驱动插件匹配
将 webServiceCache 扩展为通用 serviceCache,所有指纹识别结果 统一缓存,插件匹配时端口不命中则回退到服务名称匹配。 删除多余的 service_cache.go,复用已有的 ServiceInfo 体系。 补充 nil 防御、Explicit 标记、大量单元/集成/回归测试。
This commit is contained in:
@@ -2,10 +2,10 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -97,6 +97,10 @@ func (p *NetworkProfile) RecommendConcurrency(userThreadNum int, explicit bool)
|
||||
// probePorts 探测用的端口列表(高响应率的常见端口)
|
||||
var probePorts = []int{80, 443, 22}
|
||||
|
||||
func networkProbeAddress(host string, port int) string {
|
||||
return net.JoinHostPort(host, strconv.Itoa(port))
|
||||
}
|
||||
|
||||
// ProbeNetwork 探测目标网络环境
|
||||
// 从 hosts 中抽样,用低并发 TCP 连接测量 RTT 和丢包率
|
||||
// 整个过程控制在数秒内完成
|
||||
@@ -140,7 +144,7 @@ func ProbeNetwork(ctx context.Context, hosts []string, session *common.ScanSessi
|
||||
go func(h string, p int) {
|
||||
defer func() { <-sem; wg.Done() }()
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", h, p)
|
||||
addr := networkProbeAddress(h, p)
|
||||
start := time.Now()
|
||||
conn, err := session.DialTCP(ctx, "tcp", addr, probeTimeout)
|
||||
rtt := time.Since(start)
|
||||
|
||||
Reference in New Issue
Block a user