@twinsearth/dsh-2xray
DSH-2Xray: supervises xray-core and routes DSH process-wide HTTP(S) traffic through its local inbound, with optional multi-node gRPC control plane
Install
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:TwinsEarth/DSH-2XrayREADME
Read the full README ↗配置参考
| 字段 | 默认 | 说明 |
|---|---|---|
enabled | false | 总开关 |
server.address | — | 服务端域名或 IP(旧版单节点写法;多节点用 nodes) |
server.port | 443 | 服务端端口 |
server.uuid | — | VLESS uuid;非标准 UUID 但 ≤30 字节也可 |
server.flow | xtls-rprx-vision | "" / xtls-rprx-vision / xtls-rprx-vision-udp443;非空时 network 必须是 raw/tcp 且 security 必须是 reality/tls(-test 不校验,插件静态拦截) |
server.serverName | — | REALITY/TLS 的 SNI |
server.password | — | REALITY 公钥(当前字段名),43 字符 base64url |
server.publicKey | — | REALITY 公钥旧字段名;与 password 同时写可跨版本,至少提供一个 |
server.shortId | "" | 偶数长度 hex,≤16 字符 |
server.fingerprint | chrome | uTLS 指纹 |
server.spiderX | / | 以 / 开头 |
server.network | raw | raw / tcp(后者归一为 raw) |
server.security | reality | reality / tls / none |
nodes | [] | 节点数组;与 server.* 二选一。每项支持 id/tag 与全部 server.* 字段 |
shareLink | "" | 粘贴一条 vless:// 分享链接(二维码里就是这段文本),解析后追加为节点 |
shareLinks | [] | 多条分享链接;优先于 shareLink,与显式 nodes 合并(显式节点在前) |
activeNode | 第一个节点 | 启动时钉住的 node id 或 outbound tag |
inbound.protocol | http | http 或 socks;socks 只建议给非 Node 客户端 |
inbound.host | 127.0.0.1 | 只允许回环地址 |
inbound.port | 20808 | 本地入站端口 |
inbound.socks.enabled | false | 额外开 SOCKS 入站 |
inbound.socks.port | 20809 | 不能与 HTTP 入站相同 |
inbound.socks.udp | false | undici 只实现 SOCKS CONNECT,开启只服务其它程序 |
takeover | auto | auto:已有代理策略时不覆盖;force:强制覆盖;off:只起 xray 不接管 |
control.enabled | false | 开启 gRPC 控制面(api 入站 + services) |
control.host / control.port | 127.0.0.1 / 10085 | 只允许回环;端口不能与任何入站冲突 |
control.services | Handler/Stats/Routing | 传给 xray 的 api.services |
control.stats | true | 打开 stats 与 policy.system 流量计数 |
control.balancerTag | active | 多节点 balancer 的 tag,也是切换目标 |
control.timeoutMs | 3000 | 每次 gRPC 调用超时 |
noProxy | "" | 追加的 bypass 列表(回环由 DSH 强制加入);不支持 CIDR |
routing.bypassDomains | 内网后缀 | 直连域名后缀列表,数组或逗号串 |
routing.blockAds | false | 加 geosite:category-ads-all → block |
routing.geositeCn | false | 国内域名直连(需要 geosite 数据) |
binary.path | "" | 显式 xray 路径 |
binary.dataDir | "" | 数据目录;默认 /xray-proxy |
lifecycle.startTimeoutMs | 15000 | 端口就绪预算 |
lifecycle.stopGraceMs | 3000 | 终止宽限(也是 ctx.subprocess 的 graceMs) |
lifecycle.maxRestarts | 5 | 崩溃重启上限,超过进 restart-exhausted |
lifecycle.backoffMs / backoffMaxMs | 500 / 30000 | 指数退避 |
lifecycle.healthIntervalMs | 30000 | 周期健康探测;0 关闭 |
lifecycle.unhealthyThreshold | 3 | 连续失败后回收进程 |
functionalProbe.enabled | true | 经本地入站请求一次 204;这是唯一能证明 uuid/flow/SNI/REALITY 全链路可用的检查 |
functionalProbe.url | http://www.gstatic.com/generate_204 | 探测目标 |
functionalProbe.timeoutMs | 5000 | 探测超时 |
log.level | warning | 传给 xray 的 loglevel;访问日志固定 none |
配置导入:分享链接 / 二维码
三种入口最终都归约为同一段 vless:// 文本,所以解析器只有一份(lib/share-link.js),UI 只负责把文本拿到手。
| 方式 | 状态 | 实现 |
|---|---|---|
| 粘贴分享链接 | ✅ Host 侧已实现 | shareLink: "vless://...",或 node scripts/parse-share-link.mjs "" 生成 nodes JSON |
| 扫描屏幕二维码 | ✅ 设置页 | getDisplayMedia() 取帧 + BarcodeDetector → 内置 jsQR 回退 |
| 扫描图片二维码 | ✅ 设置页 | `` + createImageBitmap() + 同一个双解码器 |
- id: xray-proxy
name: '@twinsearth/dsh-2xray'
config:
enabled: true
# 支持标准 Xray/v2rayN 导出格式:
# vless://uuid@host:443?security=reality&sni=...&fp=chrome&pbk=...&sid=...&spx=%2F&flow=xtls-rprx-vision#Hong%20Kong
shareLink: "vless://11111111-2222-4333-8444-555555555555@hk.example.com:443?security=reality&sni=www.example.com&fp=chrome&pbk=REPLACE_43_CHARS&sid=ab12&spx=%2F&flow=xtls-rprx-vision&type=tcp#Hong%20Kong"
control:
enabled: true
解析规则:
#片段名 → 节点id(如Hong Kong→ outbound tagproxy-Hong_Kong),可用作activeNode。sni→serverName;pbk→password与publicKey双写(跨版本兼容);sid→shortId;fp→fingerprint;spx→spiderX。security=none时清空 flow/SNI/shortId;type=tcp归一为raw。vmess:///trojan:///ss://会明确报「暂不支持」,而不是生成一个 Xray 会拒绝的配置——当前 builder 只产出 VLESS 出站。
订阅分组(订阅 URL 拉取多节点)未实现。 它是独立的网络动作(SSRF、重定向、离线缓存、订阅格式),建议单独设计,不与本地导入混在一起。
扫码能力依赖浏览器设置页(dsh.client + configForms/slots),当前仓库是 Host-only,所以只有链接字段与 CLI 可用。