ssh-net 0.2.0 → 0.2.1
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 +11 -0
- package/README.md +5 -4
- package/libexec/commands/install.mjs +7 -3
- package/libexec/commands/restart.mjs +5 -5
- package/libexec/commands/start.mjs +8 -8
- package/libexec/commands/status.mjs +81 -45
- package/libexec/commands/stop.mjs +3 -3
- package/libexec/commands/uninstall.mjs +3 -3
- package/libexec/lib/runtime.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
本项目版本号与发布节奏仿 mihomo-cli:npm 公共分发,版本即升级动作。
|
|
4
4
|
|
|
5
|
+
## [0.2.1] - 2026-09-29
|
|
6
|
+
|
|
7
|
+
### 变更
|
|
8
|
+
|
|
9
|
+
- 用户可见文案整体翻新(status / 命令返回 / 问题提示):status 按
|
|
10
|
+
「隧道开关 → 当前线路 → 可用性」组织,内部术语(脚本 ok、注册口、
|
|
11
|
+
last exit 等)只在异常处出现,每条问题都附下一步动作;健康时更安静
|
|
12
|
+
(版本一致不再单列版本行)。命令返回改说结果(「安装完成,对外通道
|
|
13
|
+
已开启」「隧道已开启(数秒内建立)」),不再暴露 launchd/PathState
|
|
14
|
+
等机制词。
|
|
15
|
+
|
|
5
16
|
## [0.2.0] - 2026-09-29
|
|
6
17
|
|
|
7
18
|
### 变更(产物布局变化:升级后各机需重跑 `ssh-net install`)
|
package/README.md
CHANGED
|
@@ -78,7 +78,8 @@ npm link # 开发机:控制面改即时生效(运行时脚本仍
|
|
|
78
78
|
|
|
79
79
|
## 状态
|
|
80
80
|
|
|
81
|
-
0.2.0 已发布 npm(2026-09-29
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
0.2.0 已发布 npm(2026-09-29:运行时实体拷贝 + runtime-version 戳、状态并入
|
|
82
|
+
`~/.ssh/ssh-net/`、弃 known-hosts、新增迁移期 cleanup)。部署:m4/n007/
|
|
83
|
+
n061/mb5 四台已上线,新 Match 与 at 联动在办公室实测全通(peer 一跳登 m4、
|
|
84
|
+
SOCKS 1090、VNC、node relay);在家项(公网 v6 闸门/回落演练/合盖开盖)与
|
|
85
|
+
mb1(Phase 5)待办。
|
|
@@ -65,7 +65,9 @@ function installEdge(ctx) {
|
|
|
65
65
|
plistPath: path.join(paths.launchAgentsDir, plistFileName(linkLabel(topo.core.alias))),
|
|
66
66
|
content,
|
|
67
67
|
});
|
|
68
|
-
return
|
|
68
|
+
return r.unchanged
|
|
69
|
+
? '已安装,无需改动'
|
|
70
|
+
: '安装完成。隧道默认关闭——at home(或 ssh-net start)开启';
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
function installCore(ctx) {
|
|
@@ -85,7 +87,9 @@ function installCore(ctx) {
|
|
|
85
87
|
plistPath: path.join(paths.launchAgentsDir, plistFileName(label)),
|
|
86
88
|
content,
|
|
87
89
|
});
|
|
88
|
-
return
|
|
90
|
+
return r.unchanged
|
|
91
|
+
? '已安装,无需改动'
|
|
92
|
+
: `安装完成,对外通道已开启(s100 入口 ${topo.core.relayPort})`;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
function installNode(ctx) {
|
|
@@ -115,7 +119,7 @@ function installNode(ctx) {
|
|
|
115
119
|
]) {
|
|
116
120
|
if (r.code !== 0) throw new Error(`systemctl 失败:${r.stderr.trim()}`);
|
|
117
121
|
}
|
|
118
|
-
return
|
|
122
|
+
return `安装完成,对外通道已开启(s100 入口 ${ctx.self.relayPort})`;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
/** @param {object} ctx */
|
|
@@ -10,21 +10,21 @@ export function run(ctx) {
|
|
|
10
10
|
const label = linkLabel(ctx.topo.core.alias);
|
|
11
11
|
// kickstartEnabled:与 core 同规则,残留 disabled override 时不被拒
|
|
12
12
|
const r = launchd.kickstartEnabled(ctx.runner, ctx.uid, label);
|
|
13
|
-
if (r.code !== 0) throw new Error(
|
|
14
|
-
return '
|
|
13
|
+
if (r.code !== 0) throw new Error(`重启失败:${r.stderr.trim()}`);
|
|
14
|
+
return '隧道已重启(重新选路中)';
|
|
15
15
|
}
|
|
16
16
|
if (ctx.role === 'core') {
|
|
17
17
|
const label = relayLabel(ctx.topo.relay.alias);
|
|
18
18
|
if (!launchd.inspect(ctx.runner, ctx.uid, label).registered)
|
|
19
19
|
throw new Error('uplink-relay 未注册(已 stop?先 ssh-net start)');
|
|
20
20
|
const r = launchd.kickstartEnabled(ctx.runner, ctx.uid, label);
|
|
21
|
-
if (r.code !== 0) throw new Error(
|
|
22
|
-
return '
|
|
21
|
+
if (r.code !== 0) throw new Error(`重启失败:${r.stderr.trim()}`);
|
|
22
|
+
return '对外通道已重启';
|
|
23
23
|
}
|
|
24
24
|
if (ctx.role === 'node') {
|
|
25
25
|
const r = systemd.restartUnit(ctx.runner, relayUnitName(ctx.topo.relay.alias));
|
|
26
26
|
if (r.code !== 0) throw new Error(`systemctl restart 失败:${r.stderr.trim()}`);
|
|
27
|
-
return '
|
|
27
|
+
return '对外通道已重启';
|
|
28
28
|
}
|
|
29
29
|
throw new Error(`未知角色:${ctx.role}`);
|
|
30
30
|
}
|
|
@@ -9,23 +9,23 @@ import { linkLabel, relayLabel, relayUnitName, plistFileName } from '../lib/rend
|
|
|
9
9
|
function startCore(ctx) {
|
|
10
10
|
const label = relayLabel(ctx.topo.relay.alias);
|
|
11
11
|
const plist = path.join(ctx.paths.launchAgentsDir, plistFileName(label));
|
|
12
|
-
if (!fs.existsSync(plist)) throw new Error(
|
|
12
|
+
if (!fs.existsSync(plist)) throw new Error(`尚未安装(缺 ${plist}),先跑 ssh-net install`);
|
|
13
13
|
const st = launchd.inspect(ctx.runner, ctx.uid, label);
|
|
14
14
|
if (!st.registered) {
|
|
15
15
|
launchd.enable(ctx.runner, ctx.uid, label);
|
|
16
16
|
const r = launchd.bootstrap(ctx.runner, ctx.uid, plist);
|
|
17
|
-
if (r.code !== 0) throw new Error(
|
|
18
|
-
return '
|
|
17
|
+
if (r.code !== 0) throw new Error(`启动失败:${r.stderr.trim()}`);
|
|
18
|
+
return '对外通道已开启';
|
|
19
19
|
}
|
|
20
20
|
if (!st.running) {
|
|
21
21
|
// kickstartEnabled:kickstart 对 disabled job 被拒(stop 中途失败/手工
|
|
22
22
|
// disable 的残留态),先幂等 enable
|
|
23
23
|
const r = launchd.kickstartEnabled(ctx.runner, ctx.uid, label);
|
|
24
|
-
if (r.code !== 0) throw new Error(
|
|
25
|
-
return '
|
|
24
|
+
if (r.code !== 0) throw new Error(`启动失败:${r.stderr.trim()}`);
|
|
25
|
+
return '对外通道已重新拉起';
|
|
26
26
|
}
|
|
27
27
|
if (st.disabled) launchd.enable(ctx.runner, ctx.uid, label); // 在跑但 override 残留:清掉防退出后不重拉
|
|
28
|
-
return '
|
|
28
|
+
return '对外通道已在运行';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function run(ctx) {
|
|
@@ -34,13 +34,13 @@ export function run(ctx) {
|
|
|
34
34
|
if (!launchd.inspect(ctx.runner, ctx.uid, label).registered)
|
|
35
35
|
throw new Error(`link job 未注册(先 ssh-net install):launchctl print gui/${ctx.uid}/${label}`);
|
|
36
36
|
ctx.state.setOn();
|
|
37
|
-
return '
|
|
37
|
+
return '隧道已开启(数秒内建立;ssh-net status 查看线路)';
|
|
38
38
|
}
|
|
39
39
|
if (ctx.role === 'core') return startCore(ctx);
|
|
40
40
|
if (ctx.role === 'node') {
|
|
41
41
|
const r = systemd.startUnit(ctx.runner, relayUnitName(ctx.topo.relay.alias));
|
|
42
42
|
if (r.code !== 0) throw new Error(`systemctl start 失败:${r.stderr.trim()}`);
|
|
43
|
-
return '
|
|
43
|
+
return '对外通道已开启';
|
|
44
44
|
}
|
|
45
45
|
throw new Error(`未知角色:${ctx.role}`);
|
|
46
46
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// status(design §6.7):只报本机角色,判据是 banner/端口/注册态真实探测。
|
|
2
|
-
// collect 返回结构化对象(测试断言对象,不锁文本);renderText
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// collect 返回结构化对象(测试断言对象,不锁文本);renderText 给人看——
|
|
3
|
+
// 2026-09-29 起按用户视角组织:先答「隧道开没开、现在走哪条路、东西能不能用」,
|
|
4
|
+
// 内部名词(脚本/注册口/last exit)只在异常时出现,且每条问题都带下一步动作。
|
|
5
|
+
// 退出码:健康(含 edge 关闭态)0;有可行动问题 1。
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import { auditScript, readRuntimeVersion, runtimeVersionIssue } from '../lib/runtime.mjs';
|
|
7
8
|
import { packageScriptPath } from '../lib/paths.mjs';
|
|
@@ -20,12 +21,19 @@ function auditRequired(ctx, entries) {
|
|
|
20
21
|
}));
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
/**
|
|
24
|
+
/** 版本对账问题(各角色共用);版本值不单列展示,不一致才说话。 */
|
|
24
25
|
function versionInfo(ctx) {
|
|
25
26
|
const issue = runtimeVersionIssue(ctx.paths);
|
|
26
27
|
return { issue, runtimeVersion: readRuntimeVersion(ctx.paths) };
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/** forward 的人话标签:dynamic 是 SOCKS,local 写出目标。 */
|
|
31
|
+
function forwardLabel(f) {
|
|
32
|
+
return f.kind === 'dynamic'
|
|
33
|
+
? `SOCKS 代理 127.0.0.1:${f.listenPort}`
|
|
34
|
+
: `端口转发 127.0.0.1:${f.listenPort} → ${f.targetAlias}:${f.targetPort}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
function relayPortListening(ctx, port) {
|
|
30
38
|
// relay 别名的 User/HostName 由 ssh config Host 块提供;
|
|
31
39
|
// BatchMode 防换机器/换钥匙时在终端闪密码提示(与运行时五个 ssh 同约定)
|
|
@@ -33,8 +41,8 @@ function relayPortListening(ctx, port) {
|
|
|
33
41
|
'-o', 'BatchMode=yes', '-o', 'ConnectTimeout=5',
|
|
34
42
|
ctx.topo.relay.alias, 'ss', '-tlnH',
|
|
35
43
|
], { timeout: 8000 });
|
|
36
|
-
if (r.code !== 0) return { reachable: false, listening: false, detail: r.stderr.trim() };
|
|
37
|
-
return { reachable: true, listening: new RegExp(`127\\.0\\.0\\.1[:.]${port}\\b`).test(r.stdout) };
|
|
44
|
+
if (r.code !== 0) return { port, reachable: false, listening: false, detail: r.stderr.trim() };
|
|
45
|
+
return { port, reachable: true, listening: new RegExp(`127\\.0\\.0\\.1[:.]${port}\\b`).test(r.stdout) };
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
async function collectEdge(ctx) {
|
|
@@ -48,12 +56,12 @@ async function collectEdge(ctx) {
|
|
|
48
56
|
['v6-address', 'v6-address'],
|
|
49
57
|
]);
|
|
50
58
|
if (links.some((l) => l.audit === 'stale'))
|
|
51
|
-
issues.push('
|
|
59
|
+
issues.push('隧道组件与所装版本不一致——跑一次 ssh-net install 刷新');
|
|
52
60
|
if (links.every((l) => l.audit === 'missing'))
|
|
53
|
-
issues.push('
|
|
61
|
+
issues.push('尚未安装(先跑 ssh-net install)');
|
|
54
62
|
else if (links.some((l) => l.audit === 'missing'))
|
|
55
|
-
// 部分缺失:peer-probe
|
|
56
|
-
issues.push('
|
|
63
|
+
// 部分缺失:peer-probe 丢了会让开着的隧道恒判中继,不能只显示不报
|
|
64
|
+
issues.push(`隧道组件不完整(缺 ${links.filter((l) => l.audit === 'missing').map((l) => l.link).join('、')})——跑一次 ssh-net install 修复`);
|
|
57
65
|
|
|
58
66
|
const label = linkLabel(topo.core.alias);
|
|
59
67
|
const job = launchd.inspect(ctx.runner, ctx.uid, label);
|
|
@@ -65,21 +73,26 @@ async function collectEdge(ctx) {
|
|
|
65
73
|
if (on) {
|
|
66
74
|
peer = peerProbeOk(ctx.runner, paths.binDir);
|
|
67
75
|
route = peer ? 'peer' : 'relay';
|
|
68
|
-
//
|
|
76
|
+
// 开着但 probe 不通可能只是回拨尚未建立;不当作问题(中继同期可用)
|
|
69
77
|
}
|
|
70
78
|
const openTcp = ctx.openTcp ?? tcpOpen; // 测试可注入,避免连真端口
|
|
71
79
|
for (const f of topo.forwards) ports[f.listenPort] = await openTcp('127.0.0.1', f.listenPort);
|
|
72
80
|
|
|
73
|
-
//
|
|
81
|
+
// 关着但转发口仍在听 = 孤儿进程
|
|
74
82
|
if (!on)
|
|
75
|
-
for (const
|
|
76
|
-
if (
|
|
83
|
+
for (const f of topo.forwards)
|
|
84
|
+
if (ports[f.listenPort])
|
|
85
|
+
issues.push(`隧道已关但 ${forwardLabel(f)} 仍被占用——疑似残留进程:lsof -nP -iTCP:${f.listenPort} -sTCP:LISTEN 查占用者`);
|
|
77
86
|
|
|
78
87
|
let v6 = '';
|
|
79
88
|
if (links.find((l) => l.link === 'v6-address')?.audit === 'ok')
|
|
80
89
|
v6 = ctx.runner.runRaw(path.join(paths.binDir, 'v6-address'), [], { timeout: 5000 }).stdout.trim();
|
|
81
90
|
|
|
82
|
-
|
|
91
|
+
const forwardViews = topo.forwards.map((f) => [forwardLabel(f), ports[f.listenPort]]);
|
|
92
|
+
return {
|
|
93
|
+
role: 'edge', alias: ctx.self.alias, on, route, peer, job, links, ports,
|
|
94
|
+
forwardViews, coreAlias: topo.core.alias, v6, runtimeVersion, issues,
|
|
95
|
+
};
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
async function collectCore(ctx) {
|
|
@@ -91,9 +104,9 @@ async function collectCore(ctx) {
|
|
|
91
104
|
[relayLinkName(topo.relay.alias), 'ssh-net-uplink-relay'],
|
|
92
105
|
]);
|
|
93
106
|
if (links.some((l) => l.audit === 'stale'))
|
|
94
|
-
issues.push('
|
|
107
|
+
issues.push('常驻隧道组件与所装版本不一致——跑一次 ssh-net install 刷新');
|
|
95
108
|
if (links.every((l) => l.audit === 'missing'))
|
|
96
|
-
issues.push('
|
|
109
|
+
issues.push('尚未安装(先跑 ssh-net install)');
|
|
97
110
|
|
|
98
111
|
const relayLabelName = relayLabel(topo.relay.alias);
|
|
99
112
|
const relayJob = launchd.inspect(ctx.runner, ctx.uid, relayLabelName);
|
|
@@ -103,15 +116,15 @@ async function collectCore(ctx) {
|
|
|
103
116
|
for (const e of topo.edges) {
|
|
104
117
|
const label = edgeLabel(e.alias);
|
|
105
118
|
const st = launchd.inspect(ctx.runner, ctx.uid, label);
|
|
106
|
-
//
|
|
107
|
-
//
|
|
119
|
+
// 已连接过的随身机,回拨组件一并体检:包升级后它只有 checkin/install
|
|
120
|
+
// 两条刷新通道,漏刷会拿旧脚本拨号
|
|
108
121
|
if (st.registered) {
|
|
109
122
|
const a = auditScript(
|
|
110
123
|
path.join(paths.binDir, edgeLinkName(e.alias)),
|
|
111
124
|
packageScriptPath('ssh-net-uplink-edge'),
|
|
112
125
|
);
|
|
113
126
|
if (a !== 'ok')
|
|
114
|
-
issues.push(
|
|
127
|
+
issues.push(`${e.alias} 的回拨组件异常(${a})——重跑 ssh-net install,或等它下次报名自动修复`);
|
|
115
128
|
}
|
|
116
129
|
edges.push({
|
|
117
130
|
alias: e.alias,
|
|
@@ -123,10 +136,14 @@ async function collectCore(ctx) {
|
|
|
123
136
|
});
|
|
124
137
|
}
|
|
125
138
|
|
|
126
|
-
if (!relayJob.running) issues.push('
|
|
127
|
-
if (!relayPort.listening)
|
|
139
|
+
if (!relayJob.running) issues.push('常驻隧道未在运行——ssh-net start 可拉起');
|
|
140
|
+
if (!relayPort.listening)
|
|
141
|
+
issues.push(`s100 入口 ${topo.core.relayPort} 没在监听:在外面暂时进不来(断线会自动重连;持续出现请查 s100 或本机网络)`);
|
|
128
142
|
|
|
129
|
-
return {
|
|
143
|
+
return {
|
|
144
|
+
role: 'core', alias: ctx.self.alias, links, runtimeVersion,
|
|
145
|
+
relayAlias: topo.relay.alias, relayJob, relayPort, edges, issues,
|
|
146
|
+
};
|
|
130
147
|
}
|
|
131
148
|
|
|
132
149
|
function collectNode(ctx) {
|
|
@@ -138,17 +155,22 @@ function collectNode(ctx) {
|
|
|
138
155
|
[relayLinkName(topo.relay.alias), 'ssh-net-uplink-relay'],
|
|
139
156
|
]);
|
|
140
157
|
if (links.some((l) => l.audit === 'stale'))
|
|
141
|
-
issues.push('
|
|
158
|
+
issues.push('常驻隧道组件与所装版本不一致——跑一次 ssh-net install 刷新');
|
|
142
159
|
if (links.every((l) => l.audit === 'missing'))
|
|
143
|
-
issues.push('
|
|
160
|
+
issues.push('尚未安装(先跑 ssh-net install)');
|
|
144
161
|
|
|
145
162
|
const unit = relayUnitName(topo.relay.alias);
|
|
146
163
|
const active = systemd.isActive(ctx.runner, unit);
|
|
147
164
|
const relayPort = relayPortListening(ctx, ctx.self.relayPort);
|
|
148
|
-
if (active !== 'active')
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
165
|
+
if (active !== 'active')
|
|
166
|
+
issues.push(`系统服务 ${unit} 状态 ${active}——systemctl status ${unit} 查看`);
|
|
167
|
+
if (!relayPort.listening)
|
|
168
|
+
issues.push(`s100 入口 ${ctx.self.relayPort} 没在监听:在外面暂时进不来(断线会自动重连;持续出现请查 s100 或本机网络)`);
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
role: 'node', alias: ctx.self.alias, links, runtimeVersion,
|
|
172
|
+
relayAlias: topo.relay.alias, unit, active, relayPort, issues,
|
|
173
|
+
};
|
|
152
174
|
}
|
|
153
175
|
|
|
154
176
|
export async function collect(ctx) {
|
|
@@ -158,34 +180,48 @@ export async function collect(ctx) {
|
|
|
158
180
|
throw new Error(`未知角色:${ctx.role}`);
|
|
159
181
|
}
|
|
160
182
|
|
|
183
|
+
/** 上次退出码非 0 才值得看;0 与从未退出都不显示。 */
|
|
184
|
+
const exitNote = (code) => (code && code !== '0' ? `(上次退出 ${code})` : '');
|
|
185
|
+
|
|
161
186
|
export function renderText(s) {
|
|
162
187
|
const lines = [];
|
|
163
188
|
lines.push(`ssh-net ${s.role} ${s.alias}`);
|
|
164
|
-
lines.push(` 运行时: ${s.runtimeVersion ?? '无版本戳'}`);
|
|
165
|
-
for (const l of s.links)
|
|
166
|
-
lines.push(` 脚本 ${l.link}: ${l.audit}`);
|
|
167
189
|
|
|
168
190
|
if (s.role === 'edge') {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
191
|
+
if (!s.on) {
|
|
192
|
+
lines.push(' 隧道开关: 关(在办公室,局域网直连即可)');
|
|
193
|
+
} else {
|
|
194
|
+
lines.push(' 隧道开关: 开');
|
|
195
|
+
lines.push(s.peer
|
|
196
|
+
? ` 当前线路: 直连(一条 ssh 到 ${s.coreAlias},最快)`
|
|
197
|
+
: ' 当前线路: 中继(经 s100 转发;直连暂不可用,恢复后自动切回)');
|
|
198
|
+
lines.push(s.v6 !== '' ? ` 对外地址: ${s.v6}` : ' 对外地址: 无 v6(只能走中继)');
|
|
199
|
+
}
|
|
200
|
+
lines.push(` 后台任务: ${!s.job.registered ? '未安装' : s.job.running ? '运行中' : '已停止'}`);
|
|
201
|
+
for (const [label, ok] of s.forwardViews)
|
|
202
|
+
lines.push(` ${ok ? '✓' : '✗'} ${label}${ok ? '' : '(未就绪)'}`);
|
|
175
203
|
} else if (s.role === 'core') {
|
|
176
|
-
lines.push(
|
|
177
|
-
|
|
204
|
+
lines.push(s.relayPort.listening
|
|
205
|
+
? ` 对外通道: ✓ 开着(在外面经 ${s.relayAlias} 进入 ${s.alias} · 入口 ${s.relayPort.port})`
|
|
206
|
+
: ` 对外通道: ✗ ${s.relayPort.reachable === false ? '连不上 s100,入口状态未知' : `入口 ${s.relayPort.port} 没在监听`}`);
|
|
207
|
+
lines.push(` 常驻隧道: ${s.relayJob.running ? `运行中${exitNote(s.relayJob.lastExitCode)}` : '未运行'}`);
|
|
208
|
+
lines.push(' 随身机:');
|
|
178
209
|
for (const e of s.edges) {
|
|
179
|
-
const state = !e.registered ? '
|
|
180
|
-
|
|
210
|
+
const state = !e.registered ? '从未连接(到场装机后自动出现)'
|
|
211
|
+
: e.disabled ? '休眠中(它下次开机报名时自动唤醒)'
|
|
212
|
+
: e.running ? `已连接(直连 ${e.v6 ?? '?'})${exitNote(e.lastExitCode)}`
|
|
213
|
+
: '已断开(自动重试中)';
|
|
214
|
+
lines.push(` ${e.alias} ${state}`);
|
|
181
215
|
}
|
|
182
216
|
} else {
|
|
183
|
-
lines.push(
|
|
184
|
-
|
|
217
|
+
lines.push(s.relayPort.listening
|
|
218
|
+
? ` 对外通道: ✓ 开着(在外面经 ${s.relayAlias} 进入 ${s.alias} · 入口 ${s.relayPort.port})`
|
|
219
|
+
: ` 对外通道: ✗ 入口 ${s.relayPort.port} 没在监听`);
|
|
220
|
+
lines.push(` 常驻隧道: ${s.active === 'active' ? '运行中(systemd)' : `${s.active}(systemd)`}`);
|
|
185
221
|
}
|
|
186
222
|
|
|
187
223
|
if (s.issues.length) {
|
|
188
|
-
lines.push('
|
|
224
|
+
lines.push('需要处理:');
|
|
189
225
|
for (const i of s.issues) lines.push(` - ${i}`);
|
|
190
226
|
}
|
|
191
227
|
return lines.join('\n');
|
|
@@ -13,7 +13,7 @@ function stopCore(ctx) {
|
|
|
13
13
|
// 113 = 未注册(竞态下消失);其余失败必须报,否则 stop 谎报成功、隧道还活着
|
|
14
14
|
if (bo.code !== 0 && bo.code !== 113)
|
|
15
15
|
throw new Error(`bootout 失败(job 仍在注册表):${bo.stderr.trim()}`);
|
|
16
|
-
return '
|
|
16
|
+
return '对外通道已关闭(随身机的直连不受影响)';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function run(ctx) {
|
|
@@ -23,7 +23,7 @@ export function run(ctx) {
|
|
|
23
23
|
throw new Error(
|
|
24
24
|
`${label} 仍在运行(TERM 已发两次)。手工排查:launchctl print gui/${ctx.uid}/${label}`,
|
|
25
25
|
);
|
|
26
|
-
return '
|
|
26
|
+
return '隧道已关闭。几分钟后办公室侧会停止回拨并静默(正常现象,下次开启自动恢复)';
|
|
27
27
|
}
|
|
28
28
|
if (ctx.role === 'core') return stopCore(ctx);
|
|
29
29
|
if (ctx.role === 'node') {
|
|
@@ -31,7 +31,7 @@ export function run(ctx) {
|
|
|
31
31
|
systemd.stopUnit(ctx.runner, unit);
|
|
32
32
|
const d = systemd.disableUnit(ctx.runner, unit);
|
|
33
33
|
if (d.code !== 0) throw new Error(`systemctl disable 失败:${d.stderr.trim()}`);
|
|
34
|
-
return
|
|
34
|
+
return '对外通道已关闭(重启后保持关闭)';
|
|
35
35
|
}
|
|
36
36
|
throw new Error(`未知角色:${ctx.role}`);
|
|
37
37
|
}
|
|
@@ -32,7 +32,7 @@ function uninstallEdge(ctx) {
|
|
|
32
32
|
rm(ctx.paths.stateDir);
|
|
33
33
|
rm(ctx.paths.runtimeVersionFile);
|
|
34
34
|
rm(path.join(ctx.paths.logsDir, `${label}.log`));
|
|
35
|
-
return '
|
|
35
|
+
return '已卸载。最后一步:npm uninstall -g ssh-net';
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function uninstallCore(ctx) {
|
|
@@ -57,7 +57,7 @@ function uninstallCore(ctx) {
|
|
|
57
57
|
rm(ctx.paths.runtimeVersionFile);
|
|
58
58
|
for (const label of [...edgeJobs.keys(), relay])
|
|
59
59
|
rm(path.join(ctx.paths.logsDir, `${label}.log`));
|
|
60
|
-
return
|
|
60
|
+
return `已卸载(常驻通道与 ${edgeJobs.size} 台随身机的回拨作业)。最后一步:npm uninstall -g ssh-net`;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function uninstallNode(ctx) {
|
|
@@ -75,7 +75,7 @@ function uninstallNode(ctx) {
|
|
|
75
75
|
rm(ctx.paths.binDir);
|
|
76
76
|
rm(ctx.paths.stateDir);
|
|
77
77
|
rm(ctx.paths.runtimeVersionFile);
|
|
78
|
-
return
|
|
78
|
+
return '已卸载。最后一步:npm uninstall -g ssh-net';
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function run(ctx) {
|
package/libexec/lib/runtime.mjs
CHANGED
|
@@ -114,8 +114,8 @@ export function readRuntimeVersion(paths) {
|
|
|
114
114
|
*/
|
|
115
115
|
export function runtimeVersionIssue(paths) {
|
|
116
116
|
const v = readRuntimeVersion(paths);
|
|
117
|
-
if (v === null) return '
|
|
117
|
+
if (v === null) return '隧道组件缺版本信息——跑一次 ssh-net install 修复';
|
|
118
118
|
if (v !== RUNTIME_VERSION)
|
|
119
|
-
return
|
|
119
|
+
return `程序已升级到 ${RUNTIME_VERSION},隧道组件还是 ${v}——跑一次 ssh-net install 同步`;
|
|
120
120
|
return null;
|
|
121
121
|
}
|