DSH Plugins Marketplace

DSH Plugins

Plugins

/

dsh-url-router

S

dsh-url-router

Manifest valid

DSH Browser Traffic Splitting (V3.0): Domestic URLs use direct connection via Edge, while overseas URLs use Chrome + Clash to route through the fastest US node. This replaces the archived V1.0 dsh-chrome-only and V2.0 chrome-clash-link.

hasBundlePatchMachine translated

url-router — DSH 浏览器分流插件

在 DeepSeek Harness(DSH)里打开网页时,按网址归属分两个浏览器:

网址浏览器网络
国内可达(.cn、baidu、qq、bilibili…)Microsoft Edge直连,不碰代理
境外(github、google、youtube…)Google ChromeClash Verge + 最快美国节点

境外分支不是“把 Chrome 打开就完事”:插件会先确保 Clash Verge 在运行,对 🇺🇸US* / 🇺🇸PUS* 节点逐个测延迟,从快到慢切换 GLOBAL,并用真实出口 IP 复核国家,确认是美国才返回成功。

版本沿革

这个仓库是 DSH 浏览器方案的第三代。前两代都已归档,代码留着当历史,不再维护。

版本仓库解决什么状态
V1.0dsh-chrome-only所有浏览器跳转强制走 Google Chrome:工具 + shell 守卫 + 提示词规则 + dsh web 的 Chrome 交接已归档
V2.0chrome-clash-linkChrome 一打开就把 Clash 拉起来、开代理,同时尊重手动关闭已归档
V3.0dsh-url-router(本仓库)先判断网址归属再分流:国内 → Edge 直连;境外 → Chrome + Clash 最快美国节点 + 出口 IP 复核当前版本

三者是一条演进线,不是三个平行工具:

  • V1.0 回答了“怎么保证一定是 Chrome”——把 Start-Process <url>、start <url> 这类回落到系统默认浏览器的路子全堵掉,连 dsh web 的默认浏览器交接也换成 Chrome。代价是不分网址:国内站点也被塞进 Chrome。
  • V2.0 回答了“Chrome 打开时网络怎么办”——监听 Chrome 生命周期,自动拉起 Clash、开 TUN/系统代理。代价是它不知道什么时候不该开代理,也不知道该换哪个节点。
  • V3.0 把前两代的前提拆掉重装:先分类(域名表 → Clash DNS → GeoLite2 → DoH 兜底),国内网址根本不需要 Clash,交给 Edge 直连;只有境外网址才启动 Clash,并在美国节点里测速、复核真实出口 IP 之后再开 Chrome。V1.0 的“必须 Chrome”和 V2.0 的“开 Chrome 就连带 Clash”在这里都变成了有条件的动作。

chrome-only 插件如果还装在 profile 里,它注入的“只许 Chrome”规则会被本插件 order 1300 的提示段显式取代;不想留就把 bundle 从 profile 里去掉。

两条入口

  1. 模型侧工具(任务中打开网页、截图、OAuth 授权、给用户看结果) route_open / route_status / route_install_handler → 内部调用 scripts/Route-Url.ps1。
  2. 系统侧默认程序(用户自己在 DSH 界面点聊天外链) route_install_handler 把 HKCU\Software\Classes\ChromeHTML\shell\open\command 指向 scripts/Route-Url.vbs,点击外链也走同一套分流。DSH 本身不选浏览器,它把链接交给系统 http/https 关联,所以这是唯一能拦截聊天外链的层面。

安装(作为 DSH bundle)

git clone https://github.com/SeekAfterSeek/dsh-url-router.git
cd dsh-url-router
copy config.example.json config.json     # 按本机情况改路径 / secret
# 下载 data/Country.mmdb,见 data/README.md

vendor/maxminddb 已经 vendored,不需要额外安装。如果 classifier.py 报 import maxminddb 失败,补一次:

python -m pip install maxminddb --target vendor

然后让 DSH 装上这个目录:

plugin_manager install_bundle target="<clone 出来的 url-router 目录>"

或在桌面 profile 的 package.json 里加 link: 依赖并追加到 dsh.profile.bundles。插件行 id:include:url-router(改配置/重载用 set_plugin)。

安装后注册:

  • 系统提示段 url-router:browser-routing-rule,order 1300(高于 chrome-only 的 1200,文本里明确声明取代旧规则)。
  • 三个工具(见下)。
  • 插件不会自动改注册表;默认程序 handler 需要显式 route_install_handler。

工具

route_open({ url, foreground? })

打开一个网址,返回一行 JSON。url 支持 http/https 绝对地址、裸域名(github.com)、本地文件路径 / file://。

  • 默认后台打开(最小化,不抢焦点);foreground: true 才留在前台(截图、OAuth 登录、需要用户当场操作)。
  • 国内 → Edge 新窗口;境外 → 确保 Clash → 选节点 → 验出口 IP → Chrome 新窗口。
  • 本地 HTML/文件 → 直接 Chrome(verdict: "local"),不分类。
  • 返回字段:verdict(domestic/foreign/local)、browser、reason、node、delayMs、exitIp、exitCountry、pid、note、ok。

route_status({ url? })

  • 传 url:只分类、不打开,告诉你“会走哪个浏览器、为什么”(domestic-domain:baidu.com 这类 reason)。
  • 不传:报告 Chrome/Edge 可执行文件是否存在、Clash 进程与 API 状态、默认程序 handler 是否已安装、以及生效配置。

route_install_handler({ action })

  • install:把 ChromeHTML\shell\open\command 写成 wscript.exe //nologo "<vbs>" "%1",并把原值备份到 state/handler-backup.json。
  • uninstall:恢复备份里原来的命令(通常是 Chrome 的 --single-argument %1)。
  • status:只读。

.html 的 UserChoice 也指向 ChromeHTML,所以这一个键同时覆盖 http、https、.html。

分类规则(classifier.py)

  1. 域名后缀表:.cn、.com.cn 等 → 国内。
  2. 域名表:DOMESTIC_DOMAINS(baidu/qq/taobao/bilibili/zhihu/gitee…)、FOREIGN_DOMAINS(google/github/youtube/openai…)→ 直接判定。
  3. 拿不准:向 Clash 的 /dns/query 要解析结果(Authorization: Bearer <secret>),失败则用系统解析器;把 IP 丢进 data/Country.mmdb 查国家,CN → 国内,其他 → 境外。
  4. 解析出的是保留地址(尤其 Clash 的 fake-ip 198.18.0.0/15)说明没有国家信息,会依次退到系统解析、再退到 DoH(AliDNS → Cloudflare)拿真实 IP,然后再查 mmdb。
  5. 彻底解析不了:按境外处理(宁可多开 Clash,也不让境外站点在直连下打不开)。

注意:开着 TUN 时本机 UDP:53 会被 Clash 劫持并回 fake-ip,所以第 4 步的 DoH 是拿到真实 IP 的唯一途径——这也是“不在域名表里的国内站点”能被判成国内的原因(例如 douban.com、smzdm.com 走 ip-country:CN)。

vendor/maxminddb(3.2.0)是 vendored 的纯 Python 读库;data/Country.mmdb 需要自己下载一份,来源见 data/README.md。

配置(config.json)

键说明
chromePath / edgePath两个浏览器的可执行文件;route_status 会检查是否存在
pythonPath跑 classifier.py 的解释器(需要能 import maxminddb)
clashApiUrl / clashApiSecretClash 外部控制器,默认 http://127.0.0.1:9097 + Bearer secret
clashExecutableClash Verge 主程序;找不到时脚本还会查注册表 DisplayIcon
clashProcessNames判断“Clash 是否在跑”的进程名列表
clashStartTimeoutSeconds冷启动等待 /version 的上限
nodeTimeoutMs单个节点延迟测试超时
verifyExitIp是否用真实出口 IP 复核美国(关掉会快,但可能选到落地不在美国的节点)
delayTestUrl测速目标,默认 http://www.gstatic.com/generate_204
background默认后台最小化打开
logFile / logMaxKB每次分流的一行 JSON 日志,超过上限自动截断

插件侧的 scriptPath / installerPath / powershellPath / timeoutMs / ruleOrder / ruleEnabled 可以用 profile 的 - id: url-router 配置覆盖。

已知限制

  • 节点命名:只认名字里带 🇺🇸、US<n>、PUS<n> 的节点;订阅换了命名要改 Get-UsNodes 的过滤正则。
  • 出口 IP 复核依赖外网:api.ipify.org 走系统代理失败时会退到 ifconfig.me 和直连;全失败时返回 EXIT_NOT_US (ip= country=),仍会打开 Chrome,但 note 会写明没验证成功。
  • GLOBAL 会被切换:选择节点用的是 PUT /proxies/GLOBAL,如果你在 Clash 里手动选了别的组/节点,后续 route_open 会覆盖它。
  • Chat 外链:只有装了默认程序 handler 才走分流;卸载后回到“Chrome 直接打开”。Electron 的 shell.openExternal 在 DSH 主进程里,插件进程够不到,所以只能从注册表层拦。
  • chrome-only 的 guard 仍在:它会拒绝 shell 里的 start <url> 这类命令;route_open 不走 guard,所以不受影响。但如果你把 chrome-only 的 guardShellTools 保持开启,别用 shell 直接开 Edge,用 route_open。
  • 只支持 Windows(PowerShell 5.1 + 注册表 + wscript)。

文件布局

url-router/
├── index.js                 # Cordis 插件:3 个工具 + 系统提示段
├── cordis.patch.yml         # bundle 插入行
├── package.json             # @local/dsh-url-router
├── config.json              # 本机配置(不入库,从 config.example.json 复制)
├── config.example.json      # 配置模板
├── classifier.py            # 域名 + DNS + mmdb 国家判定
├── data/Country.mmdb        # GeoLite2 Country
├── vendor/maxminddb/        # vendored 读库
├── scripts/
│   ├── Route-Url.ps1        # 分流主脚本(需要 UTF-8 BOM)
│   ├── Route-Url.vbs        # 无窗口启动器(ASCII,无 BOM)
│   └── Install-Handler.ps1  # 默认程序 handler 安装/卸载(需要 UTF-8 BOM)
└── state/
    ├── router.log           # 一行一次分流
    └── handler-backup.json  # 注册表原值备份

排障

# 只分类
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/Route-Url.ps1 -Url https://github.com -ClassifyOnly

# 只探测 Clash
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/Route-Url.ps1 -ProbeOnly

# 完整分流(前台窗口)
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/Route-Url.ps1 -Url https://github.com -Foreground

# 最近的日志
Get-Content state/router.log -Tail 20

PowerShell 5.1 会把无 BOM 的 UTF-8 中文注释按 ANSI 解码,导致 Try statement is missing its Catch or Finally block 这类假语法错误——改 Route-Url.ps1 / Install-Handler.ps1 后确认文件头是 EF BB BF。Route-Url.vbs 相反,必须保持无 BOM 的 ASCII。

Comments

Loading…

Similar plugins

dsh-browser-ops

by dcd887

Self-managed persistent browser for DSH automation — launches its own Chrome/Edge profile, navigates, switches tabs, snapshots with semantic refs, acts by ref, evaluates JS, screenshots, and uploads f

Tools & CapabilitiesManifest valid

★ 0

MIT

JavaScript

Nov 10, 2026

dsh plugin --profile web add @local/browser-ops8

by Yidien

dsh 外挂式网络路由插件:按域名勾选走本地代理(Clash 等),其余直连;内置嗅探,设置页勾选即生效。

Manifest valid

★ 0

↓ 144/wk

TypeScript

Nov 3, 2026

dsh plugin --profile web add dsh-host-router

by B1aZerr

Runtime network switch for DeepSeek Harness: flip Harness's own outbound traffic between a local Clash Verge proxy and direct/LAN without restarting, from a status chip in the session header, the network_mode agent tool and the /net command.

Terminal & ClientsManifest valid

★ 0

MIT

JavaScript

Oct 10, 2026

dsh plugin --profile web add dsh-net-switch

by flymysql

DSH host-side bridge for the DSH Browser Client extension: a token-authenticated /ext-api RPC proxy + /ext-events.mux WebSocket event stream + bidirectional /ext-api-control channel, so a browser extension page (which cannot pass the same-origin /api trust fence) can drive the harness from a floating panel and operate the current page via page_* tools.

Tools & CapabilitiesManifest valid

★ 0

MIT

JavaScript

Sep 21, 2026

dsh plugin --profile web add dsh-browser-host

by stuarthu

DeepSeek Harness (dsh) browser companion: Chrome side panel embedding the full dsh web UI + host plugins for page reading, HTTP capture, and browser control.

Tools & CapabilitiesManifest valid

★ 13

↓ 358/wk

MIT

JavaScript

Aug 22, 2026

dsh plugin --profile web add dsh-chrome

by dawsondx

DeepSeek Harness (dsh) bundle: when `dsh web` is ready, print the full GUI URL and open it in your default browser. Cross-platform, zero runtime deps, fail-safe.

Manifest valid

★ 3

↓ 28/wk

MIT

JavaScript

Aug 15, 2026

dsh plugin --profile web add @dawsondx/dsh-web-open