dsh-clash-subscription 0.2.2 → 0.4.2-probe.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -127
- package/index.js +1 -678
- package/package.json +6 -62
- package/LICENSE +0 -21
- package/client.js +0 -786
- package/cordis.patch.yml +0 -5
- package/icon.svg +0 -14
- package/lib/core.js +0 -496
- package/lib/discovery.js +0 -94
- package/lib/install.js +0 -83
- package/lib/routes.js +0 -262
- package/lib/routing.js +0 -173
- package/lib/subscription.js +0 -138
- package/locale/en.json +0 -6
- package/locale/zh.json +0 -6
package/README.md
CHANGED
|
@@ -1,128 +1,3 @@
|
|
|
1
|
-
# dsh-clash-
|
|
1
|
+
# dsh-clash-subscription publish probe
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
and the plugin runs a **private core** and points the Harness' outbound policy at it.
|
|
5
|
-
`web_fetch`, search/fetch providers, LLM transports and shells then reach blocked
|
|
6
|
-
sites automatically — **no desktop Clash app, no system proxy, no per-command
|
|
7
|
-
`HTTPS_PROXY`**.
|
|
8
|
-
|
|
9
|
-
## Split routing
|
|
10
|
-
|
|
11
|
-
| Destination | Path |
|
|
12
|
-
| --- | --- |
|
|
13
|
-
| Loopback `127.0.0.1`, `::1`, localhost | direct (never in the tunnel: the Web UI and every plugin route live there) |
|
|
14
|
-
| LAN `10/8`, `172.16/12`, `192.168/16`, `169.254/16` | direct |
|
|
15
|
-
| Chinese addresses (`GEOIP,CN`) | direct |
|
|
16
|
-
| Everything else | proxy, through the selected subscription node |
|
|
17
|
-
|
|
18
|
-
Domestic sites therefore behave exactly as before; only traffic that would otherwise
|
|
19
|
-
be blocked reaches a node.
|
|
20
|
-
|
|
21
|
-
## No defaults, no borrowed configuration
|
|
22
|
-
|
|
23
|
-
The subscription URL has **no default value and no fallback**. The plugin never reads
|
|
24
|
-
another client's profile, subscription, or node selection. The only machine-level
|
|
25
|
-
information it uses is:
|
|
26
|
-
|
|
27
|
-
- an existing mihomo-compatible executable, so you need not type a path to a core the
|
|
28
|
-
machine already has; and
|
|
29
|
-
- downloaded GeoIP/GeoSite databases, because the core needs them before it can
|
|
30
|
-
classify a single connection — the alternative is a download over the very tunnel
|
|
31
|
-
those databases are required to establish.
|
|
32
|
-
|
|
33
|
-
Both are optional. Without them you point `corePath` at a binary and the core falls
|
|
34
|
-
back to a built-in domestic domain list.
|
|
35
|
-
|
|
36
|
-
## How it works
|
|
37
|
-
|
|
38
|
-
It does not reimplement transport. It reuses the Harness' own outbound policy module
|
|
39
|
-
`@deepseek-ai/dsh-http-proxy`:
|
|
40
|
-
|
|
41
|
-
1. **The core parses the subscription.** The config carries a `proxy-providers` entry
|
|
42
|
-
and mihomo downloads it itself, so anytls / hysteria2 / vless / ss / trojan all work
|
|
43
|
-
without a parser or a schema to track.
|
|
44
|
-
2. **The policy is loaded from the installation, not the profile.** A profile-installed
|
|
45
|
-
plugin resolves bare specifiers from its own `node_modules`; resolving
|
|
46
|
-
`dsh-http-proxy` from the dsh installation's manifest yields the *same module
|
|
47
|
-
instance the host loaded*. Node's `fetch` resolves undici's global dispatcher, and
|
|
48
|
-
`dsh-subprocess` asks this same module for a child's environment — one instance, so
|
|
49
|
-
one install covers `ctx.web`, the LLM transports and every spawned child.
|
|
50
|
-
3. **A working node is chosen at startup.** A fresh `PROXY` group starts on `DIRECT`,
|
|
51
|
-
which would send foreign traffic straight out, so the plugin measures latency in
|
|
52
|
-
batches, skips dead nodes (a provider can report a node alive long after it stopped
|
|
53
|
-
serving), and never selects `DIRECT`.
|
|
54
|
-
4. **Geo databases are reused, never re-downloaded.** A missing database makes the core
|
|
55
|
-
fetch one from GitHub at startup — the exact connection it needs the database to
|
|
56
|
-
establish — so an existing copy is reused and a missing one is reported instead of
|
|
57
|
-
retried.
|
|
58
|
-
|
|
59
|
-
## Configuration
|
|
60
|
-
|
|
61
|
-
Install the bundle, then set the subscription in **Settings → Clash proxy**.
|
|
62
|
-
|
|
63
|
-
| Field | Default | Meaning |
|
|
64
|
-
| --- | --- | --- |
|
|
65
|
-
| `subscriptionUrl` | empty | Subscription URL. `clash://install-config?url=…` import links are accepted. Required. |
|
|
66
|
-
| `node` | empty | Preferred node name; empty picks the lowest-latency working node |
|
|
67
|
-
| `corePath` | empty | mihomo/clash executable; empty searches the usual install locations |
|
|
68
|
-
| `mode` | `rule` | `rule` keeps domestic traffic direct; `global` proxies everything |
|
|
69
|
-
| `autoStart` | `true` | Start the core and install the policy when the plugin loads |
|
|
70
|
-
| `speedTestMinutes` | `30` | Re-measure interval; `0` disables the cycle |
|
|
71
|
-
| `speedTestCount` | `8` | Nodes measured per cycle |
|
|
72
|
-
| `dnsServers` | empty | Resolvers for the core's own lookups, comma separated |
|
|
73
|
-
| `directDomains` | empty | Domain suffixes that must stay direct |
|
|
74
|
-
| `proxyDomains` | empty | Domain suffixes that must always use the node |
|
|
75
|
-
| `dataDir` | `<DSH_HOME>/data/dsh-clash-proxy` | Core config, subscription cache, geo databases |
|
|
76
|
-
|
|
77
|
-
Ports are allocated free on every start, so the plugin never collides with another
|
|
78
|
-
Clash instance, and it only ever stops the process it started.
|
|
79
|
-
|
|
80
|
-
## UI
|
|
81
|
-
|
|
82
|
-
A page in **Settings → Clash proxy**, with live status, the node table with measured
|
|
83
|
-
latency, the subscription field with a pre-save reachability check, and the
|
|
84
|
-
speed-test cycle. Saving writes through the Harness config editor, so the rest of the
|
|
85
|
-
profile patch stays intact; a routing-relevant change restarts the core, a timing
|
|
86
|
-
change only re-arms the cycle.
|
|
87
|
-
|
|
88
|
-
## Tool
|
|
89
|
-
|
|
90
|
-
One model-facing tool, `clash_proxy`:
|
|
91
|
-
|
|
92
|
-
- `status` — core, policy, node table, current node, live traffic
|
|
93
|
-
- `import` — probe a URL, restart the core on it, install the policy
|
|
94
|
-
- `start` / `stop` — bring routing up or take it down
|
|
95
|
-
- `select` — switch the exit node by name
|
|
96
|
-
- `test` — measure one node, or the current one
|
|
97
|
-
- `refresh` — re-download the subscription
|
|
98
|
-
|
|
99
|
-
## Tests
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
node test/unit.mjs # offline assertions: no network, no core, no profile writes
|
|
103
|
-
node test/client-sim.mjs # executes the client bundle in a simulated module loader
|
|
104
|
-
node test/e2e.mjs "<subscription url>" # real core + real subscription
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
`test/e2e.mjs` asserts the three promises above: the core boots, `fetch` reaches
|
|
108
|
-
foreign hosts once the policy is installed, and domestic plus loopback traffic stays
|
|
109
|
-
direct.
|
|
110
|
-
|
|
111
|
-
## Known limits
|
|
112
|
-
|
|
113
|
-
- **This process and its children only.** It is the Harness' outbound policy, not a
|
|
114
|
-
system VPN; other applications are unaffected (which is part of why domestic sites
|
|
115
|
-
stay unchanged).
|
|
116
|
-
- **Worker threads do not receive the policy.** `dsh-http-proxy` deliberately withholds
|
|
117
|
-
a possibly credential-bearing proxy URL from model-authored scripts; the plugin
|
|
118
|
-
keeps that boundary.
|
|
119
|
-
- **A plugin that builds its own transport bypasses it.** A fetch provider using
|
|
120
|
-
`node:https` and its own DNS lookup does not read undici's dispatcher, so it will not
|
|
121
|
-
be proxied.
|
|
122
|
-
- **Node quality is the subscription's.** Automatic selection measures latency once;
|
|
123
|
-
later congestion still needs a manual `select` or `test`.
|
|
124
|
-
- **No bundled core.** Bring a mihomo/clash binary; the plugin does not redistribute one.
|
|
125
|
-
|
|
126
|
-
## License
|
|
127
|
-
|
|
128
|
-
MIT
|
|
3
|
+
This version exists only to verify the publish pipeline. It is not a release.
|