dsh-plugin-mesh 0.5.14 → 0.5.16
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/client/client.js +14 -0
- package/lib/index.js +46 -6
- package/lib/tsnet/checksums.js +7 -7
- package/lib/tsnet/download.js +8 -2
- package/package.json +1 -1
- package/scripts/build-sidecar.sh +3 -1
- package/sidecar/main.go +5 -1
package/client/client.js
CHANGED
|
@@ -6904,6 +6904,10 @@ window.__ModuleLoader__.load({
|
|
|
6904
6904
|
const failed = !!report && report.ok !== true;
|
|
6905
6905
|
const incomparable = !!report && report.ok === true && report.comparable === false;
|
|
6906
6906
|
const canInstall = hasUpdate && !pending && report.diskVersion !== report.latest;
|
|
6907
|
+
// 查完「没有新版本」以前什么都不渲染,看上去就像检查没生效;
|
|
6908
|
+
// 这里补一个结果:已是最新 vX(点完能看见查到的版本号)。
|
|
6909
|
+
const upToDate =
|
|
6910
|
+
!!report && report.ok === true && !hasUpdate && !incomparable && !pending && !!(report.latest || report.current);
|
|
6907
6911
|
const label = checking ? "检查中…" : "检查更新";
|
|
6908
6912
|
const title = failed
|
|
6909
6913
|
? `上次检查失败:${String(report.error || "未知原因")}(点一下重试)`
|
|
@@ -6935,6 +6939,16 @@ window.__ModuleLoader__.load({
|
|
|
6935
6939
|
`已安装 v${pending.version}`,
|
|
6936
6940
|
)
|
|
6937
6941
|
: null,
|
|
6942
|
+
upToDate
|
|
6943
|
+
? h(
|
|
6944
|
+
"span",
|
|
6945
|
+
{
|
|
6946
|
+
className: "mesh-meta-pill",
|
|
6947
|
+
title: `当前 v${report.current};registry 最新 v${report.latest || report.current}${report.cached ? "(本次为缓存结果)" : ""}`,
|
|
6948
|
+
},
|
|
6949
|
+
`已是最新 v${report.latest || report.current}`,
|
|
6950
|
+
)
|
|
6951
|
+
: null,
|
|
6938
6952
|
pending && pending.restartRequired
|
|
6939
6953
|
? h(
|
|
6940
6954
|
"button",
|
package/lib/index.js
CHANGED
|
@@ -108,7 +108,7 @@ import { TsnetNode, channelKey, channelSignature } from "./tsnet/manager.js";
|
|
|
108
108
|
import { resolveTailnetChannels } from "./tsnet/channels.js";
|
|
109
109
|
import { tailnetFetch, tailnetOrigin, isTailnetAddress } from "./tsnet/bridge.js";
|
|
110
110
|
import { createWebProxy } from "./web-proxy.js";
|
|
111
|
-
import { planWebTarget, needsReachabilityProbe } from "./web-target.js";
|
|
111
|
+
import { planWebTarget, needsReachabilityProbe, isLoopbackHost } from "./web-target.js";
|
|
112
112
|
import { planSshTarget, sshDirectCandidates } from "./ssh-target.js";
|
|
113
113
|
import { createSecretReader } from "./desktop-auth.js";
|
|
114
114
|
import {
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
export const name = "dsh-plugin-mesh";
|
|
130
130
|
export const inject = ["tools", "webServer"];
|
|
131
131
|
|
|
132
|
-
const VERSION = "0.5.
|
|
132
|
+
const VERSION = "0.5.16";
|
|
133
133
|
// 诊断用:进程启动时间 + 入口真实路径。磁盘上的版本**不在这里缓存** ——
|
|
134
134
|
// 升级之后进程还跑旧代码,版本号必须现读磁盘才能立刻反映出来(真踩过:
|
|
135
135
|
// 磁盘升到 0.5.1,进程还在 0.5.0,界面显示 0.5.0)。
|
|
@@ -4953,11 +4953,35 @@ function registerUiRoutes(ctx, { discovery, config, identity, inbound, outbound,
|
|
|
4953
4953
|
probeNote: direct.note,
|
|
4954
4954
|
});
|
|
4955
4955
|
if (plan.mode === "stream") {
|
|
4956
|
+
const passthrough = Boolean(plan.ticket);
|
|
4957
|
+
const upstreamHeaders = passthrough
|
|
4958
|
+
? { [plan.header || PEER_WEB_TICKET_HEADER]: plan.ticket, "x-dsh-mesh-token": currentSecret() }
|
|
4959
|
+
: {};
|
|
4960
|
+
// 快路:对端除了相对前缀,还把隧道的**局域网绝对地址**(tunnel.url)给了。
|
|
4961
|
+
// 同网段时直接打那个地址:sidecar 拨 tailnet 要多一跳,遇到 DERP 中继还会
|
|
4962
|
+
// 明显变慢——页面所有请求都吃这个延迟。拨不通再回落到 tailnet 出站流。
|
|
4963
|
+
const lanBase = lanTunnelBase(tunnel);
|
|
4964
|
+
if (lanBase) {
|
|
4965
|
+
const probe = await verifyWebBase(lanBase);
|
|
4966
|
+
if (probe.reachable !== false) {
|
|
4967
|
+
return {
|
|
4968
|
+
remoteBase: lanBase,
|
|
4969
|
+
pathPrefix: plan.prefix || "",
|
|
4970
|
+
passthrough,
|
|
4971
|
+
lanReachable: true,
|
|
4972
|
+
token,
|
|
4973
|
+
guiPort,
|
|
4974
|
+
guiBind,
|
|
4975
|
+
stream: null,
|
|
4976
|
+
upstreamHeaders,
|
|
4977
|
+
note: `经对端局域网 mesh 口隧道(${lanBase}${String(plan.prefix || "").replace(/^\//, "")})`,
|
|
4978
|
+
};
|
|
4979
|
+
}
|
|
4980
|
+
}
|
|
4956
4981
|
const opened = await openWebStream(target, plan.address);
|
|
4957
4982
|
if (opened.error) {
|
|
4958
4983
|
return { error: `${plan.note},但${opened.error}` };
|
|
4959
4984
|
}
|
|
4960
|
-
const passthrough = Boolean(plan.ticket);
|
|
4961
4985
|
return {
|
|
4962
4986
|
remoteBase: `http://127.0.0.1:${opened.port}/`,
|
|
4963
4987
|
pathPrefix: plan.prefix || "",
|
|
@@ -4967,9 +4991,7 @@ function registerUiRoutes(ctx, { discovery, config, identity, inbound, outbound,
|
|
|
4967
4991
|
guiPort,
|
|
4968
4992
|
guiBind,
|
|
4969
4993
|
stream: { address: plan.address, node: opened.node },
|
|
4970
|
-
upstreamHeaders
|
|
4971
|
-
? { [plan.header || PEER_WEB_TICKET_HEADER]: plan.ticket, "x-dsh-mesh-token": currentSecret() }
|
|
4972
|
-
: {},
|
|
4994
|
+
upstreamHeaders,
|
|
4973
4995
|
note: plan.note,
|
|
4974
4996
|
};
|
|
4975
4997
|
}
|
|
@@ -5007,6 +5029,24 @@ function registerUiRoutes(ctx, { discovery, config, identity, inbound, outbound,
|
|
|
5007
5029
|
}
|
|
5008
5030
|
}
|
|
5009
5031
|
|
|
5032
|
+
/**
|
|
5033
|
+
* 对端给的局域网绝对隧道地址(`tunnel.url`,形如 `http://192.168.1.5:45930/mesh/web/`)。
|
|
5034
|
+
*
|
|
5035
|
+
* 只取 `scheme://host:port/` 这一截:路径前缀由 pathPrefix 单独拼,避免拼两次。
|
|
5036
|
+
* 回环地址一律不用——那是"对端自己"的地址,拨过去只会打到本机。
|
|
5037
|
+
*/
|
|
5038
|
+
function lanTunnelBase(tunnel) {
|
|
5039
|
+
try {
|
|
5040
|
+
const raw = String(tunnel?.url ?? "").trim();
|
|
5041
|
+
if (!raw) return "";
|
|
5042
|
+
const u = new URL(raw);
|
|
5043
|
+
if (!u.hostname || isLoopbackHost(u.hostname)) return "";
|
|
5044
|
+
return `${u.protocol}//${u.host}/`;
|
|
5045
|
+
} catch {
|
|
5046
|
+
return "";
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5049
|
+
|
|
5010
5050
|
/** 在对端名片的 tailnet 端点(100.64/10)上开会话出口。 */
|
|
5011
5051
|
async function openWebStream(target, address) {
|
|
5012
5052
|
const ep = orderedEndpoints(target).find((item) => item?.transport === "tsnet" && item.host);
|
package/lib/tsnet/checksums.js
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* 键是资产名,值是 gzip 压缩后的 sha256。
|
|
10
10
|
*/
|
|
11
11
|
export const PINNED_CHECKSUMS = {
|
|
12
|
-
"dsh-mesh-tsnet-android-amd64.gz": "
|
|
13
|
-
"dsh-mesh-tsnet-android-arm64.gz": "
|
|
14
|
-
"dsh-mesh-tsnet-darwin-amd64.gz": "
|
|
15
|
-
"dsh-mesh-tsnet-darwin-arm64.gz": "
|
|
16
|
-
"dsh-mesh-tsnet-linux-amd64.gz": "
|
|
17
|
-
"dsh-mesh-tsnet-linux-arm64.gz": "
|
|
18
|
-
"dsh-mesh-tsnet-windows-amd64.exe.gz": "
|
|
12
|
+
"dsh-mesh-tsnet-android-amd64.gz": "5bdaaae79ba6530a89b2abcbeb9b3ab211bc9c9bb789cd400575208ef8e4289b",
|
|
13
|
+
"dsh-mesh-tsnet-android-arm64.gz": "b10f13079b5b699d56009890a876f8cef8d391d393da37d348b4012684ffa2cd",
|
|
14
|
+
"dsh-mesh-tsnet-darwin-amd64.gz": "1bdb986591c5bfee6ec1539cf2f7322f4067a700626199254f77d2d9905416f9",
|
|
15
|
+
"dsh-mesh-tsnet-darwin-arm64.gz": "bfe1b07a5be5c4f1841131afbfc319017dd79c3440860e829d8151187845e218",
|
|
16
|
+
"dsh-mesh-tsnet-linux-amd64.gz": "9e5800927abbda33e7c0828ecd882381c8fcab3a7b066491a5eaaee97a22714e",
|
|
17
|
+
"dsh-mesh-tsnet-linux-arm64.gz": "226b6478c35ad893b4d53705103cc4c5233fc4016ee7da2b00b277b1d915a86e",
|
|
18
|
+
"dsh-mesh-tsnet-windows-amd64.exe.gz": "d86b269bdf5d7b04615f911c0462ff5437433e26652cbe65a7780be5a31606ed",
|
|
19
19
|
};
|
package/lib/tsnet/download.js
CHANGED
|
@@ -25,8 +25,14 @@ import { dirname, join } from "node:path";
|
|
|
25
25
|
import { homedir } from "node:os";
|
|
26
26
|
import { PINNED_CHECKSUMS } from "./checksums.js";
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Sidecar 控制协议版本;与 sidecar/main.go 的 ProtocolVersion 必须一致。
|
|
30
|
+
*
|
|
31
|
+
* v2 起才有 /__tsnet/dial(出站流)与 /__tsnet/listen(入站暴露)。v1 的二进制
|
|
32
|
+
* 没有这两个端点,且老插件钉着 v1 那批 sha256 —— 换二进制必须新开 sidecar-v<N>,
|
|
33
|
+
* 覆盖同名资产会让老版本校验失败。
|
|
34
|
+
*/
|
|
35
|
+
export const SIDECAR_PROTOCOL = 2;
|
|
30
36
|
const RELEASE_TAG = `sidecar-v${SIDECAR_PROTOCOL}`;
|
|
31
37
|
const REPO = "peng456/dsh-plugin-mesh";
|
|
32
38
|
const ASSET_BASE = `https://github.com/${REPO}/releases/download/${RELEASE_TAG}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-mesh",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "把跑不完的活交给另一台电脑;跑完,结果回到你面前。两台装了 DSH 的电脑各装一次,自动互相发现,任务派过去由对端的 agent 执行,结果派回来。Hand a long task to another machine: your DSH instances find each other, the peer runs it, and the result comes back. No pairing codes, no IPs, no Tailscale client.",
|
|
6
6
|
"license": "MIT",
|
package/scripts/build-sidecar.sh
CHANGED
|
@@ -19,7 +19,9 @@ DIST_DIR="$REPO_ROOT/dist/sidecar"
|
|
|
19
19
|
|
|
20
20
|
# The release tag is tied to the sidecar control-API protocol, not the plugin
|
|
21
21
|
# version: the plugin pins a protocol number and refuses mismatched binaries.
|
|
22
|
-
|
|
22
|
+
# 必须与 sidecar/main.go 的 ProtocolVersion、lib/tsnet/download.js 的
|
|
23
|
+
# SIDECAR_PROTOCOL 三处一致(脚本里自己会校验前两者)。
|
|
24
|
+
PROTOCOL_VERSION=2
|
|
23
25
|
RELEASE_TAG="sidecar-v${PROTOCOL_VERSION}"
|
|
24
26
|
# 发布目标仓库。必须与 lib/tsnet/download.js 里的 REPO 一致,否则插件会去
|
|
25
27
|
# 另一个仓库找二进制。
|
package/sidecar/main.go
CHANGED
|
@@ -51,7 +51,11 @@ import (
|
|
|
51
51
|
|
|
52
52
|
// ProtocolVersion is bumped whenever the control API changes shape, so the
|
|
53
53
|
// plugin can refuse a stale cached binary instead of failing in confusing ways.
|
|
54
|
-
|
|
54
|
+
//
|
|
55
|
+
// v2:新增出站流 /__tsnet/dial + /__tsnet/undial(SSH 走 tailnet 的前提)和
|
|
56
|
+
// 入站 /__tsnet/listen(把本机端口暴露到 tailnet)。v1 的二进制没有这两个端点,
|
|
57
|
+
// 而老插件钉的是 v1 那批 sha256 —— 所以只能新开 sidecar-v2,不能覆盖 v1 资产。
|
|
58
|
+
const ProtocolVersion = 2
|
|
55
59
|
|
|
56
60
|
var (
|
|
57
61
|
flHostname = flag.String("hostname", "", "tailnet node name (DNS label); required")
|