@twinsearth/dsh-2xray 0.3.1 → 0.3.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4 — 2026-10-29
4
+
5
+ ### 修复
6
+
7
+ - 侧边栏标题不再写死「全局代理」:读取 `status.routing.mode`,显示「全局代理 / 国内直连 / 白名单代理」;geodata 缺失降级时追加「已降级全局」。
8
+ - 状态卡增加「路由:…」一栏,并同步显示降级原因。
9
+ - 状态快照新增 `routing` 字段(mode / whitelist / blacklist)。
10
+
11
+ ## 0.3.3 — 2026-10-29
12
+
13
+ ### 健康检查与发布
14
+
15
+ - 新增鉴权端点 `GET /api/xray/healthz`:返回 `v0.3.3`、运行状态与路由接管状态。
16
+ - Release 增加公开静态资产 `healthz.json`(`version: v0.3.3`),供部署流水线探针使用。
17
+ - 包含 0.3.1 的端口护栏与 geodata 降级修复(0.3.2 未单独发布)。
18
+
3
19
  ## 0.3.1 — 2026-10-29
4
20
 
5
21
  ### 修复
package/README.md CHANGED
@@ -334,6 +334,11 @@ v0.2.0 提供两个入口,互不替代:
334
334
 
335
335
  维护者用 `tools/build-core-packages.mjs` 从官方 zip 生成平台包;`.github/workflows/core-packages.yml` 会在具备 `NPM_TOKEN` secret 时自动下载、校验并发布各平台包。
336
336
 
337
+ ## 健康检查
338
+
339
+ - 进程内(需 DSH 会话鉴权):`GET /api/xray/healthz` → `{ "ok": true, "version": "v0.3.3", ... }`
340
+ - 发布物(公开、静态):Release 资产 `healthz.json`,`version` 与 tag 一致,可用于部署流水线的健康探针。
341
+
337
342
  ## 更新
338
343
 
339
344
  设置页 2Xray 里有三个入口:
package/index.js CHANGED
@@ -233,6 +233,25 @@ export function apply(ctx, rawConfig) {
233
233
  }),
234
234
  'dsh-2xray: update api',
235
235
  )
236
+ child.effect(
237
+ () =>
238
+ child.connection.fetch.register({
239
+ path: '/api/xray/healthz',
240
+ methods: ['GET'],
241
+ fetch: () => {
242
+ const snapshot = supervisor.snapshot()
243
+ return Response.json({
244
+ ok: true,
245
+ service: 'dsh-2xray',
246
+ version: `v${updateState.current}`,
247
+ state: snapshot.state,
248
+ ready: snapshot.state === 'ready',
249
+ routeInstalled: snapshot.route?.installed === true,
250
+ })
251
+ },
252
+ }),
253
+ 'dsh-2xray: healthz api',
254
+ )
236
255
  } catch (error) {
237
256
  logger.warn(`状态 API 注册失败:${String(error)}`)
238
257
  }
package/lib/client.js CHANGED
@@ -199,6 +199,8 @@ window.__ModuleLoader__.load({
199
199
  }
200
200
 
201
201
  function StatusCard({ status, latency, egress, phase }) {
202
+ const routingLabel =
203
+ { global: '全局', 'cn-direct': '国内直连', whitelist: '白名单' }[status?.routing?.mode] ?? '全局'
202
204
  return h('section', { style: C.card },
203
205
  h('div', { style: C.cardHead }, '③ 连接状态'),
204
206
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
@@ -209,6 +211,8 @@ window.__ModuleLoader__.load({
209
211
  egress?.ip ? `出口 IP ${egress.ip}${egress.country ? ` (${egress.country})` : ''}` : '出口 IP —')),
210
212
  h('div', { style: { ...C.muted, fontSize: 12.5, marginTop: 6 } },
211
213
  `节点「${status?.vpnName ?? status?.activeNode ?? '—'}」` +
214
+ ` · 路由:${routingLabel}` +
215
+ (status?.routingFallback ? '(geodata 缺失,已降级全局)' : '') +
212
216
  (status?.route?.installed ? ` · ${status.route.mode === 'harness' ? 'DSH 策略已接管' : '内置 dispatcher'}` : ' · 尚未接管')))
213
217
  }
214
218
 
@@ -238,13 +242,16 @@ window.__ModuleLoader__.load({
238
242
  const latency = probe.latency?.ms
239
243
  const egress = probe.egress ?? {}
240
244
  const localEndpoint = status ? `127.0.0.1:${status.port}` : '—'
245
+ const routingLabel =
246
+ { global: '全局代理', 'cn-direct': '国内直连', whitelist: '白名单代理' }[status?.routing?.mode] ?? '全局代理'
247
+ const fallbackNote = status?.routingFallback ? ' · geodata 缺失,已降级全局' : ''
241
248
 
242
249
  return h('div', { style: C.page },
243
250
  h('div', { style: C.header },
244
251
  h('span', { style: C.globe }, h(GlobeIcon, { size: 22 })),
245
252
  h('div', null,
246
253
  h('h1', { style: C.title }, '2Xray'),
247
- h('p', { style: C.sub }, `Xray 全局代理 · 本地 ${localEndpoint}`)),
254
+ h('p', { style: C.sub }, `Xray ${routingLabel} · 本地 ${localEndpoint}${fallbackNote}`)),
248
255
  h(StatusPill, { status })),
249
256
  error
250
257
  ? h('div', { style: { ...C.card, ...C.error, fontSize: 12.5 } }, `状态通道不可用:${error}(代理本身可能仍在工作)`)
package/lib/supervisor.js CHANGED
@@ -732,6 +732,11 @@ export class Supervisor {
732
732
  takeover: this.config.takeover,
733
733
  settingsSchema: this.#schemaLoaded,
734
734
  routingFallback: this.#routingFallback,
735
+ routing: {
736
+ mode: this.config.routing?.mode ?? 'global',
737
+ whitelist: this.config.routing?.whitelist ?? [],
738
+ blacklist: this.config.routing?.blacklist ?? [],
739
+ },
735
740
  nodes: this.config.nodes.map((node) => ({
736
741
  id: node.id,
737
742
  tag: node.tag,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/dsh-2xray",
3
- "version": "0.3.1",
3
+ "version": "0.3.4",
4
4
  "private": false,
5
5
  "description": "DSH-2Xray: supervises xray-core and routes DSH process-wide HTTP(S) traffic through its local inbound, with optional multi-node gRPC control plane",
6
6
  "type": "module",