dsh-clash-subscription 0.4.2-probe.5 → 0.4.2
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/LICENSE +21 -0
- package/README.md +188 -2
- package/client.js +980 -0
- package/cordis.patch.yml +5 -0
- package/icon.svg +14 -0
- package/index.js +1314 -1
- package/lib/cn-cidr.js +5526 -0
- package/lib/core.js +734 -0
- package/lib/corefetch.js +618 -0
- package/lib/discovery.js +52 -0
- package/lib/geo.js +130 -0
- package/lib/install.js +171 -0
- package/lib/routes.js +306 -0
- package/lib/routing.js +173 -0
- package/lib/subscription.js +334 -0
- package/lib/vendored.js +167 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +67 -6
- package/vendor/SHA256SUMS.json +7 -0
- package/vendor/mihomo.exe.gz +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-clash-proxy contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,189 @@
|
|
|
1
|
-
# dsh-clash-subscription
|
|
1
|
+
# dsh-clash-subscription
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Package `dsh-clash-subscription` · loader row id `clash-proxy` (kept stable so an
|
|
4
|
+
> existing profile's saved config keeps applying) · Settings → **Clash 代理**
|
|
5
|
+
|
|
6
|
+
Give DeepSeek Harness its own outbound proxy: import **one or more** Clash/mihomo
|
|
7
|
+
subscriptions and the plugin routes foreign traffic through a node while Chinese traffic
|
|
8
|
+
stays direct — **no desktop Clash app, no system proxy, no per-command `HTTPS_PROXY`, and no
|
|
9
|
+
other software to install**.
|
|
10
|
+
|
|
11
|
+
## What 0.4 changes
|
|
12
|
+
|
|
13
|
+
**The core now ships with the plugin.** That is the difference between "installs" and
|
|
14
|
+
"works". The core is itself on the internet, so downloading it lazily made a machine that
|
|
15
|
+
installed this plugin *because* it could not reach the internet need the internet to become
|
|
16
|
+
able to reach the internet. Now:
|
|
17
|
+
|
|
18
|
+
| | Before | 0.4 |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| Core | searched for, else "install Clash Verge" | **vendored** (22 MB gzip), unpacked and verified on first use — measured 0.9 s to routing |
|
|
21
|
+
| Domestic classification | needed `Country.mmdb`, else a 30-domain list that sent meituan.com through a node | **5500 embedded CN CIDR blocks** in a generated rule set; no database required |
|
|
22
|
+
| GeoIP database | fetched during startup, over a tunnel that did not exist yet | fetched **after routing is healthy**, in the background, as an upgrade |
|
|
23
|
+
| Missing core | was a `blocker` — the panel said "cannot start" | not a blocker; configuration works without one |
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
The bundle must be present in **two** places in the profile manifest. Only one of them is
|
|
28
|
+
enough to make the settings page appear to exist, and the plugin then silently does nothing.
|
|
29
|
+
|
|
30
|
+
```jsonc
|
|
31
|
+
// ~/.dsh/profiles/<profile>/package.json
|
|
32
|
+
{
|
|
33
|
+
"dependencies": { "dsh-clash-subscription": "0.4.0" },
|
|
34
|
+
"dsh": { "profile": { "bundles": ["dsh-clash-subscription"] } }
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cd ~/.dsh/profiles/<profile>
|
|
40
|
+
pnpm install --config.minimumReleaseAge=0
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then **fully restart the Harness** — the host loads plugin code at boot.
|
|
44
|
+
|
|
45
|
+
The package is ~22 MB because it carries the core. That is deliberate: it is the only way
|
|
46
|
+
"install, configure, works" holds on a machine with no working outbound route.
|
|
47
|
+
|
|
48
|
+
## Subscriptions
|
|
49
|
+
|
|
50
|
+
One per line in **订阅链接 / Import links**. Blank lines and lines starting with `#` or `//`
|
|
51
|
+
are ignored.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
主用 https://api.example.com/api/v1/client/subscribe?token=…
|
|
55
|
+
备用 https://backup.example.com/sub?token=…
|
|
56
|
+
clash://install-config?url=https%3A%2F%2Fthird.example.com%2Fsub
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- A leading `name` is optional; without one the entry is called `订阅 N`.
|
|
60
|
+
- Bare `https://` and `clash://install-config?url=…` are both accepted, on any line.
|
|
61
|
+
- A duplicate URL is dropped and *reported*; a malformed line is named by line number.
|
|
62
|
+
- An existing 0.2 profile's single `subscriptionUrl` is read as the first line; the next save
|
|
63
|
+
moves the profile onto the list field.
|
|
64
|
+
|
|
65
|
+
Every subscription becomes its own core provider feeding one `PROXY` group, so the node table
|
|
66
|
+
is the union. With more than one subscription each provider's nodes are prefixed with its
|
|
67
|
+
name — two providers routinely both name a node `香港01`, and without a prefix the group holds
|
|
68
|
+
duplicate names. A provider that fails to download shows `未拉到节点` on its own row and does
|
|
69
|
+
not stop the others.
|
|
70
|
+
|
|
71
|
+
## Split routing
|
|
72
|
+
|
|
73
|
+
| Destination | Path |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| Loopback `127.0.0.1`, `::1`, localhost | direct |
|
|
76
|
+
| LAN `10/8`, `172.16/12`, `192.168/16`, `169.254/16` | direct |
|
|
77
|
+
| Chinese domains and addresses | direct |
|
|
78
|
+
| Everything else | proxy |
|
|
79
|
+
|
|
80
|
+
Domestic is decided in three layers, in order: an explicit `directDomains` list, a built-in
|
|
81
|
+
domain list (`.cn`, baidu, qq, taobao…), then a **5500-block CN address rule set generated
|
|
82
|
+
from the plugin's own data**. No GeoIP database is needed for any of it.
|
|
83
|
+
|
|
84
|
+
Two measured details are worth knowing because they are easy to get wrong:
|
|
85
|
+
|
|
86
|
+
- The address rule must **not** carry `no-resolve`. A CONNECT to a hostname has no address
|
|
87
|
+
until the core resolves it; with `no-resolve` every domestic site fell through to `MATCH`,
|
|
88
|
+
i.e. straight into the tunnel.
|
|
89
|
+
- A core with no `Country.mmdb` logs `MMDB invalid, remove and download` and tries to fetch
|
|
90
|
+
one. That is why the database is an *upgrade* now and never a startup dependency.
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
| Field | Default | Meaning |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `subscriptionUrls` | empty | One subscription per line, optional `name ` prefix |
|
|
97
|
+
| `node` | empty | Preferred exit node; empty means automatic |
|
|
98
|
+
| `mode` | `rule` | `rule` keeps Chinese sites direct; `global` sends everything through the node |
|
|
99
|
+
| `autoStart` | `true` | Bring routing up when the plugin loads |
|
|
100
|
+
| `autoFetchCore` | `false` | Download a core from the internet when this platform has no bundled one |
|
|
101
|
+
| `autoFetchGeo` | `true` | Fetch GeoIP databases after routing works; an upgrade, never a requirement |
|
|
102
|
+
| `speedTestMinutes` | `30` | Node re-measurement cycle; `0` disables |
|
|
103
|
+
| `speedTestCount` | `8` | Nodes measured per cycle |
|
|
104
|
+
| `healthCheckMinutes` | `1` | Liveness/watchdog cycle; `0` disables |
|
|
105
|
+
| `directDomains` / `proxyDomains` | empty | Comma-separated suffixes, always direct / always proxied |
|
|
106
|
+
| `dnsServers` | empty | Resolvers the core uses for its own lookups |
|
|
107
|
+
| `corePath` | empty | Use this executable instead of the bundled/search one |
|
|
108
|
+
| `coreVersion` | empty | Pin a download to a version whose digest ships with this build |
|
|
109
|
+
| `dataDir` | `<DSH_HOME>/data/dsh-clash-proxy` | Core, its config, provider cache, rule set |
|
|
110
|
+
|
|
111
|
+
## The bundled core
|
|
112
|
+
|
|
113
|
+
`vendor/mihomo.exe.gz` is mihomo v1.19.34 (windows-amd64-compatible — the CPU-baseline build,
|
|
114
|
+
so it runs on older machines that a `v3` build would crash with an illegal instruction).
|
|
115
|
+
|
|
116
|
+
`vendor/SHA256SUMS.json` is generated when the package is built and records the SHA-256 of
|
|
117
|
+
both the archive and the unpacked executable. `lib/vendored.js` checks the archive **before**
|
|
118
|
+
unpacking and the executable **after**, and re-unpacks if an already-installed copy no longer
|
|
119
|
+
matches — a corrupted or replaced binary is restored rather than trusted. If the manifest and
|
|
120
|
+
the archive ever disagree, the plugin refuses to run the binary at all.
|
|
121
|
+
|
|
122
|
+
Only `win32-x64` ships. Other platforms report `platformSupported: false` and use `corePath`
|
|
123
|
+
or `autoFetchCore` instead.
|
|
124
|
+
|
|
125
|
+
## The optional GeoIP upgrade
|
|
126
|
+
|
|
127
|
+
After routing is confirmed healthy, the plugin tries to fetch `Country.mmdb` (and `geoip.dat`)
|
|
128
|
+
from jsDelivr first, then GitHub raw. Progress is visible as `status.geoUpgrade`:
|
|
129
|
+
|
|
130
|
+
| `phase` | Meaning |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `present` | a database is already on disk (seeded from a local Clash install, or fetched earlier) |
|
|
133
|
+
| `fetching` | in flight |
|
|
134
|
+
| `done` / `partial` / `unavailable` | outcome; the domestic bypass works in every case |
|
|
135
|
+
| `disabled` | `autoFetchGeo: false` |
|
|
136
|
+
|
|
137
|
+
A fetched database applies from the next core start.
|
|
138
|
+
|
|
139
|
+
## UI
|
|
140
|
+
|
|
141
|
+
Settings → **Clash proxy**:
|
|
142
|
+
|
|
143
|
+
- live state: endpoint, whether the policy is installed, and whether it is actually healthy
|
|
144
|
+
- one row per subscription: name, node count, last fetch time, its own refresh button
|
|
145
|
+
- exit-node table with per-node latency (not measured / measured / no answer)
|
|
146
|
+
- a multi-line subscription editor with **检测全部** reporting every line
|
|
147
|
+
- when no core is present: a **下载内核** button, with the download's progress and outcome
|
|
148
|
+
|
|
149
|
+
## Tool
|
|
150
|
+
|
|
151
|
+
`clash_proxy`:
|
|
152
|
+
|
|
153
|
+
| Action | Effect |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| `status` | Core, policy, subscriptions, node table, traffic, rule-set state, GeoIP phase |
|
|
156
|
+
| `import` | `url` (one or more lines) replaces the list; `append: true` adds. Probes, **saves**, restarts |
|
|
157
|
+
| `bootstrap` | Download and verify a core when this platform has no bundled one |
|
|
158
|
+
| `start` / `stop` | Bring routing up (unpacking the bundled core if needed) / return to direct |
|
|
159
|
+
| `select` / `test` | Switch the exit node / measure latency |
|
|
160
|
+
| `refresh` | Re-download every subscription |
|
|
161
|
+
|
|
162
|
+
## HTTP routes
|
|
163
|
+
|
|
164
|
+
All `exact`, same-origin, JSON: `/clash-proxy/status` (GET), `/clash-proxy/config` (GET/POST),
|
|
165
|
+
`/clash-proxy/action` (POST: `start` `stop` `refresh` `refreshOne` `bootstrap` `probe` `test`
|
|
166
|
+
`select`), `/clash-proxy/probe` (POST).
|
|
167
|
+
|
|
168
|
+
Tokens are masked (`token=***`) in every response and in the log. The profile patch and the
|
|
169
|
+
core's own `config.json` necessarily hold the real value.
|
|
170
|
+
|
|
171
|
+
## Tests
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
node test/unit.mjs # 77 offline assertions: no network, no core, no profile writes
|
|
175
|
+
node test/client-sim.mjs # the panel bundle in a simulated module loader
|
|
176
|
+
node test/e2e.mjs "<subscription url>" # real core + real subscription
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Known limits
|
|
180
|
+
|
|
181
|
+
- **Only windows-x64 is vendored.** macOS and Linux need `corePath` or `autoFetchCore`.
|
|
182
|
+
- **22 MB package.** The alternative is a download that cannot work on the machine that needs
|
|
183
|
+
it most.
|
|
184
|
+
- `directDomains` / `proxyDomains` are `DOMAIN-SUFFIX` rules only; CIDR there is not accepted
|
|
185
|
+
(the loopback/LAN CIDRs are built in).
|
|
186
|
+
- A provider health check answers `503` for a node whose server is unreachable — that is the
|
|
187
|
+
measurement working, not a plugin error.
|
|
188
|
+
- The bundled rule set covers IPv4. IPv6 stays direct via the loopback/LAN rules and is
|
|
189
|
+
otherwise classified by the optional GeoIP database.
|