dsh-plugin-mesh 0.5.3 → 0.5.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/AGENTS.md +5 -4
- package/README.md +61 -1
- package/client/client.js +324 -122
- package/lib/_selftest-tsnet.mjs +173 -1
- package/lib/_selftest-workbench.mjs +53 -0
- package/lib/discovery.js +89 -18
- package/lib/index.js +543 -178
- package/lib/tsnet/channels.js +72 -0
- package/lib/tsnet/manager.js +187 -48
- package/llms.txt +17 -10
- package/package.json +2 -2
package/client/client.js
CHANGED
|
@@ -2723,13 +2723,24 @@ window.__ModuleLoader__.load({
|
|
|
2723
2723
|
? h("p", { className: "mesh-p" }, "对端还没有报告通道信息。等它下一次广播后会出现。")
|
|
2724
2724
|
: eps.map((ep, i) => {
|
|
2725
2725
|
const cooling = ep.downUntil && now < ep.downUntil;
|
|
2726
|
-
|
|
2726
|
+
// 多 tailnet:通道 key 才是端点身份(lan / tsnet:<id>),
|
|
2727
|
+
// 只比 transport 会把"局域网在用"错标到每条 tailnet 上。
|
|
2728
|
+
const epKey = ep.channel || ep.transport || "";
|
|
2729
|
+
const active = !!(peer.online && (peer.channel || peer.transport) && epKey === (peer.channel || peer.transport));
|
|
2727
2730
|
const state = active ? "在用" : cooling ? "冷却中" : ep.verified === false ? "未探测" : "备用";
|
|
2728
2731
|
const kind = active ? "ok" : cooling ? "warn" : "idle";
|
|
2729
|
-
const
|
|
2732
|
+
const channelTag =
|
|
2733
|
+
ep.transport === "tsnet"
|
|
2734
|
+
? epKey.startsWith("tsnet:cand:")
|
|
2735
|
+
? "候选地址"
|
|
2736
|
+
: epKey.startsWith("tsnet:")
|
|
2737
|
+
? epKey.slice("tsnet:".length)
|
|
2738
|
+
: ""
|
|
2739
|
+
: "";
|
|
2740
|
+
const label = ep.transport === "tsnet" ? (channelTag ? `互联网 · ${channelTag}` : "互联网") : "局域网";
|
|
2730
2741
|
return h(
|
|
2731
2742
|
"div",
|
|
2732
|
-
{ key: `ep-${
|
|
2743
|
+
{ key: `ep-${epKey}-${i}`, className: "mesh-channel" },
|
|
2733
2744
|
h("span", { className: "mesh-channel-icon" }, h(Icon, { name: ep.transport === "tsnet" ? "tailscale" : "wifi", size: 14 })),
|
|
2734
2745
|
h(
|
|
2735
2746
|
"span",
|
|
@@ -4208,9 +4219,56 @@ window.__ModuleLoader__.load({
|
|
|
4208
4219
|
);
|
|
4209
4220
|
}
|
|
4210
4221
|
|
|
4222
|
+
/** 单条通道的阶段 → 文案/颜色。 */
|
|
4223
|
+
function channelPhase(ch) {
|
|
4224
|
+
const p = ch && ch.node && ch.node.phase ? ch.node.phase : ch && ch.enabled ? "idle" : "off";
|
|
4225
|
+
const map = {
|
|
4226
|
+
off: ["未启用", "idle"],
|
|
4227
|
+
idle: ["未连接", "idle"],
|
|
4228
|
+
starting: ["正在启动", "warn"],
|
|
4229
|
+
downloading: ["正在下载组件", "warn"],
|
|
4230
|
+
"needs-login": ["需要授权", "warn"],
|
|
4231
|
+
running: ["已连接", "ok"],
|
|
4232
|
+
exited: ["已停止", "idle"],
|
|
4233
|
+
error: ["出错", "err"],
|
|
4234
|
+
};
|
|
4235
|
+
const m = map[p] || [p, "idle"];
|
|
4236
|
+
return { phase: p, label: m[0], kind: m[1] };
|
|
4237
|
+
}
|
|
4238
|
+
|
|
4239
|
+
/**
|
|
4240
|
+
* 汇总多条 tailnet 通道的状态。
|
|
4241
|
+
*
|
|
4242
|
+
* 多 tailnet 之后"连上没连上"不再是一个布尔值:3 条通道里连上 2 条,
|
|
4243
|
+
* 既要显示"已连接",又要让用户看见还差一条。所以标签带分数。
|
|
4244
|
+
*/
|
|
4211
4245
|
function tsnetPhase(tsnet) {
|
|
4212
|
-
|
|
4213
|
-
const
|
|
4246
|
+
if (!tsnet) return { phase: "off", label: "未启用", kind: "idle", channels: [], running: 0 };
|
|
4247
|
+
const channels = Array.isArray(tsnet.channels) ? tsnet.channels.slice() : [];
|
|
4248
|
+
// 旧主机只有单节点字段:合成一个通道视图,界面逻辑不分叉
|
|
4249
|
+
if (channels.length === 0 && tsnet.node) {
|
|
4250
|
+
channels.push({
|
|
4251
|
+
id: "default",
|
|
4252
|
+
label: "Tailscale",
|
|
4253
|
+
enabled: tsnet.enabled === true,
|
|
4254
|
+
authKeySaved: tsnet.authKeySaved === true,
|
|
4255
|
+
controlUrl: tsnet.controlUrl || "",
|
|
4256
|
+
hostname: (tsnet.node && tsnet.node.hostname) || "",
|
|
4257
|
+
node: tsnet.node,
|
|
4258
|
+
recentEvents: tsnet.recentEvents || [],
|
|
4259
|
+
});
|
|
4260
|
+
}
|
|
4261
|
+
const phases = channels.map((c) => channelPhase(c).phase);
|
|
4262
|
+
const running = phases.filter((p) => p === "running").length;
|
|
4263
|
+
let phase = tsnet.enabled ? "idle" : "off";
|
|
4264
|
+
if (running > 0) phase = "running";
|
|
4265
|
+
else if (phases.includes("needs-login")) phase = "needs-login";
|
|
4266
|
+
else if (phases.includes("downloading")) phase = "downloading";
|
|
4267
|
+
else if (phases.includes("starting")) phase = "starting";
|
|
4268
|
+
else if (phases.includes("error")) phase = "error";
|
|
4269
|
+
else if (phases.includes("exited")) phase = "exited";
|
|
4270
|
+
else if (channels.length === 0) phase = tsnet.enabled ? "idle" : "off";
|
|
4271
|
+
const base = channelPhase({ enabled: tsnet.enabled, node: null });
|
|
4214
4272
|
const map = {
|
|
4215
4273
|
off: ["未启用", "idle"],
|
|
4216
4274
|
idle: ["已启用 · 未启动", "idle"],
|
|
@@ -4221,72 +4279,120 @@ window.__ModuleLoader__.load({
|
|
|
4221
4279
|
exited: ["已停止", "idle"],
|
|
4222
4280
|
error: ["出错", "err"],
|
|
4223
4281
|
};
|
|
4224
|
-
|
|
4282
|
+
const m = map[phase] || base;
|
|
4283
|
+
let label = m[0];
|
|
4284
|
+
if (phase === "running" && channels.length > 1) label = `已连接 ${running}/${channels.length} 条`;
|
|
4285
|
+
return { phase, label, kind: m[1], channels, running };
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4288
|
+
/** 通道列表的公共视图:旧主机没有 channels 时用旧字段兜底。 */
|
|
4289
|
+
function tsnetChannelsOf(tsnet) {
|
|
4290
|
+
const list = tsnet && Array.isArray(tsnet.channels) ? tsnet.channels.slice() : [];
|
|
4291
|
+
if (list.length > 0) return list;
|
|
4292
|
+
if (tsnet && tsnet.node) {
|
|
4293
|
+
return [
|
|
4294
|
+
{
|
|
4295
|
+
id: "default",
|
|
4296
|
+
label: "Tailscale",
|
|
4297
|
+
enabled: tsnet.enabled === true,
|
|
4298
|
+
authKeySaved: tsnet.authKeySaved === true,
|
|
4299
|
+
controlUrl: tsnet.controlUrl || "",
|
|
4300
|
+
hostname: (tsnet.node && tsnet.node.hostname) || "",
|
|
4301
|
+
node: tsnet.node,
|
|
4302
|
+
recentEvents: tsnet.recentEvents || [],
|
|
4303
|
+
},
|
|
4304
|
+
];
|
|
4305
|
+
}
|
|
4306
|
+
return [];
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
/** 已连接通道的 tailnet 地址(供设置页/卡片显示一行摘要)。 */
|
|
4310
|
+
function tsnetAddressList(tsnet) {
|
|
4311
|
+
return tsnetChannelsOf(tsnet)
|
|
4312
|
+
.filter((c) => c.node && c.node.phase === "running")
|
|
4313
|
+
.map((c) => (c.node && c.node.selfIpv4) || "")
|
|
4314
|
+
.filter(Boolean);
|
|
4225
4315
|
}
|
|
4226
4316
|
|
|
4227
4317
|
function TsnetBody({ tsnet, push, reload }) {
|
|
4228
|
-
const [key, setKey] = react.useState("");
|
|
4229
|
-
const [controlUrl, setControlUrl] = react.useState((tsnet && tsnet.controlUrl) || "");
|
|
4230
4318
|
const [busy, setBusy] = react.useState("");
|
|
4231
4319
|
const [error, setError] = react.useState("");
|
|
4232
|
-
|
|
4233
|
-
react.
|
|
4234
|
-
|
|
4235
|
-
}, [tsnet && tsnet.controlUrl]);
|
|
4320
|
+
const [draftLabel, setDraftLabel] = react.useState("");
|
|
4321
|
+
const [draftKey, setDraftKey] = react.useState("");
|
|
4322
|
+
const [draftControl, setDraftControl] = react.useState("");
|
|
4236
4323
|
|
|
4237
4324
|
if (!tsnet) {
|
|
4238
4325
|
return h("p", { className: "mesh-p" }, "当前主机版本还没有跨网络组网能力。升级插件后会出现在这里。");
|
|
4239
4326
|
}
|
|
4240
4327
|
|
|
4241
|
-
const
|
|
4328
|
+
const channels = tsnetChannelsOf(tsnet);
|
|
4242
4329
|
const phase = tsnetPhase(tsnet);
|
|
4243
|
-
const running = phase.
|
|
4244
|
-
const events = (
|
|
4245
|
-
const canConnect = !!(tsnet.authKeySaved || key.trim());
|
|
4330
|
+
const running = phase.running;
|
|
4331
|
+
const events = (channels.find((c) => c.node && c.node.phase === "running")?.recentEvents || channels[0]?.recentEvents || tsnet.recentEvents || []).slice(-6);
|
|
4246
4332
|
|
|
4247
|
-
const
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
return;
|
|
4251
|
-
}
|
|
4252
|
-
setBusy("connect");
|
|
4333
|
+
const run = async (path, body, okText) => {
|
|
4334
|
+
const tag = `${path}${body && body.id ? `:${body.id}` : ""}`;
|
|
4335
|
+
setBusy(tag);
|
|
4253
4336
|
setError("");
|
|
4254
4337
|
try {
|
|
4255
|
-
const
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
if (!saved || !saved.ok) {
|
|
4261
|
-
setError(`保存失败:${apiErr(saved)}`);
|
|
4262
|
-
return;
|
|
4263
|
-
}
|
|
4264
|
-
setKey("");
|
|
4265
|
-
const started = await api("/tsnet/start", {});
|
|
4266
|
-
if (started && started.ok) {
|
|
4267
|
-
push("success", "已开始连接。授权码只保存在本机,之后不用再填。");
|
|
4268
|
-
} else {
|
|
4269
|
-
push("error", `启动失败:${apiErr(started)}`);
|
|
4338
|
+
const r = await api(path, body || {});
|
|
4339
|
+
if (r && r.ok) {
|
|
4340
|
+
push("success", okText || "完成");
|
|
4341
|
+
await reload();
|
|
4342
|
+
return r;
|
|
4270
4343
|
}
|
|
4271
|
-
|
|
4344
|
+
setError(apiErr(r));
|
|
4345
|
+
return r;
|
|
4272
4346
|
} catch (e) {
|
|
4273
4347
|
setError(String((e && e.message) || e));
|
|
4348
|
+
return null;
|
|
4274
4349
|
} finally {
|
|
4275
4350
|
setBusy("");
|
|
4276
4351
|
}
|
|
4277
4352
|
};
|
|
4278
4353
|
|
|
4279
|
-
|
|
4280
|
-
|
|
4354
|
+
// 保存通道列表时只回传非敏感字段;授权码留空 = 保留原值(宿主按 id 合并)。
|
|
4355
|
+
const payloadOf = (list) =>
|
|
4356
|
+
list.map((c) => ({
|
|
4357
|
+
id: c.id,
|
|
4358
|
+
label: c.label,
|
|
4359
|
+
controlUrl: c.controlUrl || "",
|
|
4360
|
+
hostname: c.hostname || "",
|
|
4361
|
+
enabled: c.enabled !== false,
|
|
4362
|
+
}));
|
|
4363
|
+
|
|
4364
|
+
const addChannel = async () => {
|
|
4365
|
+
if (!draftKey.trim()) {
|
|
4366
|
+
setError("先填入授权码。");
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4369
|
+
setBusy("add");
|
|
4281
4370
|
setError("");
|
|
4282
4371
|
try {
|
|
4283
|
-
const
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4372
|
+
const next = [
|
|
4373
|
+
...payloadOf(channels),
|
|
4374
|
+
{
|
|
4375
|
+
label: draftLabel.trim() || `Tailnet ${channels.length + 1}`,
|
|
4376
|
+
authKey: draftKey.trim(),
|
|
4377
|
+
controlUrl: draftControl.trim(),
|
|
4378
|
+
enabled: true,
|
|
4379
|
+
},
|
|
4380
|
+
];
|
|
4381
|
+
const saved = await api("/tsnet/config", { channels: next });
|
|
4382
|
+
if (!saved || !saved.ok) {
|
|
4383
|
+
setError(`保存失败:${apiErr(saved)}`);
|
|
4384
|
+
return;
|
|
4289
4385
|
}
|
|
4386
|
+
const created = (saved.channels || []).find((c) => !channels.some((x) => x.id === c.id));
|
|
4387
|
+
if (created) {
|
|
4388
|
+
const started = await api("/tsnet/start", { id: created.id });
|
|
4389
|
+
if (started && started.ok) push("success", `通道「${created.label}」已开始连接。授权码只保存在本机。`);
|
|
4390
|
+
else push("error", `通道已保存,但启动失败:${apiErr(started)}`);
|
|
4391
|
+
}
|
|
4392
|
+
setDraftLabel("");
|
|
4393
|
+
setDraftKey("");
|
|
4394
|
+
setDraftControl("");
|
|
4395
|
+
await reload();
|
|
4290
4396
|
} catch (e) {
|
|
4291
4397
|
setError(String((e && e.message) || e));
|
|
4292
4398
|
} finally {
|
|
@@ -4294,60 +4400,158 @@ window.__ModuleLoader__.load({
|
|
|
4294
4400
|
}
|
|
4295
4401
|
};
|
|
4296
4402
|
|
|
4403
|
+
const removeChannel = async (ch) => {
|
|
4404
|
+
const next = payloadOf(channels.filter((c) => c.id !== ch.id));
|
|
4405
|
+
// 最后一条也允许删:宿主会顺带清掉旧版单通道字段并关闭组网,
|
|
4406
|
+
// 否则"删不掉、也关不干净"会变成又一处静默残留。
|
|
4407
|
+
await run(
|
|
4408
|
+
"/tsnet/config",
|
|
4409
|
+
{ channels: next },
|
|
4410
|
+
next.length === 0 ? "所有通道已删除,跨网络组网已关闭" : `通道「${ch.label || ch.id}」已删除`,
|
|
4411
|
+
);
|
|
4412
|
+
};
|
|
4413
|
+
|
|
4414
|
+
const updateEnabled = async (ch, enabled) => {
|
|
4415
|
+
const next = payloadOf(channels).map((c) => (c.id === ch.id ? { ...c, enabled } : c));
|
|
4416
|
+
await run("/tsnet/config", { channels: next }, enabled ? "通道已启用" : "通道已停用");
|
|
4417
|
+
};
|
|
4418
|
+
|
|
4297
4419
|
return h(
|
|
4298
4420
|
"div",
|
|
4299
4421
|
null,
|
|
4300
4422
|
h(
|
|
4301
4423
|
"p",
|
|
4302
4424
|
{ className: "mesh-p", style: { marginBottom: 12 } },
|
|
4303
|
-
"让不在同一网络的电脑也能互相派发任务。使用同一套设备列表,不需要另装 Tailscale
|
|
4425
|
+
"让不在同一网络的电脑也能互相派发任务。使用同一套设备列表,不需要另装 Tailscale 客户端。一台机器可以同时加入多个 tailnet:设备身份仍然只有一个,每条通道只是它的一条路。",
|
|
4304
4426
|
),
|
|
4305
|
-
|
|
4427
|
+
channels.length === 0
|
|
4306
4428
|
? h(
|
|
4307
4429
|
"div",
|
|
4308
|
-
{ className: "mesh-note
|
|
4309
|
-
h(Icon, { name: "
|
|
4430
|
+
{ className: "mesh-note" },
|
|
4431
|
+
h(Icon, { name: "key", size: 13 }),
|
|
4310
4432
|
h("span", null,
|
|
4311
|
-
"
|
|
4312
|
-
h("a", { href:
|
|
4433
|
+
"还没有配置 tailnet 通道。需要一个 Tailscale 授权码:打开 ",
|
|
4434
|
+
h("a", { href: TS_KEYS_URL, target: "_blank", rel: "noreferrer" }, TS_KEYS_URL),
|
|
4435
|
+
" 登录后点 Generate auth key;生成时勾选 Reusable,如果后台开了设备审批再勾 Pre-approved。",
|
|
4313
4436
|
),
|
|
4314
4437
|
)
|
|
4315
4438
|
: null,
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
h("span", null, String(node.error)),
|
|
4322
|
-
)
|
|
4323
|
-
: null,
|
|
4324
|
-
phase.phase === "downloading"
|
|
4325
|
-
? h(
|
|
4326
|
-
"div",
|
|
4327
|
-
{ className: "mesh-note" },
|
|
4328
|
-
h("span", { className: "mesh-spinner" }),
|
|
4329
|
-
h("span", null, `正在下载组件${node && node.downloadPercent ? ` · ${node.downloadPercent}%` : ""}。第一次使用会稍慢,之后不再下载。`),
|
|
4330
|
-
)
|
|
4331
|
-
: null,
|
|
4332
|
-
h(
|
|
4333
|
-
Collapse,
|
|
4334
|
-
{ open: running },
|
|
4335
|
-
h(
|
|
4439
|
+
channels.map((ch) => {
|
|
4440
|
+
const cp = channelPhase(ch);
|
|
4441
|
+
const node = ch.node || null;
|
|
4442
|
+
const isBusy = !!busy;
|
|
4443
|
+
return h(
|
|
4336
4444
|
"div",
|
|
4337
|
-
{ className: "mesh-channel" },
|
|
4338
|
-
h("span", { className: "mesh-channel-icon" }, h(Icon, { name: "tailscale", size: 14 })),
|
|
4445
|
+
{ key: ch.id, className: "mesh-channel-card", style: { marginBottom: 10 } },
|
|
4339
4446
|
h(
|
|
4340
|
-
"
|
|
4341
|
-
{ className: "mesh-channel
|
|
4342
|
-
h("span", { className: "mesh-channel-
|
|
4343
|
-
h(
|
|
4447
|
+
"div",
|
|
4448
|
+
{ className: "mesh-channel" },
|
|
4449
|
+
h("span", { className: "mesh-channel-icon" }, h(Icon, { name: "tailscale", size: 14 })),
|
|
4450
|
+
h(
|
|
4451
|
+
"span",
|
|
4452
|
+
{ className: "mesh-channel-main" },
|
|
4453
|
+
h(
|
|
4454
|
+
"span",
|
|
4455
|
+
{ className: "mesh-channel-title" },
|
|
4456
|
+
ch.label || "Tailscale",
|
|
4457
|
+
h(Badge, { kind: cp.kind }, cp.label),
|
|
4458
|
+
ch.id !== "default" ? h("span", { className: "mesh-channel-sub", style: { marginLeft: 6 } }, ch.id) : null,
|
|
4459
|
+
),
|
|
4460
|
+
h(
|
|
4461
|
+
"span",
|
|
4462
|
+
{ className: "mesh-channel-sub" },
|
|
4463
|
+
node && node.selfIpv4
|
|
4464
|
+
? [node.selfIpv4, node.selfDnsName].filter(Boolean).join(" · ")
|
|
4465
|
+
: ch.authKeySaved
|
|
4466
|
+
? `已保存授权码${ch.controlUrl ? ` · ${ch.controlUrl}` : " · 官方 Tailscale"}`
|
|
4467
|
+
: "未设置授权码",
|
|
4468
|
+
),
|
|
4469
|
+
),
|
|
4470
|
+
cp.phase === "running"
|
|
4471
|
+
? h(
|
|
4472
|
+
Button,
|
|
4473
|
+
{
|
|
4474
|
+
variant: "ghost",
|
|
4475
|
+
size: "sm",
|
|
4476
|
+
loading: busy === `/tsnet/stop:${ch.id}`,
|
|
4477
|
+
disabled: isBusy && busy !== `/tsnet/stop:${ch.id}`,
|
|
4478
|
+
onClick: () => run("/tsnet/stop", { id: ch.id }, `通道「${ch.label || ch.id}」已断开`),
|
|
4479
|
+
},
|
|
4480
|
+
"断开",
|
|
4481
|
+
)
|
|
4482
|
+
: h(
|
|
4483
|
+
Button,
|
|
4484
|
+
{
|
|
4485
|
+
variant: "ghost",
|
|
4486
|
+
size: "sm",
|
|
4487
|
+
loading: busy === `/tsnet/start:${ch.id}`,
|
|
4488
|
+
disabled: isBusy && busy !== `/tsnet/start:${ch.id}`,
|
|
4489
|
+
onClick: () => run("/tsnet/start", { id: ch.id }, `通道「${ch.label || ch.id}」已启动`),
|
|
4490
|
+
},
|
|
4491
|
+
"连接",
|
|
4492
|
+
),
|
|
4344
4493
|
),
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4494
|
+
node && node.authUrl
|
|
4495
|
+
? h(
|
|
4496
|
+
"div",
|
|
4497
|
+
{ className: "mesh-note is-warn" },
|
|
4498
|
+
h(Icon, { name: "alert", size: 13 }),
|
|
4499
|
+
h("span", null,
|
|
4500
|
+
"这条通道需要你授权加入 tailnet:",
|
|
4501
|
+
h("a", { href: node.authUrl, target: "_blank", rel: "noreferrer", style: { marginLeft: 4, wordBreak: "break-all" } }, "打开授权页"),
|
|
4502
|
+
),
|
|
4503
|
+
)
|
|
4504
|
+
: null,
|
|
4505
|
+
node && node.error
|
|
4506
|
+
? h(
|
|
4507
|
+
"div",
|
|
4508
|
+
{ className: "mesh-note is-err" },
|
|
4509
|
+
h(Icon, { name: "alert", size: 13 }),
|
|
4510
|
+
h("span", null, String(node.error)),
|
|
4511
|
+
)
|
|
4512
|
+
: null,
|
|
4513
|
+
cp.phase === "downloading"
|
|
4514
|
+
? h(
|
|
4515
|
+
"div",
|
|
4516
|
+
{ className: "mesh-note" },
|
|
4517
|
+
h("span", { className: "mesh-spinner" }),
|
|
4518
|
+
h("span", null, `正在下载组件${node && node.downloadPercent ? ` · ${node.downloadPercent}%` : ""}。第一次使用会稍慢,之后不再下载。`),
|
|
4519
|
+
)
|
|
4520
|
+
: null,
|
|
4521
|
+
h(
|
|
4522
|
+
Fold,
|
|
4523
|
+
{ title: "通道设置", right: ch.controlUrl ? "自定义控制服务器" : "官方 Tailscale" },
|
|
4524
|
+
h(
|
|
4525
|
+
"dl",
|
|
4526
|
+
{ className: "mesh-kv" },
|
|
4527
|
+
h("dt", null, "通道 id"), h("dd", null, ch.id),
|
|
4528
|
+
h("dt", null, "节点名"), h("dd", null, (node && node.hostname) || ch.hostname || "—"),
|
|
4529
|
+
h("dt", null, "控制服务器"), h("dd", null, ch.controlUrl || "官方"),
|
|
4530
|
+
h("dt", null, "授权码"), h("dd", null, ch.authKeySaved ? "已保存(不会显示内容)" : "未设置"),
|
|
4531
|
+
),
|
|
4532
|
+
h(
|
|
4533
|
+
"div",
|
|
4534
|
+
{ className: "mesh-actions-row" },
|
|
4535
|
+
h(Button, { variant: "ghost", size: "sm", disabled: !!busy || cp.phase !== "running", loading: busy === `/tsnet/scan:${ch.id}`, onClick: () => run("/tsnet/scan", { id: ch.id }, "已扫描该通道") }, "扫描该通道"),
|
|
4536
|
+
h(ConfirmButton, {
|
|
4537
|
+
label: "重新登录",
|
|
4538
|
+
confirmLabel: "确认清除身份?",
|
|
4539
|
+
disabled: !!busy || !ch.authKeySaved,
|
|
4540
|
+
onConfirm: () => run("/tsnet/relogin", { id: ch.id }, "已清除节点身份,等待重新授权"),
|
|
4541
|
+
}),
|
|
4542
|
+
h(ConfirmButton, {
|
|
4543
|
+
label: "删除通道",
|
|
4544
|
+
confirmLabel: "确认删除?",
|
|
4545
|
+
disabled: !!busy,
|
|
4546
|
+
onConfirm: () => removeChannel(ch),
|
|
4547
|
+
}),
|
|
4548
|
+
),
|
|
4549
|
+
),
|
|
4550
|
+
);
|
|
4551
|
+
}),
|
|
4348
4552
|
h(
|
|
4349
|
-
|
|
4350
|
-
{
|
|
4553
|
+
Fold,
|
|
4554
|
+
{ title: channels.length ? "添加通道" : "配置第一条通道", right: "多 tailnet", defaultOpen: channels.length === 0 },
|
|
4351
4555
|
h(
|
|
4352
4556
|
"div",
|
|
4353
4557
|
null,
|
|
@@ -4356,21 +4560,39 @@ window.__ModuleLoader__.load({
|
|
|
4356
4560
|
{ className: "mesh-note" },
|
|
4357
4561
|
h(Icon, { name: "key", size: 13 }),
|
|
4358
4562
|
h("span", null,
|
|
4359
|
-
"
|
|
4360
|
-
h("a", { href: TS_KEYS_URL, target: "_blank", rel: "noreferrer" }, TS_KEYS_URL),
|
|
4361
|
-
" 登录后点 Generate auth key;生成时勾选 Reusable,如果后台开了设备审批再勾 Pre-approved。",
|
|
4563
|
+
"每条通道对应一个 tailnet(一把 tskey 一把钥匙,但可以加多条)。名称只用于本机显示;重命名不影响设备身份。",
|
|
4362
4564
|
),
|
|
4363
4565
|
),
|
|
4364
4566
|
h(
|
|
4365
4567
|
Field,
|
|
4366
|
-
{ label: "
|
|
4568
|
+
{ label: "名称(可选)", hint: "例如「个人」「公司」;留空自动命名。" },
|
|
4569
|
+
h("input", {
|
|
4570
|
+
className: "mesh-input",
|
|
4571
|
+
value: draftLabel,
|
|
4572
|
+
placeholder: "公司 tailnet",
|
|
4573
|
+
onChange: (e) => setDraftLabel(e.target.value),
|
|
4574
|
+
}),
|
|
4575
|
+
),
|
|
4576
|
+
h(
|
|
4577
|
+
Field,
|
|
4578
|
+
{ label: "授权码", hint: "只保存在本机;粘贴新值会新增一条通道。" },
|
|
4367
4579
|
h("input", {
|
|
4368
4580
|
className: "mesh-input",
|
|
4369
4581
|
type: "password",
|
|
4370
4582
|
autoComplete: "off",
|
|
4371
|
-
value:
|
|
4372
|
-
placeholder:
|
|
4373
|
-
onChange: (e) =>
|
|
4583
|
+
value: draftKey,
|
|
4584
|
+
placeholder: "tskey-auth-…",
|
|
4585
|
+
onChange: (e) => setDraftKey(e.target.value),
|
|
4586
|
+
}),
|
|
4587
|
+
),
|
|
4588
|
+
h(
|
|
4589
|
+
Field,
|
|
4590
|
+
{ label: "控制服务器(可选)", hint: "留空用官方 Tailscale;Headscale 用户填自己的地址。" },
|
|
4591
|
+
h("input", {
|
|
4592
|
+
className: "mesh-input",
|
|
4593
|
+
value: draftControl,
|
|
4594
|
+
placeholder: "https://controlplane.tailscale.com",
|
|
4595
|
+
onChange: (e) => setDraftControl(e.target.value),
|
|
4374
4596
|
}),
|
|
4375
4597
|
),
|
|
4376
4598
|
h(
|
|
@@ -4378,44 +4600,24 @@ window.__ModuleLoader__.load({
|
|
|
4378
4600
|
{ className: "mesh-actions-row" },
|
|
4379
4601
|
h(
|
|
4380
4602
|
Button,
|
|
4381
|
-
{ variant: "primary", icon: "plug", loading: busy === "
|
|
4382
|
-
|
|
4603
|
+
{ variant: "primary", icon: "plug", loading: busy === "add", disabled: !!busy || !draftKey.trim(), onClick: addChannel },
|
|
4604
|
+
"添加并连接",
|
|
4383
4605
|
),
|
|
4384
|
-
tsnet.enabled && !running && tsnet.authKeySaved
|
|
4385
|
-
? h(Button, { variant: "ghost", loading: busy === "/tsnet/start", onClick: () => runNode("/tsnet/start", "已启动") }, "只启动")
|
|
4386
|
-
: null,
|
|
4387
4606
|
),
|
|
4388
4607
|
),
|
|
4389
4608
|
),
|
|
4390
4609
|
h(
|
|
4391
4610
|
Fold,
|
|
4392
|
-
{ title: "
|
|
4393
|
-
h(
|
|
4394
|
-
Field,
|
|
4395
|
-
{ label: "控制服务器", hint: "留空用官方 Tailscale;Headscale 用户填自己的地址。修改后点“保存并重启”。" },
|
|
4396
|
-
h("input", {
|
|
4397
|
-
className: "mesh-input",
|
|
4398
|
-
value: controlUrl,
|
|
4399
|
-
placeholder: "https://controlplane.tailscale.com",
|
|
4400
|
-
onChange: (e) => setControlUrl(e.target.value),
|
|
4401
|
-
}),
|
|
4402
|
-
),
|
|
4611
|
+
{ title: "维护", right: running ? "扫描与组件" : undefined },
|
|
4403
4612
|
h(
|
|
4404
4613
|
"div",
|
|
4405
4614
|
{ className: "mesh-actions-row" },
|
|
4406
|
-
h(Button, { variant: "ghost", size: "sm", disabled:
|
|
4407
|
-
h(Button, { variant: "ghost", size: "sm", disabled: !canConnect || !!busy, loading: busy === "connect", onClick: saveAndConnect }, "保存并重启"),
|
|
4408
|
-
h(ConfirmButton, {
|
|
4409
|
-
label: "重新登录",
|
|
4410
|
-
confirmLabel: "确认清除身份?",
|
|
4411
|
-
disabled: !tsnet.enabled || !!busy,
|
|
4412
|
-
onConfirm: () => runNode("/tsnet/relogin", "已清除节点身份,等待重新授权"),
|
|
4413
|
-
}),
|
|
4615
|
+
h(Button, { variant: "ghost", size: "sm", disabled: !!busy || running === 0, loading: busy === "/tsnet/scan", onClick: () => run("/tsnet/scan", {}, "已扫描所有通道") }, "扫描所有通道"),
|
|
4414
4616
|
h(ConfirmButton, {
|
|
4415
4617
|
label: "重新下载组件",
|
|
4416
4618
|
confirmLabel: "确认重新下载?",
|
|
4417
|
-
disabled:
|
|
4418
|
-
onConfirm: () =>
|
|
4619
|
+
disabled: !!busy,
|
|
4620
|
+
onConfirm: () => run("/tsnet/reinstall", {}, "已重新下载组件"),
|
|
4419
4621
|
}),
|
|
4420
4622
|
),
|
|
4421
4623
|
events.length
|
|
@@ -4534,8 +4736,8 @@ window.__ModuleLoader__.load({
|
|
|
4534
4736
|
id: "tsnet",
|
|
4535
4737
|
icon: "tailscale",
|
|
4536
4738
|
title: "互联网组网",
|
|
4537
|
-
subtitle: tsnet.enabled
|
|
4538
|
-
? `${phase.label}${tsnet.
|
|
4739
|
+
subtitle: tsnet.enabled || tsnetAddressList(tsnet).length
|
|
4740
|
+
? `${phase.label}${tsnetAddressList(tsnet).length ? ` · ${tsnetAddressList(tsnet)[0]}` : ""}`
|
|
4539
4741
|
: "未启用 · 跨网络互联(Tailscale)",
|
|
4540
4742
|
status: h(Badge, { kind: phase.kind }, phase.label),
|
|
4541
4743
|
open: open === "tsnet",
|
|
@@ -4752,8 +4954,8 @@ window.__ModuleLoader__.load({
|
|
|
4752
4954
|
children: h(
|
|
4753
4955
|
"p",
|
|
4754
4956
|
{ className: "mesh-card-text" },
|
|
4755
|
-
tsnet
|
|
4756
|
-
? `已连接
|
|
4957
|
+
tsnetAddressList(tsnet).length
|
|
4958
|
+
? `已连接 ${tsnetAddressList(tsnet).length} 条通道 · ${tsnetAddressList(tsnet).join(" · ")}`
|
|
4757
4959
|
: "让不在同一网络的电脑也能互相派发任务。需要免费的 Tailscale 账号,授权码只保存一次。",
|
|
4758
4960
|
),
|
|
4759
4961
|
footer: h(Button, { variant: "ghost", size: "sm", icon: "tailscale", onClick: () => onConnect("tsnet") }, "设置互联网组网"),
|
|
@@ -5703,8 +5905,8 @@ window.__ModuleLoader__.load({
|
|
|
5703
5905
|
children: h(
|
|
5704
5906
|
"p",
|
|
5705
5907
|
{ className: "mesh-card-text" },
|
|
5706
|
-
tsnet
|
|
5707
|
-
? `已连接
|
|
5908
|
+
tsnetAddressList(tsnet).length
|
|
5909
|
+
? `已连接 ${tsnetAddressList(tsnet).length} 条通道 · ${tsnetAddressList(tsnet).join(" · ")}`
|
|
5708
5910
|
: "让不在同一网络的电脑也能互相派发任务。需要免费的 Tailscale 账号,授权码只保存一次。",
|
|
5709
5911
|
),
|
|
5710
5912
|
footer: h(Button, { variant: "ghost", size: "sm", icon: "tailscale", onClick: () => onConnect("tsnet") }, "设置互联网组网"),
|