dsh-proxy-router: DSH direct-connection priority and proxy fallback routing

Introduction

In DeepSeek Harness (DSH), agents often need to fetch subscription pages, documentation, or APIs. When environment variables like HTTP_PROXY are set globally, even sites that should be accessible via direct connection get routed through the proxy. Conversely, if a direct connection fails and there is no per-host retry mechanism, users often have to manually switch mirrors or restart repeatedly. The DSH community plugin dsh-proxy-router (Maintainer: Lequait, Category: Network Tools) addresses a different layer of needs: importing a proxy subscription to implement “Direct-First, Proxy-Fallback” logic on the harness side, and remembering the optimal route per host for future requests.

Below is an introduction to what it is, how it differs from the built-in dsh-http-proxy, and how to install and use it.

What is this

dsh-proxy-router provides DSH with a “Direct-First, Proxy-Fallback” fetching capability: Subscription Link → Locally Supervised mihomo Core → Local Mixed Port. The plugin’s smartFetch first checks the route memory; if a direct connection fails, it retries via the proxy. Upon success, it records the path that should be taken for that host.

Comparison with DSH’s built-in dsh-http-proxy (as described in the README):

  • dsh-http-proxy installs HTTP_PROXY / HTTPS_PROXY / ALL_PROXY as the undici global dispatcher at startup. It is either fully proxied or fully direct, without per-host differentiation, and lacks logic to switch paths after a failure.
  • This plugin compensates by offering: Two Paths + Per-Host Memory + Decoupling from Proxy Health—when the proxy has no healthy nodes, the direct connection path remains available. The transport layer uses Node’s built-in node:http / node:https / node:tls and CONNECT tunnels, with no additional npm dependencies.

Node selection and failover are handled by mihomo (subscription, url-test groups, 204 probing); the direct/proxy policy is managed by the plugin. Current version 0.2.1, License MIT, requires DSH >=0.1.0-rc.6.

How it Works (Overview)

  1. Core Management: Generate/update core configuration using the subscription link. The plugin supervises mihomo and provides a mixed port (e.g., http://127.0.0.1:<mixedPort>) externally (default mixedPort 19097, controllerPort 19098, avoiding common Clash Verge ports).
  2. smartFetch: Check route memory by host (default TTL ~30 min) → Direct connection preferred → If failed, retry via local proxy → If successful, write to memory.
  3. Core Path Resolution: Tries environment variable DSH_PROXY_CORE, PATH, common installation directories, running processes, Windows Registry, etc., in sequence. If none are found, it can automatically download mihomo to <DSH_HOME>/cache/proxy-router/bin/ (switching to mirror sources if GitHub direct connection fails).

Installation and Activation

Install the plugin under the target profile (commands from the repository README):

dsh plugin --profile <your_profile> add dsh-proxy-router
# Or use GitHub source
dsh plugin --profile <your_profile> add github:Lequait/dsh-proxy-router

After restarting the harness, the proxy_router tool will appear in the session.

Subscription and Configuration

Minimum input: A subscription URL. Supports Clash YAML and base64 node lists.

Method ①: Handled by Agent (Recommended)

Provide the subscription at startup. The plugin will write it to <DSH_HOME>/cache/proxy-router/subscription.txt. Subsequent status / test / fetch commands will not require repeating it:

proxy_router { action: "start", subscriptionUrl: "https://your_subscription_url" }

Method ②: Written in the profile’s cordis.patch.yml

Set subscriptionUrl in the config of the proxy-router entry. Set autoStart: true if you want the core to launch automatically with the harness. Other fields are optional, e.g.:

- id: proxy-router
  name: dsh-proxy-router
  config:
    subscriptionUrl: 'https://your_subscription_url'
    corePath: ''
    autoStart: true
    mixedPort: 19097
    controllerPort: 19098
    directTimeoutMs: 8000
    proxyTimeoutMs: 12000
    healthUrl: 'http://cp.cloudflare.com/generate_204'
Field Default Description
subscriptionUrl '' Subscription link (contains token, please keep it safe)
corePath Auto-detect → Auto-download Usually leave empty; or set DSH_PROXY_CORE
autoStart false Whether to start the core with the harness
mixedPort / controllerPort 19097 / 19098 Local mixed port and controller port
directTimeoutMs / proxyTimeoutMs 8000 / 12000 Direct connection and proxy timeout
healthUrl cloudflare 204 Node health check URL

Tool proxy_router Typical Usage

action Function
status Core status, current node, number of healthy nodes, number of route memory entries
start / stop Start/stop the local core
test Test node health individually, sorted by latency
fetch Fetch URL using “Direct-First → Proxy-Fallback” (force: true ignores memory and retries)
routes / forget View or clear per-host route memory

Using fetch to verify if an agent can retrieve a URL under the current network is a common debugging step. Before production use, test can be used to confirm if the subscription still has healthy nodes.

Use Cases and Notes

Who it is for: Developers who need to stably fetch external resources within a DSH session without letting a global proxy slow down direct-access sites, or who want “switch paths immediately after the first failure, fewer trial-and-errors from the second attempt.”

Important to Know:

  • The plugin runs with the current dsh process privileges and starts the third-party core mihomo. Please read the GitHub Source Code and the MIT License before installing; only install from sources you trust.
  • The subscription URL will appear in generated files like <DSH_HOME>/cache/proxy-router/config.yaml. It contains credentials, so do not sync or commit them to version control.
  • If all subscription nodes are unavailable, the plugin will report 0 healthy nodes. Only direct connections remain available, preventing the agent from being dragged down by a broken proxy.
  • This plugin does not yet take over the built-in web_fetch; it provides an independent tool and local proxy port. To route the built-in fetcher through the same logic, you need to additionally register a ctx.web fetch provider (README boundary notes).

The DSH ecosystem emphasizes “Everything is a plugin.” The community directory SkillHub Plugin Page is an independent site and has no official affiliation with DeepSeek or Hithink RoyalFlush.

Conclusion

dsh-proxy-router consolidates “Subscription → Local mihomo → Direct-First, Proxy-Fallback on Failure, Per-Host Learning” into a callable proxy_router tool within the harness. Compared to global environment variable proxying, it better suits the need for per-site routing. For further details, please check the SkillHub Directory Page and the GitHub Repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye