ssh-net 0.2.1 → 26.9.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 +14 -0
- package/README.md +4 -5
- package/libexec/commands/install.mjs +2 -2
- package/libexec/commands/restart.mjs +3 -3
- package/libexec/commands/start.mjs +4 -4
- package/libexec/commands/status.mjs +16 -14
- package/libexec/commands/stop.mjs +2 -2
- package/libexec/commands/uninstall.mjs +1 -1
- package/libexec/lib/paths.mjs +1 -1
- package/libexec/lib/state.mjs +1 -1
- package/libexec/ssh-net-link-core +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
本项目版本号与发布节奏仿 mihomo-cli:npm 公共分发,版本即升级动作。
|
|
4
|
+
版本号格式为**年.月.序号**(如 26.9.1),序号每月重置——2026-09-29 起
|
|
5
|
+
启用;此前的 0.x 为过渡期编号。
|
|
6
|
+
|
|
7
|
+
## [26.9.1] - 2026-09-29
|
|
8
|
+
|
|
9
|
+
### 变更
|
|
10
|
+
|
|
11
|
+
- 版本号启用「年.月.序号」方案(26.9.x,序号每月重置)
|
|
12
|
+
- **开关文件改为大写 `ON`**(`~/.ssh/ssh-net/state/ON`,与 dotfiles 的
|
|
13
|
+
AT_HOME/AUTO_PROXY 空标记同款约定);升级后 edge 需重新
|
|
14
|
+
`ssh-net start`(旧小写 `on` 文件可删),Match 判据与 at status 同步
|
|
15
|
+
- 文案统一用既定原词,不自造:「随身机」→ edge、「直连/中继/对外通道/
|
|
16
|
+
常驻隧道」→ peer / relay(后附括号解释);无 v6 的「只能走 relay」
|
|
17
|
+
警示仅在确实走 relay 时出现
|
|
4
18
|
|
|
5
19
|
## [0.2.1] - 2026-09-29
|
|
6
20
|
|
package/README.md
CHANGED
|
@@ -78,8 +78,7 @@ npm link # 开发机:控制面改即时生效(运行时脚本仍
|
|
|
78
78
|
|
|
79
79
|
## 状态
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
mb1(Phase 5)待办。
|
|
81
|
+
26.9.1 已发布 npm(版本号自本版起用「年.月.序号」,序号每月重置)。部署:
|
|
82
|
+
m4/n007/n061/mb5 四台上线;文案为用户视角(peer/relay 原词 + 括号解释),
|
|
83
|
+
edge 开关文件为大写 `ON`。在家项(公网 v6 闸门/合盖开盖)与 mb1
|
|
84
|
+
(Phase 5)待办。
|
|
@@ -89,7 +89,7 @@ function installCore(ctx) {
|
|
|
89
89
|
});
|
|
90
90
|
return r.unchanged
|
|
91
91
|
? '已安装,无需改动'
|
|
92
|
-
:
|
|
92
|
+
: `安装完成,relay 已开启(s100 入口 ${topo.core.relayPort})`;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function installNode(ctx) {
|
|
@@ -119,7 +119,7 @@ function installNode(ctx) {
|
|
|
119
119
|
]) {
|
|
120
120
|
if (r.code !== 0) throw new Error(`systemctl 失败:${r.stderr.trim()}`);
|
|
121
121
|
}
|
|
122
|
-
return
|
|
122
|
+
return `安装完成,relay 已开启(s100 入口 ${ctx.self.relayPort})`;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/** @param {object} ctx */
|
|
@@ -6,7 +6,7 @@ import { linkLabel, relayLabel, relayUnitName } from '../lib/render.mjs';
|
|
|
6
6
|
|
|
7
7
|
export function run(ctx) {
|
|
8
8
|
if (ctx.role === 'edge') {
|
|
9
|
-
if (!ctx.state.isOn()) throw new Error('
|
|
9
|
+
if (!ctx.state.isOn()) throw new Error('隧道未开启——先 ssh-net start');
|
|
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);
|
|
@@ -19,12 +19,12 @@ export function run(ctx) {
|
|
|
19
19
|
throw new Error('uplink-relay 未注册(已 stop?先 ssh-net start)');
|
|
20
20
|
const r = launchd.kickstartEnabled(ctx.runner, ctx.uid, label);
|
|
21
21
|
if (r.code !== 0) throw new Error(`重启失败:${r.stderr.trim()}`);
|
|
22
|
-
return '
|
|
22
|
+
return 'relay 已重启';
|
|
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 'relay 已重启';
|
|
28
28
|
}
|
|
29
29
|
throw new Error(`未知角色:${ctx.role}`);
|
|
30
30
|
}
|
|
@@ -15,17 +15,17 @@ function startCore(ctx) {
|
|
|
15
15
|
launchd.enable(ctx.runner, ctx.uid, label);
|
|
16
16
|
const r = launchd.bootstrap(ctx.runner, ctx.uid, plist);
|
|
17
17
|
if (r.code !== 0) throw new Error(`启动失败:${r.stderr.trim()}`);
|
|
18
|
-
return '
|
|
18
|
+
return 'relay 已开启';
|
|
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
24
|
if (r.code !== 0) throw new Error(`启动失败:${r.stderr.trim()}`);
|
|
25
|
-
return '
|
|
25
|
+
return 'relay 已重新拉起';
|
|
26
26
|
}
|
|
27
27
|
if (st.disabled) launchd.enable(ctx.runner, ctx.uid, label); // 在跑但 override 残留:清掉防退出后不重拉
|
|
28
|
-
return '
|
|
28
|
+
return 'relay 已在运行';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function run(ctx) {
|
|
@@ -40,7 +40,7 @@ export function run(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 'relay 已开启';
|
|
44
44
|
}
|
|
45
45
|
throw new Error(`未知角色:${ctx.role}`);
|
|
46
46
|
}
|
|
@@ -104,7 +104,7 @@ async function collectCore(ctx) {
|
|
|
104
104
|
[relayLinkName(topo.relay.alias), 'ssh-net-uplink-relay'],
|
|
105
105
|
]);
|
|
106
106
|
if (links.some((l) => l.audit === 'stale'))
|
|
107
|
-
issues.push('
|
|
107
|
+
issues.push('relay 组件与所装版本不一致——跑一次 ssh-net install 刷新');
|
|
108
108
|
if (links.every((l) => l.audit === 'missing'))
|
|
109
109
|
issues.push('尚未安装(先跑 ssh-net install)');
|
|
110
110
|
|
|
@@ -136,7 +136,7 @@ async function collectCore(ctx) {
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
if (!relayJob.running) issues.push('
|
|
139
|
+
if (!relayJob.running) issues.push('relay 未在运行——ssh-net start 可拉起');
|
|
140
140
|
if (!relayPort.listening)
|
|
141
141
|
issues.push(`s100 入口 ${topo.core.relayPort} 没在监听:在外面暂时进不来(断线会自动重连;持续出现请查 s100 或本机网络)`);
|
|
142
142
|
|
|
@@ -155,7 +155,7 @@ function collectNode(ctx) {
|
|
|
155
155
|
[relayLinkName(topo.relay.alias), 'ssh-net-uplink-relay'],
|
|
156
156
|
]);
|
|
157
157
|
if (links.some((l) => l.audit === 'stale'))
|
|
158
|
-
issues.push('
|
|
158
|
+
issues.push('relay 组件与所装版本不一致——跑一次 ssh-net install 刷新');
|
|
159
159
|
if (links.every((l) => l.audit === 'missing'))
|
|
160
160
|
issues.push('尚未安装(先跑 ssh-net install)');
|
|
161
161
|
|
|
@@ -193,31 +193,33 @@ export function renderText(s) {
|
|
|
193
193
|
} else {
|
|
194
194
|
lines.push(' 隧道开关: 开');
|
|
195
195
|
lines.push(s.peer
|
|
196
|
-
? ` 当前线路:
|
|
197
|
-
: ' 当前线路:
|
|
198
|
-
lines.push(s.v6 !== ''
|
|
196
|
+
? ` 当前线路: peer(v6 直达 ${s.coreAlias},一条 ssh)`
|
|
197
|
+
: ' 当前线路: relay(经 s100 中转;peer 恢复后自动切回)');
|
|
198
|
+
lines.push(s.v6 !== ''
|
|
199
|
+
? ` 对外地址: ${s.v6}`
|
|
200
|
+
: ` 对外地址: 无 v6${s.peer ? '' : '(只能走 relay)'}`);
|
|
199
201
|
}
|
|
200
202
|
lines.push(` 后台任务: ${!s.job.registered ? '未安装' : s.job.running ? '运行中' : '已停止'}`);
|
|
201
203
|
for (const [label, ok] of s.forwardViews)
|
|
202
204
|
lines.push(` ${ok ? '✓' : '✗'} ${label}${ok ? '' : '(未就绪)'}`);
|
|
203
205
|
} else if (s.role === 'core') {
|
|
204
206
|
lines.push(s.relayPort.listening
|
|
205
|
-
? `
|
|
206
|
-
: `
|
|
207
|
-
lines.push(`
|
|
208
|
-
lines.push('
|
|
207
|
+
? ` relay: ✓ 开着(在外面经 ${s.relayAlias} 进入 ${s.alias} · 入口 ${s.relayPort.port})`
|
|
208
|
+
: ` relay: ✗ ${s.relayPort.reachable === false ? '连不上 s100,入口状态未知' : `入口 ${s.relayPort.port} 没在监听`}`);
|
|
209
|
+
lines.push(` relay 进程: ${s.relayJob.running ? `运行中${exitNote(s.relayJob.lastExitCode)}` : '未运行'}`);
|
|
210
|
+
lines.push(' edge:');
|
|
209
211
|
for (const e of s.edges) {
|
|
210
212
|
const state = !e.registered ? '从未连接(到场装机后自动出现)'
|
|
211
213
|
: e.disabled ? '休眠中(它下次开机报名时自动唤醒)'
|
|
212
|
-
: e.running ?
|
|
214
|
+
: e.running ? `已连接(peer ${e.v6 ?? '?'})${exitNote(e.lastExitCode)}`
|
|
213
215
|
: '已断开(自动重试中)';
|
|
214
216
|
lines.push(` ${e.alias} ${state}`);
|
|
215
217
|
}
|
|
216
218
|
} else {
|
|
217
219
|
lines.push(s.relayPort.listening
|
|
218
|
-
? `
|
|
219
|
-
: `
|
|
220
|
-
lines.push(`
|
|
220
|
+
? ` relay: ✓ 开着(在外面经 ${s.relayAlias} 进入 ${s.alias} · 入口 ${s.relayPort.port})`
|
|
221
|
+
: ` relay: ✗ 入口 ${s.relayPort.port} 没在监听`);
|
|
222
|
+
lines.push(` relay 进程: ${s.active === 'active' ? '运行中(systemd)' : `${s.active}(systemd)`}`);
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
if (s.issues.length) {
|
|
@@ -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 'relay 已关闭(edge 的 peer 连接不受影响)';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function run(ctx) {
|
|
@@ -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 'relay 已关闭(重启后保持关闭)';
|
|
35
35
|
}
|
|
36
36
|
throw new Error(`未知角色:${ctx.role}`);
|
|
37
37
|
}
|
|
@@ -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 `已卸载(relay 通道与 ${edgeJobs.size} 个 edge 的回拨作业)。最后一步:npm uninstall -g ssh-net`;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function uninstallNode(ctx) {
|
package/libexec/lib/paths.mjs
CHANGED
|
@@ -38,7 +38,7 @@ export function machinePaths(env = process.env) {
|
|
|
38
38
|
binDir: path.join(sshNetDir, 'bin'),
|
|
39
39
|
runtimeVersionFile: path.join(sshNetDir, 'runtime-version'),
|
|
40
40
|
stateDir,
|
|
41
|
-
onFile: path.join(stateDir, '
|
|
41
|
+
onFile: path.join(stateDir, 'ON'),
|
|
42
42
|
edgesDir: path.join(stateDir, 'edges'),
|
|
43
43
|
launchAgentsDir: path.join(home, 'Library', 'LaunchAgents'),
|
|
44
44
|
logsDir: path.join(home, 'Library', 'Logs'),
|
package/libexec/lib/state.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
*/
|
|
21
21
|
export function createStateStore(stateDir) {
|
|
22
22
|
const edgesDir = path.join(stateDir, 'edges');
|
|
23
|
-
const onFile = path.join(stateDir, '
|
|
23
|
+
const onFile = path.join(stateDir, 'ON');
|
|
24
24
|
|
|
25
25
|
const ensureState = () => {
|
|
26
26
|
fs.mkdirSync(stateDir, { recursive: true, mode: 0o700 });
|