Repository navigation
fix(discovery): 移除本机临时端口区间扫描 - #17
Merged
Merged
Conversation
自动发现原本在信标全部落空后还会扫一遍平台临时端口区间(Windows/macOS 16384 个、Linux 28232 个端口),用来兼容没有发现信标的旧宿主。现在插件与 扩展一体安装、旧宿主的混搭场景很窄,这条兜底路径代价明显更大,因此移除: - 删除 port-scan.ts(区间、并发、超时与扫描上限常量)及其用例; - discovery.ts 只保留固定端口组(上次地址 → 常用端口 → 信标端口), 进度改为按组上报; - 面板文案从「扫描」改为「探测」,实例来源去掉 scan; - README 中英同步去掉临时端口区间扫描的描述。
# Conflicts: # README.i18n.yaml
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.
概述 / Summary
自动发现不再扫描本机临时端口区间:面板只探「上次成功的地址 →
dsh web默认端口 → 插件的固定信标端口(43189–43198)」,未命中即报「未找到服务」。Auto-detect no longer sweeps the platform's ephemeral port range; discovery only probes the remembered URL, the
dsh webdefaults, and the plugin's fixed beacon ports (43189–43198).动机 / Motivation
原来的自动探测在信标端口全部落空后,还会把平台临时端口区间整个扫一遍(Windows/macOS 16384 个端口、Linux 28232 个),用来兜底「扩展已升级、桥插件仍是旧版本(没有发现信标)」的混搭环境。这条兜底路径的代价是:面板打开却没有任何服务时要做上万次本地 TCP 探测(上限 20 s),在企业环境里也容易被安全软件当成端口扫描。
现在插件与扩展由同一个安装脚本一起安装,桥插件默认发布固定端口信标,混搭场景已经很窄,因此移除该兜底,让探测路径变成一次有界探测(14 个端口以内)。
改动内容 / Changes
extensions/dsh-browser/src/background/port-scan.ts(区间定义、并发/超时/扫描上限常量、端口展开);background/discovery.ts只保留固定端口组,去掉sweep计划与扫描实现;进度改为「首探前 + 每组完成后」上报;background/index.ts去掉port-scan引用、platformOs/ensurePlatformOs与两处sweepPorts;detectScanning→detectProgress),实例来源类型去掉scan;tests/port-scan.spec.ts;tests/background-discovery.spec.ts改用例为固定端口组语义(首组命中即停、跨组枚举合并来源、按组进度、按组取消、全静默空结果);测试 / Testing
真机手测(macOS 26 / Chrome 153,扩展以「已解压扩展」加载):
~/.dsh/browser-extension后在chrome://extensions重新加载;ws://127.0.0.1:<随机端口>/ext/bridge),来源标签仅「固定端口 / 信标」,不再出现「扫描」。影响范围 / Impact
changelog
CHANGELOG.md:* 2026-10-21 [Refactor] Auto-detect no longer sweeps the local ephemeral port range.CHANGELOG.zh-CN.md:* 2026-10-21 [Refactor] 侧栏自动发现不再扫描本机临时端口区间。Checklist
pnpm run build/bash -n scripts/install.sh等基础检查 / Passed basic checks