reactive-resume
reactive-resume
A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
JerryLingWuQ/dsh-traffic-guard
A byte-budget gate for agents on metered proxies: direct-first, stall-triggered proxy, hard per-call/per-day caps, per-hop redirect checks, local ledger. Cross-platform (macOS/Linux/Windows). DeepSeek Harness plugin + standalone CLI.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:JerryLingWuQ/dsh-traffic-guard
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A byte-budget gate for metered proxies for DeepSeek Harness (dsh). Agent downloads go direct by default; the local proxy is used only when a direct attempt actually stalls, and every proxied byte is charged against a hard per-call / per-day budget and written to a local ledger.
One CLI (netguard, usable standalone) + one Host plugin exposing three tools:
net_usage, net_probe, net_download.
中文: README.zh.md
When your egress is metered (a paid proxy plan, a mobile hotspot, a corporate gateway), traffic is money. Agents make that easy to lose:
curl -O, git clone or pip install can be hundreds of MB;dsh-traffic-guard turns this into one auditable policy: direct first → escalate only on stall →
hard budget → everything logged.
| Layer | Behaviour |
|---|---|
| Routing | Direct by default. Only hosts in proxy_hosts may use the proxy, and only after a direct attempt fails / returns zero bytes / reads too slowly. The proxy is discovered from the OS (scutil --proxy on macOS, NETGUARD_HTTP_PROXY elsewhere); no hardcoded port. |
| Budget | Proxied calls are capped per call (default 128 MiB) and per day (default 300 MiB). Exceeding either is a hard failure (exit 3); only --force overrides. Direct traffic is free and not charged. |
| Redirects | Automatic following is disabled and every hop is re-evaluated (borrowed from SSRF-guard plugins): a redirect from a proxy host to a direct host is re-decided, not blindly proxied. |
| Pre-checks | If Content-Length already exceeds the call budget, nothing is downloaded; while streaming, bytes are counted and the read is aborted on overflow. |
| Timeouts | One max_time budget for the whole redirect chain, so N hops cannot multiply the wait. |
| Ledger | One JSONL row per call: timestamp, URL, host, route, bytes, duration, outcome, matched rule. report aggregates by day and host. |
| Fail cache | A host that recently failed direct repeatedly skips the direct attempt next time, saving the 8 s stall each call. |
dsh plugin --profile <profile> add github:<you>/dsh-traffic-guard
or install the checkout as a local bundle with plugin_manager (action: install_bundle,
target: <absolute path to this repository>). The plugin has no dsh dependencies (Node builtins only),
so a linked package works.
Tools exposed to the model: net_usage, net_probe, net_download.
It is not tied to one proxy vendor. Neither the plugin nor the CLI contains vendor-specific code;
dsh-traffic-guard only needs a local HTTP/HTTPS proxy and a metered plan. Any client that exposes an
HTTP proxy port works — Clash/mihomo, Surge, Stash, sing-box, V2Ray, a corporate egress gateway, or an SSH
tunnel bridged to HTTP. The optional status line that reads a local client's /status endpoint is a
nicety: when no such endpoint exists it is simply skipped.
The author's client-side split-routing rules are not part of this repository — routing policy inside a closed-source client is a different problem, and no vendor formats or keys are shipped here.
| Priority | Source | Notes |
|---|---|---|
| 1 | config.proxy.url |
e.g. "http://127.0.0.1:7890" — most explicit, works everywhere |
| 2 | NETGUARD_HTTP_PROXY env |
Same format; good for CI and per-shell overrides |
| 3 | OS detection | macOS scutil --proxy; Windows WinINET registry; GNOME gsettings |
SOCKS-only clients are not supported by Python's urllib; use the client's HTTP proxy port (most clients
expose one) or a local HTTP→SOCKS bridge.
Python >= 3.9, Node >= 18.17, dsh
+ a local HTTP proxy port
+ host lists edited for the new network (proxy_hosts / direct_hosts)
~/.dsh/netguard/ledger.jsonl) is per machine; copy it along if you want history to continue.netguard only; the OS and the proxy client still apply their own limits.config.proxy.url when in doubt.export NETGUARD_HOME=~/.dsh/netguard # optional, this is the default
cp cli/config.example.json "$NETGUARD_HOME/config.json"
python3 cli/netguard.py status
python3 cli/netguard.py probe https://github.com/
python3 cli/netguard.py dl https://example.com/file.zip -o /tmp/file.zip
python3 cli/netguard.py report --days 7
Exit codes: 0 ok, 3 budget/size refused, 4 network failure, 5 proxy needed but unavailable.
$NETGUARD_HOME/config.json (default ~/.dsh/netguard/config.json); see
cli/config.example.json.
{
"route": {
"proxy_hosts": ["github.com", "*.githubusercontent.com", "huggingface.co"],
"direct_hosts": ["*.deepseek.com", "*.npmmirror.com", "*.aliyun.com"]
},
"budget": { "per_call": 134217728, "per_day": 314572800 }
}
proxy_hosts are hosts allowed to use the proxy when direct stalls (not "must use proxy").
direct_hosts are hosts that never use the proxy and take precedence.
The ecosystem already has egress-security plugins; this one is about budget and accounting:
| Project | Focus | What we borrowed |
|---|---|---|
| JackZo400/dsh-netguard | SSRF guard: resolve and check every IP, re-check every redirect hop, stream with a byte cap, pre-check Content-Length |
Per-hop redirect re-evaluation, Content-Length pre-check, whole-chain timeout |
| CharlotteN7/dsh-netguard | Host allowlist for web_fetch/web_search, pre-execute destination checks, audit-first mode |
Audit-first framing (record first, constrain only proxy spend) |
| wtdwang/dsh-tool-netguard | Split "egress" vs "ingress", tools/pre-execute + ctx.approval |
Possible future "ask before over-budget" gate |
| MukundaKatta/resilient-agent | Retries, circuit breaker, USD budget, egress allowlist, audit trace | Independent validation that budget + audit compose |
If you need SSRF / exfiltration protection, use those; this repo keeps you from burning a metered plan.
ctx.approval before exceeding the budget instead of failing hardnetguard (HTTP/HTTPS proxies only today)web_fetch provider replacement (needs handling of WEB_PROVIDER_AMBIGUOUS)node --check + manifest JSON check)dsh plugin add dsh-traffic-guard worksnetguard. Bypassing calls
(curl, git clone, app auto-updaters) are not stopped, though they show up in system/plan totals.--force overrides it, and other
processes can still use the same proxy.scutil --proxy; Linux/Windows via NETGUARD_HTTP_PROXY.python3 -m unittest discover -s test -v # 10 tests, all against a local 127.0.0.1 server
node --check index.mjs
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: proxy。