DSH HUB
首页插件商店插件包社区排行榜资源发布指南
插件源码
返回插件目录

31guzhou /

31guzhou/dsh-vpn-watchdog

已验证

DSH 侧栏面板:把 proxy-watchdog(Windows / macOS)的启动、停止、查流量、恢复网络、带代理运行、提交推送搬到 GUI。0 token,纯本地。

★ 1 Stars0 Forks0 IssuesN/A 社区评分0 已确认安装
查看 GitHub
README来源: main@2405949d

dsh-vpn-watchdog

中文

DeepSeek Harness(DSH)侧栏里的一个面板:把 proxy-watchdog 的日常操作(启动、停止、查流量、恢复网络、带代理运行、提交推送)从命令行搬进 GUI。 只做 Windows 与 macOS。

  • 0 token:不注册任何 agent 工具、不往 system prompt 写东西,模型上下文里看不到它。
  • 纯本地:只监听本机回环,只跑本机脚本,不发任何外部请求。
  • 不改看门狗:proxy-watchdog 里的 .cmd / .ps1 / watchdog.py 一个字都不动,命令行照旧可用。

English

A panel in the DeepSeek Harness (DSH) sidebar that moves the daily operations of proxy-watchdog — start, stop, traffic, restore network, run with proxy, commit-and-push — out of the terminal and into the GUI. Windows and macOS only.

  • Zero tokens: no agent tool is registered and nothing is added to the system prompt.
  • Local only: it listens on loopback, runs local scripts, and makes no outbound requests of its own.
  • The watchdog is untouched: no file inside proxy-watchdog is modified; the CLI keeps working.

面板做什么 / What the panel does

中文

操作 Windows macOS
启动看门狗 start-silent.ps1:CREATE_NO_WINDOW 拉起,不弹控制台;单实例互斥体防重复;最多等 180 秒到中转口就绪 python3 mac/watchdog.py:detached 后台拉起,轮询中转口
停止看门狗 stop-watchdog.ps1 -NoPause:优雅退出失败则按 PID + 命令行特征强杀,顺便还原系统代理 python3 watchdog.py --stop
查流量 traffic.ps1 -NoPause:机场额度 + 本机记账 python3 watchdog.py --traffic:只有本机记账
恢复网络 restore-network.ps1:只修系统代理,不动进程 python3 watchdog.py --repair-network
提交推送 git add / commit(有变更才提交)/ push(中转优先,失败回退直连) 同左
带代理运行 cmd /c <命令>,附 HTTP(S)_PROXY=http://127.0.0.1:17890 /bin/sh -lc <命令>,环境变量同上

除了按钮,面板还画三个东西:

  • 状态灯:看门狗在跑 / 已停止 / 正在执行某个动作,附中转口、守护进程 PID、上次动作结果;
  • 用量图:今日与累计流量、按小时用量、14 天热力、延迟与吞吐曲线(数据来自 logs/watchdog_*.log 的状态行);
  • 输出区:动作的实时 stdout/stderr,最后 50 行,够了就滚掉。

English

Action Windows macOS
Start start-silent.ps1: spawns through CREATE_NO_WINDOW, so no console flashes; the single-instance mutex prevents doubles; waits up to 180 s for the relay port python3 mac/watchdog.py: detached in the background; polls the relay port
Stop stop-watchdog.ps1 -NoPause: force-kills by PID plus command-line signature when a graceful exit fails, and restores the system proxy on the way python3 watchdog.py --stop
Traffic traffic.ps1 -NoPause: provider quota plus local accounting python3 watchdog.py --traffic: local accounting only
Restore network restore-network.ps1: the system proxy only, processes untouched python3 watchdog.py --repair-network
Commit & push git add / commit (only when something is staged) / push (relay first, direct fallback) same
Run with proxy cmd /c <command> with HTTP(S)_PROXY=http://127.0.0.1:17890 /bin/sh -lc <command>, same variables

Next to the buttons the panel draws three things: a status light (running / stopped / busy, plus relay port, guard PID and the last action's result), usage charts (today and total traffic, hourly usage, a 14-day heat map, latency and throughput curves — all parsed from the watchdog's own status lines), and an output pane with the last 50 lines of stdout/stderr.

环境要求 / Requirements

中文

  • DSH 桌面端或 dsh web(面板是 web 客户端插件);
  • proxy-watchdog 的一份克隆(Windows 里含 watchdog.ps1,macOS 里含 mac/watchdog.py);
  • Windows:PowerShell 5.1(系统自带);macOS:python3(系统自带);
  • Node.js ≥ 22.5(DSH 自带运行时即可)。

English

  • DSH desktop, or dsh web (the panel is a web client plugin);
  • a clone of proxy-watchdog (with watchdog.ps1 on Windows, mac/watchdog.py on macOS);
  • Windows: PowerShell 5.1 (built in); macOS: python3 (built in);
  • Node.js ≥ 22.5 (the runtime DSH already ships is fine).

安装 / Install

中文

  1. 在 profile 的 package.json 里加依赖(file: 指向你 clone 的插件目录):

    "@local/dsh-vpn-watchdog": "file:D:/tools/dsh-vpn-watchdog"
    
  2. 装一次。file: 依赖是复制进 node_modules,改完源码要重装:

    # Windows,用 DSH 自带的 pnpm
    & D:\tools\node\node.exe "$env:USERPROFILE\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\pnpm\bin\pnpm.mjs" install --dir "$env:USERPROFILE\.dsh\profiles\desktop"
    
    # macOS
    pnpm install --dir ~/.dsh/profiles/desktop
    
  3. 启用 bundle:plugin_manager → set_bundle → @local/dsh-vpn-watchdog → enabled: true(写进 dsh.profile.bundles 并热加载)。

  4. 浏览器 Ctrl+R,侧栏出现「看门狗 / Watchdog」。

English

  1. Add the dependency to the profile's package.json, with file: pointing at your clone of this repository.
  2. Install once — a file: dependency is copied into node_modules, so reinstall after changing the source (either command above).
  3. Enable the bundle through plugin_manager → set_bundle → @local/dsh-vpn-watchdog → enabled: true.
  4. Press Ctrl+R in the browser; the sidebar shows 「看门狗 / Watchdog」.

找仓库、读配置 / Finding the repo, reading the config

中文

  • 仓库位置按顺序找:VPN_WATCHDOG_ROOT → 常见克隆路径(Windows:D:\all\1-vpn、%USERPROFILE%\proxy-watchdog、…\Documents\proxy-watchdog;macOS:~/proxy-watchdog、~/code/…、~/src/…、~/Documents/…)。判据是那个标记文件在不在。
  • 中转口不写死:先读 config.json,再叠加 config.local.json(和看门狗自己的合并规则一致,深层覆盖),所以改了 relay_port 面板会跟着变。
  • 脚本目录 = 仓库目录(Windows)/ 仓库的 mac/(macOS);状态与日志在各自的 state/、logs/。
环境变量 作用
VPN_WATCHDOG_ROOT 指定仓库根(优先于自动探测;写仓库根,不是 mac/)
VPN_WATCHDOG_PYTHON macOS 上的 python3 可执行文件(DSH 从 launchd 启动时 PATH 可能很窄)
VPN_WATCHDOG_GIT git 可执行文件

English

  • The repo is located by VPN_WATCHDOG_ROOT, then a list of common clone paths (see above); the marker file decides.
  • The relay port is not hard-coded: config.json is read, then config.local.json is layered on top (the same deep merge the watchdog performs), so a changed relay_port is picked up.
  • The script directory is the repo (Windows) or the repo's mac/ (macOS); state and logs live in the matching state/ and logs/.
  • Environment overrides: VPN_WATCHDOG_ROOT (repo root, not mac/), VPN_WATCHDOG_PYTHON (macOS python3), VPN_WATCHDOG_GIT (git binary).

它怎么判断"在跑" / How "running" is decided

中文

只看两件事,不看进程名:

  1. 配置里的中转口(默认 127.0.0.1:17890)是否在监听;
  2. state/guard.pid 里那个异常退出守护是否还活着。

任意一条成立就算运行中。进程名和端口单看都会误报:命令行里带 watchdog.ps1 的 shell、或者残留的"幽灵端口",都会让"正在运行"变成假阳性。

English

Two signals, never the process name:

  1. whether the configured relay port (default 127.0.0.1:17890) is listening;
  2. whether the exit guard recorded in state/guard.pid is still alive.

Either one counts as running. Process names and the port alone both produce false positives — a shell whose command line contains watchdog.ps1, or a leftover "ghost listener", would claim the watchdog is up when it is not.

接口 / Routes

方法 路径 作用
GET /api/vpn-watchdog/status {running, relay, port, guardPid, guardAlive, busy, last, platform, repo, root, mode}
GET /api/vpn-watchdog/output {lines, total},最近 50 行
GET /api/vpn-watchdog/metrics 延迟 / 吞吐 / 每日与小时用量 / 余额历史
GET /api/vpn-watchdog/log ?count=30,看门狗自己 logs/watchdog_*.log 的尾部
POST /api/vpn-watchdog/action {action: start|stop|restore|traffic}
POST /api/vpn-watchdog/push {message},提交并推送看门狗仓库
POST /api/vpn-watchdog/run {command},带代理执行一条命令

所有路由只接受本机同源请求:回环地址 + Sec-Fetch-Site / Origin 校验,跨站请求一律 403。 Every route accepts local same-origin requests only (loopback plus Sec-Fetch-Site / Origin); anything cross-site gets a 403.

设计取舍 / Design notes

中文

  • 为什么 Windows 启动要另写 start-silent.ps1:cmd /c start 和 -WindowStyle Hidden 在 Windows Terminal 下都会开窗;只有 CreateProcessW + CREATE_NO_WINDOW(外加 CREATE_BREAKAWAY_FROM_JOB 尝试脱离调用方作业对象)能真正做到无窗口。作业不允许 breakaway 时自动回退成只带 CREATE_NO_WINDOW。
  • 为什么 macOS 用 detached:Mac 上没有"窗口"这个概念,spawn(..., {detached:true}) + unref() 起完就与面板解绑,DSH 重启也不会把看门狗一起带走。
  • 为什么"先应答再跑":启动要等 20~180 秒,POST /action 立刻回 202,面板轮询 /status 与 /output,长动作不占着 HTTP 请求;同时只允许一个动作,重复点击 409。
  • 为什么图表要解析日志:看门狗只在 logs/watchdog_YYYYMMDD.log 里写状态行,面板不去问内核 API,离线也能画历史。跨天的日志文件里会出现第二天的行,所以日期按"今日计数回落"推断,不能拿文件名当行日期。
  • 为什么 file: 依赖要重装:pnpm 对 file: 是复制不是软链,源码改了不会自动同步。

English

  • Why Windows needs its own start-silent.ps1: under Windows Terminal both cmd /c start and -WindowStyle Hidden still open a window; only CreateProcessW with CREATE_NO_WINDOW (plus CREATE_BREAKAWAY_FROM_JOB to escape a KILL_ON_JOB_CLOSE job, when the job allows it) is truly windowless.
  • Why macOS uses detached: macOS has no "window" to hide; spawn(..., {detached:true}) + unref() leaves the watchdog running independently of the panel and of DSH restarts.
  • Why actions acknowledge first: a start can take 20–180 s, so POST /action returns 202 immediately and the panel polls /status and /output; one action at a time, the second click gets a 409.
  • Why the charts parse logs: the watchdog publishes its state as status lines in logs/watchdog_YYYYMMDD.log; the panel reads those instead of querying the core API, so history works offline. A log file can span midnight, so the date is inferred from the "today" counter dropping to zero rather than from the file name.
  • Why file: dependencies need a reinstall: pnpm copies them into node_modules, it does not symlink.

已知限制 / Known limitations

中文

  • macOS 分支没有在真机上跑过:本仓库的 macOS 支持只做过语法、路径、配置与路由层面的验证;第一次在 Mac 上用,建议先看输出区。
  • 余额历史只有 Windows 会增长:查流量 在 macOS 上只给本机记账,机场额度查询没移植。
  • host 侧改动要重启 DSH(或重新启用 bundle);只改 client.js 刷新页面即可。
  • 图表只认 watchdog_YYYYMMDD.log:看门狗日志保留 7 天,所以图表最长 14 天只是理论上限。
  • 改 relay_port 后要重新加载插件:端口在插件启动时读一次。

English

  • The macOS branch has not run on real hardware: it was verified at the syntax, path, config and route level only; on a first Mac run, watch the output pane.
  • Quota history only grows on Windows: traffic on macOS reports local accounting only.
  • Host-side changes need a DSH restart (or a bundle re-enable); client.js-only changes just need a page refresh.
  • Charts only read watchdog_YYYYMMDD.log: the watchdog keeps 7 days of logs, so the 14-day range is a ceiling.
  • Changing relay_port needs a plugin reload: the port is read once at startup.

常见问题 / Troubleshooting

中文

现象 处理
侧栏没有「看门狗」 profile 的 bundles 里有没有 @local/dsh-vpn-watchdog;cordis.patch.yml 在不在安装目录里
面板显示"找不到看门狗仓库" 设 VPN_WATCHDOG_ROOT 指向 clone 目录;Windows 要有 watchdog.ps1,macOS 要有 mac/watchdog.py
点了启动,输出区没动静 看 logs/watchdog_*.log(面板 /log 也能看);Windows 上确认 17890 没被别人占
状态灯一直"已停止",但进程在 端口可能被改过 → 面板读的是 config.json + config.local.json 的 relay_port
停止/恢复点了没反应 输出区有 [exit 1] 就是脚本自己失败,按看门狗仓库的 TROUBLESHOOTING.md 排查

看门狗本身的问题(选边、节点、Sakura 502、系统代理)不在这个仓库:见 proxy-watchdog/TROUBLESHOOTING.md 与 PITFALLS.md。

English

Symptom What to do
No 「看门狗」 entry in the sidebar Check dsh.profile.bundles for @local/dsh-vpn-watchdog, and that cordis.patch.yml exists in the installed directory
The panel says it cannot find the watchdog repo Set VPN_WATCHDOG_ROOT to the clone; it needs watchdog.ps1 (Windows) or mac/watchdog.py (macOS)
Start clicked, output stays empty Read logs/watchdog_*.log (the panel's /log shows it too); on Windows make sure nothing else holds the relay port
Status says "stopped" while the process is alive The port may have been changed — the panel reads relay_port from config.json plus config.local.json
Stop or restore seems to do nothing [exit 1] in the output means the script itself failed; see the watchdog repo's TROUBLESHOOTING.md

Problems inside the watchdog (side selection, nodes, Sakura 502, system proxy) belong to the other repository — see proxy-watchdog/TROUBLESHOOTING.md and PITFALLS.md.

版本与兼容 / Version and compatibility

中文

版本 变更
1.1.0 加 macOS(mac/watchdog.py 子命令)、中转口从 config 读、仓库位置可用环境变量覆盖;README 重写
1.0.0 首版,只做 Windows

面板依赖看门狗的状态行格式(探测 … | 吞吐 … | … | 今日 C …)和 state/guard.pid。看门狗 v3.10(Windows)/ mac v0.1 是当前验证过的组合;格式大改时图表会失灵,但按钮仍然可用。

English

Version Changes
1.1.0 macOS support (mac/watchdog.py subcommands), relay port read from config, repo location overridable, rewritten README
1.0.0 first release, Windows only

The panel depends on the watchdog's status-line format and on state/guard.pid. The verified pairing is watchdog v3.10 (Windows) / mac v0.1; if the format changes the charts go blank while the buttons keep working.

许可证 / License

MIT,见 LICENSE。看门狗本体在 31guzhou/proxy-watchdog。 MIT — see LICENSE. The watchdog itself lives at 31guzhou/proxy-watchdog.

—/ 5

暂无评分

已验证 DSH bundle

Commit 2405949d6de3

社区评论

还没有评论,来写第一条。

DSH HUB

社区维护的 DSH 插件索引。不是 GitHub 或 DeepSeek AI 的官方产品。

社区资源API关于