fix: 修复高并发下自适应超时过低导致开放端口漏扫#597
Closed
fyihang wants to merge 1 commit into
Closed
Conversation
扫描本机/低 RTT 目标时,AdaptiveTimeout 在 10 次采样后迅速收敛到 100ms 下限。高并发(600+ 线程)下 TCP 握手尾延迟可能超过 100ms,加上超时错误不会重试,导致开放端口被误判为关闭。 - AdaptiveTimeout 下限从 100ms 提升至 max(500ms, maxTimeout/5) - connectWithRetry 对超时错误用完整超时重试一次 - slidingWindowSchedule 任务丢弃时记录日志,便于排查漏扫
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Issue #503 反映 fscan 2.x 扫描本机时部分端口漏扫,而 1.8.4 不存在此问题。
原因
2.x 引入的 AdaptiveTimeout(自适应超时)在高并发场景下下限过低:
修复
1. 提高自适应超时下限(core/adaptive_timeout.go)
minTO 从固定 100ms 改为 max(500ms, maxTimeout/5):
2. 超时错误重试(core/port_scan.go)
connectWithRetry 新增 fallbackTimeout 参数,连接超时时用完整超时再试一次,避免自适应超时过低导致误判。
3. 任务丢弃日志(core/port_scan.go)
slidingWindowSchedule 中 pool.Invoke 失败不再静默丢弃,改为记录日志和总计统计,方便排查漏扫。
测试
全部测试通过,包括自适应超时收敛测试验证新下限工作正常:
TestReal_AdaptiveTimeout_Convergence: 3s -> 600ms (20 samples)
TestIntegration_DualRTTTracking: AdaptiveTO=600ms, Ratio=1.00
Closes #503