ssh-net 26.10.22 → 26.10.24

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.
@@ -12,6 +12,9 @@ LAUNCHCTL=${LAUNCHCTL:-/bin/launchctl}
12
12
  ID=${ID:-/usr/bin/id}
13
13
  STATE_DIR=${SSH_NET_STATE_DIR:-$HOME/.ssh/ssh-net/state}
14
14
  BIN_DIR=${SSH_NET_BIN_DIR:-$HOME/.ssh/ssh-net/bin}
15
+ # core 上给人用的 edge 入口片段目录(design §4.2):休眠即删,喂参测试可注入
16
+ CONF_DIR=${SSH_NET_CONF_DIR:-$HOME/.ssh/ssh-net/conf.d}
17
+ RM=${RM:-/bin/rm}
15
18
  CLEAR_TTL=${SSH_NET_CLEAR_TTL:-30} # 持续存活满 30s 清零失败计数
16
19
  FAIL_LIMIT=${SSH_NET_FAIL_LIMIT:-6}
17
20
  RETRY_SLEEP=${SSH_NET_RETRY_SLEEP:-30}
@@ -53,6 +56,12 @@ start_clear_timer() {
53
56
 
54
57
  fails=0
55
58
  rounds=0
59
+
60
+ # 休眠 = edge 当前不在线:删掉给人用的 conf.d/edge-<别名> 入口,免得
61
+ # `ssh <别名>` 拨向必然失败的旧 v6;下次报名 _register 连同 state 写回。
62
+ # 与 _register 的写有竞态(本删晚于报名的写):edge 的 TTL 重报走 noop
63
+ # 分支会补写片段,最坏一个重报周期入口缺失(只影响人主动 ssh,不影响隧道)
64
+ retire_host_fragment() { "$RM" -f "$CONF_DIR/edge-$alias_name" 2>/dev/null || true; }
56
65
  while :; do
57
66
  if [ -n "${SSH_NET_MAX_ROUNDS:-}" ]; then
58
67
  rounds=$((rounds + 1))
@@ -69,6 +78,7 @@ while :; do
69
78
  # 不空转拨号,也不删任何东西
70
79
  if [ -z "$v6" ]; then
71
80
  log "state 无 v6(人工误删?)→ disable 休眠,等下次报名唤醒"
81
+ retire_host_fragment
72
82
  "$LAUNCHCTL" disable "gui/$("$ID" -u)/$label"
73
83
  exit 0
74
84
  fi
@@ -112,6 +122,7 @@ while :; do
112
122
  # 当下零重拉靠本 exit 0(SuccessfulExit=false 只在非自愿退出时重拉);
113
123
  # disable 管加载期拦截与跨登录持久(实测矩阵见 notes)
114
124
  log "$FAIL_LIMIT 次快速失败 → disable 休眠(正常路径:edge 关机/合盖/不可达;等下次报名唤醒)"
125
+ retire_host_fragment
115
126
  "$LAUNCHCTL" disable "gui/$("$ID" -u)/$label"
116
127
  exit 0
117
128
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh-net",
3
- "version": "26.10.22",
3
+ "version": "26.10.24",
4
4
  "type": "module",
5
5
  "description": "个人 SSH 组网:v6 直连优先、relay 兜底、关机有界重试后静默",
6
6
  "bin": {