ssh-net 26.10.22 → 26.10.23
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 +23 -0
- package/libexec/commands/install.mjs +2 -2
- package/libexec/lib/config.mjs +24 -13
- package/libexec/lib/render.mjs +1 -0
- package/libexec/ssh-net-link-core +39 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,29 @@
|
|
|
9
9
|
故 26.9.12 之后跳号发 26.9.17(第 17 个包),13–16 永久空缺——序号从此与
|
|
10
10
|
第几个包严格一致,看到版本号即知发布总数
|
|
11
11
|
|
|
12
|
+
## [26.10.23] - 2026-10-01
|
|
13
|
+
|
|
14
|
+
### 变更(转发规格化;loopback6 目标按 peer/relay 选 v6/v4 环回)
|
|
15
|
+
|
|
16
|
+
- topology 新增环回目标别名 **`loopback6`**:`forward local 15900
|
|
17
|
+
loopback6 5900`。与固定 v4 的 `loopback` 不同,它由 link-core 按当前
|
|
18
|
+
mode 渲染——**peer 态远程目标 `[::1]:5900`、relay 态自动退
|
|
19
|
+
`127.0.0.1:5900`**(ps 看 link 的 ssh `-L` 即可辨别当前路径;两态都
|
|
20
|
+
落地 core,要求 core 服务两族环回都听——macOS 屏幕共享实测都听)。
|
|
21
|
+
1090 microsocks 只听 v4,继续用 `loopback`
|
|
22
|
+
- plist 传给 link-core 的转发参数从「裸 ssh 片段」改为**转发规格**
|
|
23
|
+
`D:<本地口>` / `L:<本地口>:<目标口>:<目标>`(buildForwardArgs →
|
|
24
|
+
buildForwardSpecs),由 link-core 在 mode 确定后渲染;peer↔relay
|
|
25
|
+
翻转杀 ssh 重连时目标地址随 mode 切换,无需额外动作
|
|
26
|
+
|
|
27
|
+
**需 dotfiles 同步发布(15900 改 loopback6),edge 顺序不能乱**:
|
|
28
|
+
1. `npm i -g ssh-net@26.10.23`(先装能解析 loopback6、能读规格的包)
|
|
29
|
+
2. `dot apply ssh`(落新 topology)
|
|
30
|
+
3. `ssh-net install`(渲染规格 plist 并重建隧道)
|
|
31
|
+
|
|
32
|
+
顺序反了:旧包解析 `loopback6` 会按「未知别名」报配置错;旧 link 收到
|
|
33
|
+
规格当裸 ssh 参数会起不来。core/node 无 forward 行,升包无行为变化。
|
|
34
|
+
|
|
12
35
|
## [26.10.22] - 2026-10-01
|
|
13
36
|
|
|
14
37
|
### 变更(选路判决集中到 link-core;修 sn-probe 健康路径白等 2s)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// enable --now。
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
-
import {
|
|
7
|
+
import { buildForwardSpecs } from '../lib/config.mjs';
|
|
8
8
|
import { CALLBACK_PORT } from '../lib/constants.mjs';
|
|
9
9
|
import { syncPlist, writeFileAtomic } from '../lib/manage.mjs';
|
|
10
10
|
import { ensureRuntime } from '../lib/runtime.mjs';
|
|
@@ -87,7 +87,7 @@ async function installEdge(ctx) {
|
|
|
87
87
|
binDir: paths.binDir,
|
|
88
88
|
coreAlias: topo.core.alias,
|
|
89
89
|
selfAlias: ctx.self.alias,
|
|
90
|
-
forwardArgs:
|
|
90
|
+
forwardArgs: buildForwardSpecs(topo.forwards),
|
|
91
91
|
relayOnFile: paths.switchFiles.relay,
|
|
92
92
|
logsDir: paths.logsDir,
|
|
93
93
|
});
|
package/libexec/lib/config.mjs
CHANGED
|
@@ -38,8 +38,9 @@ const BIND = '127.0.0.1'; // 所有转发强制只绑环回(design §6.5)
|
|
|
38
38
|
* @property {'dynamic'|'local'} kind
|
|
39
39
|
* @property {string} bind 恒 127.0.0.1
|
|
40
40
|
* @property {number} listenPort
|
|
41
|
-
* @property {string} [targetAlias]
|
|
42
|
-
*
|
|
41
|
+
* @property {string} [targetAlias] 目标别名;'loopback'=落地机 v4 环回,
|
|
42
|
+
* 'loopback6'=v6 环回偏好(peer 走 ::1、非 peer 退 127.0.0.1)
|
|
43
|
+
* @property {string} [targetIp] 解析后的目标 IP(loopback6 记首选 ::1)
|
|
43
44
|
* @property {number} [targetPort]
|
|
44
45
|
*
|
|
45
46
|
* @typedef {Object} Topology
|
|
@@ -181,16 +182,19 @@ export function parseTopology(text) {
|
|
|
181
182
|
const targetPort = parsePort(cols[4]);
|
|
182
183
|
if (!Number.isInteger(targetPort) || targetPort < 1 || targetPort > 65535)
|
|
183
184
|
throw new ConfigError(line, `目标端口非法:${cols[4]}`);
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
|
|
185
|
+
// 环回别名:目标服务在 ssh 落地机(link-core 两态都落地 core)的本机
|
|
186
|
+
// 环回上,不在拓扑里、无 LAN IP 可翻(协议常量可入包代码):
|
|
187
|
+
// loopback = 127.0.0.1(microsocks 只听 v4,故默认/v4 服务用它)
|
|
188
|
+
// loopback6 = ::1(服务同听 v6 环回时用,如 macOS 屏幕共享;
|
|
189
|
+
// link-core 渲染 ssh 参数时带方括号,见 buildForwardSpecs)
|
|
190
|
+
const loopbackIp = { loopback: '127.0.0.1', loopback6: '::1' }[targetAlias];
|
|
191
|
+
if (loopbackIp !== undefined) {
|
|
188
192
|
forwards.push({
|
|
189
193
|
kind,
|
|
190
194
|
bind: BIND,
|
|
191
195
|
listenPort,
|
|
192
196
|
targetAlias,
|
|
193
|
-
targetIp:
|
|
197
|
+
targetIp: loopbackIp,
|
|
194
198
|
targetPort,
|
|
195
199
|
});
|
|
196
200
|
continue;
|
|
@@ -223,19 +227,26 @@ export function parseTopology(text) {
|
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
/**
|
|
226
|
-
* 转发渲染成
|
|
230
|
+
* 转发渲染成 link-core 的**转发规格**(plist argv 传它,不是裸 ssh 片段):
|
|
231
|
+
* dynamic → `D:<listenPort>`
|
|
232
|
+
* local → `L:<listenPort>:<targetPort>:<target>`
|
|
233
|
+
* target 普通情况是解析期翻好的 IP(LAN IP / 127.0.0.1);`loopback6`
|
|
234
|
+
* 保留为关键字——它要由 link-core 按当前 mode 渲染(peer→[::1]、relay 退
|
|
235
|
+
* 127.0.0.1),解析期定不死。bind 不进规格(link-core 恒用 127.0.0.1)。
|
|
236
|
+
* 注意:规格以冒号分隔,target 不支持 v6 字面量(v6 环回走 loopback6 关键字)。
|
|
227
237
|
* @param {readonly Forward[]} forwards
|
|
228
238
|
* @returns {string[]}
|
|
229
239
|
*/
|
|
230
|
-
export function
|
|
240
|
+
export function buildForwardSpecs(forwards) {
|
|
231
241
|
/** @type {string[]} */
|
|
232
|
-
const
|
|
242
|
+
const specs = [];
|
|
233
243
|
for (const f of forwards) {
|
|
234
244
|
if (f.kind === 'dynamic') {
|
|
235
|
-
|
|
245
|
+
specs.push(`D:${f.listenPort}`);
|
|
236
246
|
} else {
|
|
237
|
-
|
|
247
|
+
const target = f.targetAlias === 'loopback6' ? 'loopback6' : f.targetIp;
|
|
248
|
+
specs.push(`L:${f.listenPort}:${f.targetPort}:${target}`);
|
|
238
249
|
}
|
|
239
250
|
}
|
|
240
|
-
return
|
|
251
|
+
return specs;
|
|
241
252
|
}
|
package/libexec/lib/render.mjs
CHANGED
|
@@ -65,6 +65,7 @@ export const plistFileName = (label) => `${label}.plist`;
|
|
|
65
65
|
* edge link job:PathState 盯根开关 RELAY_ON,不写 RunAtLoad。
|
|
66
66
|
* @param {{binDir:string, coreAlias:string, selfAlias:string,
|
|
67
67
|
* forwardArgs:readonly string[], relayOnFile:string, logsDir:string}} opts
|
|
68
|
+
* forwardArgs 是 buildForwardSpecs 的转发规格(D:/L:),由 link-core 按 mode 渲染
|
|
68
69
|
*/
|
|
69
70
|
export function renderEdgeLinkPlist(opts) {
|
|
70
71
|
const { binDir, coreAlias, selfAlias, forwardArgs, relayOnFile, logsDir } = opts;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# ssh-net-link-core:edge 上到 core 的常驻隧道(-D SOCKS + -L VNC)。
|
|
3
|
-
# argv: <self 别名> <peer 别名>
|
|
3
|
+
# argv: <self 别名> <peer 别名> <转发规格…>
|
|
4
|
+
# 转发规格(buildForwardSpecs 产出,不是裸 ssh 片段):D:<本地口> 或
|
|
5
|
+
# L:<本地口>:<目标口>:<目标>;目标是 IP,或关键字 loopback6——后者按当前
|
|
6
|
+
# mode 渲染:peer 走 [::1]、relay/其他退 127.0.0.1(两态都落地 core,
|
|
7
|
+
# core 的屏幕共享两族环回都听;1090 用普通 loopback 不参与)。规格在
|
|
8
|
+
# 每轮 mode 确定后渲染成 -D/-L,翻转杀 ssh 重连即随新 mode 换目标。
|
|
4
9
|
# 走 peer 还是 relay 由本循环判决(回拨窗口/信令/到点探),并把结论发布到
|
|
5
10
|
# state/ROUTE_PEER(peer=epoch 心跳,relay/退出=删除),ssh config Match 的
|
|
6
11
|
# sn-route 只读它 + 一次廉价 banner 复核(design §2.2/§6.1)。循环本身做
|
|
@@ -34,7 +39,34 @@ RM=${RM:-/bin/rm}
|
|
|
34
39
|
self=$1
|
|
35
40
|
peer=$2
|
|
36
41
|
shift 2
|
|
37
|
-
fwd=("$@")
|
|
42
|
+
fwd=("$@") # 转发规格(D:/L:),mode 确定后经 build_fwd_args 渲染
|
|
43
|
+
|
|
44
|
+
# 转发规格 → ssh -D/-L 参数(结果写全局数组 FWD_SSH)。bind 恒 127.0.0.1
|
|
45
|
+
#(与控制面 BIND 双源,constants.test.mjs 钉)。loopback6 按本轮 mode 选族。
|
|
46
|
+
# bash 3.2:不用关联数组,逐项字符串切分(规格分隔符是冒号,故 target 不
|
|
47
|
+
# 支持 v6 字面量,v6 环回只能用 loopback6 关键字)
|
|
48
|
+
build_fwd_args() {
|
|
49
|
+
FWD_SSH=()
|
|
50
|
+
local spec kind rest lport rport target ip
|
|
51
|
+
for spec in "${fwd[@]}"; do
|
|
52
|
+
kind=${spec%%:*}
|
|
53
|
+
rest=${spec#*:}
|
|
54
|
+
case "$kind" in
|
|
55
|
+
D)
|
|
56
|
+
FWD_SSH+=(-D "127.0.0.1:$rest")
|
|
57
|
+
;;
|
|
58
|
+
L)
|
|
59
|
+
lport=${rest%%:*}; rest=${rest#*:}
|
|
60
|
+
rport=${rest%%:*}; target=${rest#*:}
|
|
61
|
+
ip=$target
|
|
62
|
+
if [ "$target" = loopback6 ]; then
|
|
63
|
+
if [ "$mode" = peer ]; then ip='[::1]'; else ip=127.0.0.1; fi
|
|
64
|
+
fi
|
|
65
|
+
FWD_SSH+=(-L "127.0.0.1:$lport:$ip:$rport")
|
|
66
|
+
;;
|
|
67
|
+
esac
|
|
68
|
+
done
|
|
69
|
+
}
|
|
38
70
|
|
|
39
71
|
# 事件日志:一行一事件(date 绝对路径,launchd 无交互 PATH)。ssh 自身的
|
|
40
72
|
# stderr 照旧落同一文件但无时间戳——事件行负责锚定时刻(design §6.1)
|
|
@@ -220,12 +252,14 @@ while :; do
|
|
|
220
252
|
last_notice=$mode
|
|
221
253
|
fi
|
|
222
254
|
|
|
223
|
-
# 唯一一条转发 ssh
|
|
224
|
-
# ssh——「只要被连接、不要本地转发口」的形态;bash 3.2
|
|
255
|
+
# 唯一一条转发 ssh(规格按本轮 mode 渲染成 -D/-L;LINK_ON 不在=纯报名
|
|
256
|
+
# 维护,不起 ssh——「只要被连接、不要本地转发口」的形态;bash 3.2 空
|
|
257
|
+
# 数组展开写法)
|
|
225
258
|
ssh_pid=
|
|
226
259
|
if [ "$link_on" = 1 ]; then
|
|
260
|
+
build_fwd_args
|
|
227
261
|
log "转发 ssh 起(mode=$mode${v6:+ v6=$v6})"
|
|
228
|
-
"$SSH" -N ${
|
|
262
|
+
"$SSH" -N ${FWD_SSH[@]+"${FWD_SSH[@]}"} \
|
|
229
263
|
-o ExitOnForwardFailure=yes -o BatchMode=yes -o IdentitiesOnly=yes \
|
|
230
264
|
-o ControlMaster=no -o ControlPath=none \
|
|
231
265
|
-o ServerAliveInterval=35 -o ServerAliveCountMax=3 \
|