ssh-net 26.11.2 → 26.11.66
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 +30 -3
- package/README.md +25 -19
- package/libexec/cli.mjs +23 -23
- package/libexec/commands/install.mjs +112 -182
- package/libexec/commands/register.mjs +1 -2
- package/libexec/commands/start.mjs +25 -18
- package/libexec/commands/status.mjs +59 -39
- package/libexec/commands/stop.mjs +6 -10
- package/libexec/commands/uninstall.mjs +11 -26
- package/libexec/commands/update.mjs +49 -21
- package/libexec/lib/conf.mjs +14 -3
- package/libexec/lib/config.mjs +3 -13
- package/libexec/lib/constants.mjs +3 -0
- package/libexec/lib/exec.mjs +2 -0
- package/libexec/lib/fsutil.mjs +33 -8
- package/libexec/lib/identity.mjs +16 -0
- package/libexec/lib/jobctl.mjs +1 -1
- package/libexec/lib/jobs.mjs +17 -17
- package/libexec/lib/launchd.mjs +17 -49
- package/libexec/lib/manage.mjs +117 -76
- package/libexec/lib/manifest.mjs +14 -57
- package/libexec/lib/paths.mjs +2 -4
- package/libexec/lib/probe.mjs +33 -46
- package/libexec/lib/runtime.mjs +29 -37
- package/libexec/lib/sshconfig.mjs +98 -17
- package/libexec/lib/systemd.mjs +214 -55
- package/libexec/sn-ipv6 +2 -2
- package/libexec/sn-route +110 -57
- package/libexec/ssh-net-link-core +2 -3
- package/package.json +1 -1
package/libexec/lib/probe.mjs
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
import net from 'node:net';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { SN_PROBE } from './manifest.mjs';
|
|
9
|
+
import { TIMEOUT_SEARCH_PATH } from './constants.mjs';
|
|
10
|
+
import { isExecutableFile } from './fsutil.mjs';
|
|
11
|
+
|
|
12
|
+
/** 检查安装和本地状态所需的回拨限时工具,不运行外部命令 */
|
|
13
|
+
export function hasRouteTimeout(env) {
|
|
14
|
+
const searchPath = env.SSH_NET_TIMEOUT_PATH || TIMEOUT_SEARCH_PATH;
|
|
15
|
+
return searchPath.split(':').some(dir => isExecutableFile(path.join(dir, 'timeout')));
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* TCP 能否在超时内连上(status 用,mjs 侧不依赖 nc)。
|
|
@@ -44,21 +52,20 @@ function runLsof(runner, args, port) {
|
|
|
44
52
|
throw new Error(`lsof 查询端口 ${port} 失败:${detail}`);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.filter((n) => Number.isInteger(n));
|
|
55
|
+
/** 只认覆盖 127.0.0.1 的监听。同号的 IPv6 通配监听可能只收 IPv6,单独探测 */
|
|
56
|
+
export async function forwardListenerPids(runner, port) {
|
|
57
|
+
const r = runLsof(runner, ['-nP', '-Fpftn', `-iTCP:${port}`, '-sTCP:LISTEN'], port);
|
|
58
|
+
const ipv4 = new Set();
|
|
59
|
+
const wildcard6 = new Set();
|
|
60
|
+
let pid, type;
|
|
61
|
+
for (const field of r.stdout.split('\n')) {
|
|
62
|
+
if (field.startsWith('p')) pid = Number(field.slice(1));
|
|
63
|
+
if (field.startsWith('t')) type = field.slice(1);
|
|
64
|
+
if (field === `n127.0.0.1:${port}` || field === `n[::ffff:127.0.0.1]:${port}`) ipv4.add(pid);
|
|
65
|
+
if (field === `n*:${port}`) (type === 'IPv6' ? wildcard6 : ipv4).add(pid);
|
|
66
|
+
}
|
|
67
|
+
if (ipv4.size === 0 && wildcard6.size && await tcpOpen('127.0.0.1', port)) return [...wildcard6];
|
|
68
|
+
return [...ipv4];
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
/**
|
|
@@ -73,37 +80,17 @@ export function lsofListen(runner, port) {
|
|
|
73
80
|
return r.code === 0 ? r.stdout.trim() : '';
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return text
|
|
88
|
-
.split('\n')
|
|
89
|
-
.filter((l) => portRe.test(l))
|
|
90
|
-
.map((l) => Number(l.match(/\s(\d+)\s/)?.[1]))
|
|
91
|
-
.filter((n) => Number.isInteger(n));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 本地转发口预检:无监听=空闲;持口者全是 link job 进程本身=本服务;否则冲突。
|
|
96
|
-
* @param {import('./exec.mjs').Runner} runner
|
|
97
|
-
* @param {number} port
|
|
98
|
-
* @param {number|null} jobPid link job 的 pid(未注册或没在跑给 null)
|
|
99
|
-
* @returns {{kind:'free'|'ours'|'foreign', pids:number[]}}
|
|
100
|
-
*/
|
|
101
|
-
export function classifyLocalPort(runner, port, jobPid) {
|
|
102
|
-
const pids = listListeners(runner, port);
|
|
103
|
-
if (pids.length === 0) return { kind: 'free', pids: [] };
|
|
104
|
-
return jobPid !== null && pids.every((p) => p === jobPid)
|
|
105
|
-
? { kind: 'ours', pids }
|
|
106
|
-
: { kind: 'foreign', pids };
|
|
83
|
+
/** 回拨只能绑定 [::1]。IPv6 通配即使提供 SSH 服务也会占用回拨地址 */
|
|
84
|
+
export function v6ListenerScope(text, port) {
|
|
85
|
+
let scope = null;
|
|
86
|
+
for (const line of text.split('\n')) {
|
|
87
|
+
const fields = line.trim().split(/\s+/);
|
|
88
|
+
if (fields[4] !== 'IPv6') continue;
|
|
89
|
+
const address = fields.at(-2);
|
|
90
|
+
if (address === `*:${port}` || address === `[::]:${port}`) return 'wildcard';
|
|
91
|
+
if (address === `[::1]:${port}`) scope = 'loopback';
|
|
92
|
+
}
|
|
93
|
+
return scope;
|
|
107
94
|
}
|
|
108
95
|
|
|
109
96
|
/**
|
package/libexec/lib/runtime.mjs
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// - bin/ 只放包脚本的**原名实体**(0755),服务 job 经「带机器名软链」引用——
|
|
3
3
|
// 程序永远只有一份(升级原子换一份、N 个 job 自动跟新),进程 argv[0] 第
|
|
4
4
|
// 一列仍带机器名可辨识(ssh-net-uplink-edge-<别名> 等)
|
|
5
|
-
// -
|
|
5
|
+
// - 实体的内容与 0755 权限都正确时保留原文件;软链目标正确时保留原链
|
|
6
6
|
// - 运行时零 npm/fnm 依赖;包升级后重跑 install 刷新(core 侧 uplink-edge
|
|
7
7
|
// 由每次报名自动对账),status 直接比对包内脚本与磁盘产物
|
|
8
8
|
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
9
10
|
import { packageScriptPath } from './paths.mjs';
|
|
10
|
-
import {
|
|
11
|
+
import { withTempFile, writeFileAtomic } from './fsutil.mjs';
|
|
12
|
+
|
|
13
|
+
function isRuntimeFile(stat) {
|
|
14
|
+
return stat.isFile() && (stat.mode & 0o7777) === 0o755;
|
|
15
|
+
}
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
18
|
* 拷贝单脚本到 bin/(实体)。
|
|
@@ -17,14 +22,7 @@ import { readFileOrNull, writeFileAtomic } from './fsutil.mjs';
|
|
|
17
22
|
*/
|
|
18
23
|
export function ensureScript(dstPath, srcPath) {
|
|
19
24
|
const src = fs.readFileSync(srcPath);
|
|
20
|
-
|
|
21
|
-
const st = cur === null ? null : fs.lstatSync(dstPath);
|
|
22
|
-
if (st !== null && st.isFile() && cur.equals(src)) {
|
|
23
|
-
// 内容对但可执行位丢了(cp/同步工具吃掉 mode):补上
|
|
24
|
-
if (st.mode & 0o111) return false;
|
|
25
|
-
fs.chmodSync(dstPath, 0o755);
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
25
|
+
if (auditScript(dstPath, src) === 'ok') return false;
|
|
28
26
|
// 缺失、旧内容或软链:tmp+rename 原子换(rename 替换目录项本身,不跟随软链)
|
|
29
27
|
writeFileAtomic(dstPath, src, { mode: 0o755 });
|
|
30
28
|
return true;
|
|
@@ -41,25 +39,26 @@ export function ensureLink(linkPath, entityName) {
|
|
|
41
39
|
const st = fs.lstatSync(linkPath, { throwIfNoEntry: false }) ?? null;
|
|
42
40
|
if (st?.isSymbolicLink() && fs.readlinkSync(linkPath) === entityName)
|
|
43
41
|
return false;
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// 原子替换,launchd 和并发报名始终可以打开已存在的服务入口
|
|
43
|
+
withTempFile(linkPath, {}, (tmp) => {
|
|
44
|
+
fs.symlinkSync(entityName, tmp);
|
|
45
|
+
fs.renameSync(tmp, linkPath);
|
|
46
|
+
});
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* 幂等对账 bin/:实体拷贝 + 服务软链。所有 install 路径都先经这里。
|
|
52
|
-
*
|
|
53
|
-
* 靠的就是实体已先行刷对。
|
|
52
|
+
* 先刷实体再建链,软链位即使有旧文件,也可以直接换成指向新实体的链接。
|
|
54
53
|
* @param {object} ctx
|
|
55
|
-
* @param {readonly
|
|
54
|
+
* @param {readonly string[]} entities 原名安装的包脚本
|
|
56
55
|
* @param {readonly (readonly [string, string])[]} links [链名, 实体 bin 名]
|
|
57
56
|
* @returns {boolean[]} 每项是否发生变更
|
|
58
57
|
*/
|
|
59
|
-
export function ensureRuntime(ctx,
|
|
58
|
+
export function ensureRuntime(ctx, entities, links = []) {
|
|
60
59
|
fs.mkdirSync(ctx.paths.binDir, { recursive: true });
|
|
61
|
-
const results =
|
|
62
|
-
ensureScript(ctx.paths.binScript(name), packageScriptPath(
|
|
60
|
+
const results = entities.map((name) =>
|
|
61
|
+
ensureScript(ctx.paths.binScript(name), packageScriptPath(name)));
|
|
63
62
|
for (const [name, entityName] of links) {
|
|
64
63
|
results.push(ensureLink(ctx.paths.binScript(name), entityName));
|
|
65
64
|
}
|
|
@@ -69,26 +68,18 @@ export function ensureRuntime(ctx, entries, links = []) {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* 继续依赖包路径;位丢了时 Match exec 直接 EACCES,只报字节一致会让 status
|
|
75
|
-
* 在选路静默落 relay 时误判健康。
|
|
71
|
+
* 实体须为权限 0755 的普通文件,且与包内脚本逐字节相同。先查类型,避免跟随
|
|
72
|
+
* 软链或读取命名管道。安装时直接复用即将写入的字节
|
|
76
73
|
* @param {string} dstPath
|
|
77
|
-
* @param {string}
|
|
74
|
+
* @param {string|Buffer} source 包内脚本的路径或已读内容
|
|
78
75
|
* @returns {'ok'|'missing'|'stale'}
|
|
79
76
|
*/
|
|
80
|
-
export function auditScript(dstPath,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (err.code !== 'ENOENT') throw err;
|
|
87
|
-
return 'missing';
|
|
88
|
-
}
|
|
89
|
-
if (!st.isFile() || !cur.equals(fs.readFileSync(srcPath)) || !(st.mode & 0o111))
|
|
90
|
-
return 'stale';
|
|
91
|
-
return 'ok';
|
|
77
|
+
export function auditScript(dstPath, source) {
|
|
78
|
+
const st = fs.lstatSync(dstPath, { throwIfNoEntry: false });
|
|
79
|
+
if (!st) return 'missing';
|
|
80
|
+
if (!isRuntimeFile(st)) return 'stale';
|
|
81
|
+
const expected = Buffer.isBuffer(source) ? source : fs.readFileSync(source);
|
|
82
|
+
return fs.readFileSync(dstPath).equals(expected) ? 'ok' : 'stale';
|
|
92
83
|
}
|
|
93
84
|
|
|
94
85
|
/**
|
|
@@ -103,7 +94,8 @@ export function auditLink(linkPath, entityName) {
|
|
|
103
94
|
if (!st?.isSymbolicLink()) return false;
|
|
104
95
|
if (fs.readlinkSync(linkPath) !== entityName) return false;
|
|
105
96
|
try {
|
|
106
|
-
|
|
97
|
+
const target = fs.lstatSync(path.join(path.dirname(linkPath), entityName));
|
|
98
|
+
return isRuntimeFile(target);
|
|
107
99
|
} catch {
|
|
108
100
|
return false;
|
|
109
101
|
}
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
// - **跳过 Match 块**(同理,Match 是条件覆盖,不是静态主机定义)
|
|
9
9
|
// - 只收录精确别名(无通配的 Host 模式);`Host *` / `Host n*` 不入表
|
|
10
10
|
// - 关键字大小写不敏感(ssh 规则),同块内同关键字取首次(ssh 首次生效)
|
|
11
|
-
// - 行首 `#`
|
|
11
|
+
// - 行首 `#` 注释、空行忽略
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { SSH_NET_DIR_REL } from './constants.mjs';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* @typedef {Object} StaticHost
|
|
@@ -16,23 +19,98 @@
|
|
|
16
19
|
*/
|
|
17
20
|
|
|
18
21
|
const GLOB_CHARS = new Set(['*', '?', '!']);
|
|
22
|
+
const ROUTES_INCLUDE = `~/${SSH_NET_DIR_REL}/conf.d/*`;
|
|
19
23
|
|
|
20
24
|
/** @param {string} pattern Host 模式 */
|
|
21
25
|
function isExactPattern(pattern) {
|
|
22
26
|
return ![...pattern].some((c) => GLOB_CHARS.has(c));
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/** 比较 Include 目录的真实位置。首次安装允许末尾目录还没创建,但不能跨过不存在的目录解析 .. */
|
|
30
|
+
function directoryLocation(dir) {
|
|
31
|
+
try { return fs.realpathSync.native(dir); } catch (err) {
|
|
32
|
+
if (['ENOTDIR', 'EACCES', 'EPERM', 'ELOOP'].includes(err.code)) return null;
|
|
33
|
+
if (err.code !== 'ENOENT') throw err;
|
|
34
|
+
const name = path.basename(dir);
|
|
35
|
+
if (name === '..' || fs.lstatSync(dir, { throwIfNoEntry: false })) return null;
|
|
36
|
+
const parent = directoryLocation(path.dirname(dir));
|
|
37
|
+
return parent && path.join(parent, name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** OpenSSH 9.9 起在 Include 中展开环境变量。只在用户实际使用该写法时查询版本 */
|
|
42
|
+
export function supportsIncludeEnv(runner) {
|
|
43
|
+
const r = runner.run('ssh', ['-V']);
|
|
44
|
+
const version = `${r.stderr} ${r.stdout}`.match(/\bOpenSSH_(\d+)\.(\d+)/);
|
|
45
|
+
if (r.code !== 0 || !version) throw new Error('无法确认 SSH 客户端版本,请使用 Include ~/.ssh/ssh-net/conf.d/*');
|
|
46
|
+
return Number(version[1]) > 9 || (Number(version[1]) === 9 && Number(version[2]) >= 9);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 用户配置的相对 Include 从 ~/.ssh 起算;只核对路径,不读片段内容 */
|
|
50
|
+
function includesRoutes(tokens, { sshDir, confDir }, allowEnv) {
|
|
51
|
+
return tokens.some((token) => {
|
|
52
|
+
// glob 末尾的 / 只选目录。遇到 .. 要按实际目录解析,不能跨过不存在的目录或软链
|
|
53
|
+
if (!token.endsWith('/*') || (token.startsWith('${HOME}/') && !allowEnv())) return false;
|
|
54
|
+
const expanded = token.replace(/^(?:~|\$\{HOME\})(?=\/)/, () => path.dirname(sshDir));
|
|
55
|
+
const dir = path.dirname(path.isAbsolute(expanded) ? expanded : `${sshDir}/${expanded}`);
|
|
56
|
+
if (!dir.split('/').includes('..') && path.normalize(dir) === confDir) return true;
|
|
57
|
+
const actual = directoryLocation(dir);
|
|
58
|
+
return actual !== null && actual === directoryLocation(confDir);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** OpenSSH 参数可拼接引号内外的字串,# 只在参数开头引出注释 */
|
|
63
|
+
function configArgs(value) {
|
|
64
|
+
const words = [];
|
|
65
|
+
let word = '', quote = '', started = false;
|
|
66
|
+
for (let i = 0; i < value.length; i++) {
|
|
67
|
+
const c = value[i];
|
|
68
|
+
const next = value[i + 1];
|
|
69
|
+
if (c === '\\' && (['\\', '"', "'"].includes(next) || (!quote && (next === ' ' || next === '\t')))) {
|
|
70
|
+
word += value[++i];
|
|
71
|
+
} else if (quote) {
|
|
72
|
+
if (c === quote) quote = '';
|
|
73
|
+
else word += c;
|
|
74
|
+
} else if (c === '"' || c === "'") {
|
|
75
|
+
quote = c;
|
|
76
|
+
} else if (/\s/.test(c)) {
|
|
77
|
+
if (started) words.push(word);
|
|
78
|
+
word = ''; started = false;
|
|
79
|
+
continue;
|
|
80
|
+
} else if (c === '#' && !started) {
|
|
81
|
+
break;
|
|
82
|
+
} else {
|
|
83
|
+
word += c;
|
|
84
|
+
}
|
|
85
|
+
started = true;
|
|
86
|
+
}
|
|
87
|
+
if (quote) throw new Error('~/.ssh/config 中的引号没有闭合');
|
|
88
|
+
if (started) words.push(word);
|
|
89
|
+
return words;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function exactHosts(tokens) {
|
|
93
|
+
const excluded = tokens.filter((token) => token.startsWith('!')).map((token) => {
|
|
94
|
+
const pattern = token.slice(1).split(/([*?])/).map((part) =>
|
|
95
|
+
part === '*' ? '.*' : part === '?' ? '.' : RegExp.escape(part)).join('');
|
|
96
|
+
return new RegExp(`^${pattern}$`);
|
|
97
|
+
});
|
|
98
|
+
return tokens.filter((token) => isExactPattern(token) && !excluded.some((re) => re.test(token)));
|
|
99
|
+
}
|
|
100
|
+
|
|
25
101
|
/**
|
|
26
102
|
* 解析主 ssh config 的静态 Host 块。
|
|
27
103
|
* @param {string} text ~/.ssh/config 原文
|
|
104
|
+
* @param {{sshDir:string, confDir:string}} [paths] 读取本机配置时核对顶部 Include
|
|
105
|
+
* @param {() => boolean} [allowEnv] 本机 SSH 是否能展开 Include 中的环境变量
|
|
28
106
|
* @returns {Map<string, StaticHost>} key=精确别名
|
|
29
107
|
*/
|
|
30
|
-
export function parseStaticHosts(text) {
|
|
108
|
+
export function parseStaticHosts(text, paths, allowEnv = () => false) {
|
|
31
109
|
/** @type {Map<string, StaticHost>} */
|
|
32
110
|
const table = new Map();
|
|
33
|
-
/** @type {string[]} */
|
|
34
|
-
let currentPatterns =
|
|
35
|
-
let
|
|
111
|
+
/** @type {string[]|null} 首个 Host/Match 前的 Include 对所有主机生效 */
|
|
112
|
+
let currentPatterns = null;
|
|
113
|
+
let routesIncluded = false;
|
|
36
114
|
|
|
37
115
|
for (const raw of text.split('\n')) {
|
|
38
116
|
const line = raw.trim();
|
|
@@ -41,33 +119,36 @@ export function parseStaticHosts(text) {
|
|
|
41
119
|
const parsed = line.match(/^([^\s=]+)\s*(?:=\s*|\s+)(.*)$/);
|
|
42
120
|
if (!parsed) continue;
|
|
43
121
|
const keyword = parsed[1].toLowerCase();
|
|
44
|
-
const
|
|
122
|
+
const value = parsed[2];
|
|
45
123
|
|
|
124
|
+
if (keyword === 'include') {
|
|
125
|
+
if (paths && currentPatterns === null) routesIncluded ||= includesRoutes(configArgs(value), paths, allowEnv);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
46
128
|
if (keyword === 'match') {
|
|
47
|
-
inMatch = true;
|
|
48
129
|
currentPatterns = [];
|
|
49
130
|
continue;
|
|
50
131
|
}
|
|
51
132
|
if (keyword === 'host') {
|
|
52
|
-
inMatch = false;
|
|
53
133
|
// 精确模式入表(多模式逐个);同一别名多个 Host 块时 ssh 取首次值——
|
|
54
134
|
// 已存在的记录对象继续沿用,首次值写入不被后块覆盖
|
|
55
|
-
currentPatterns =
|
|
135
|
+
currentPatterns = exactHosts(configArgs(value));
|
|
56
136
|
for (const p of currentPatterns) {
|
|
57
137
|
if (!table.has(p)) table.set(p, {});
|
|
58
138
|
}
|
|
59
139
|
continue;
|
|
60
140
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
141
|
+
if (keyword === 'hostname' && currentPatterns?.length && value) {
|
|
142
|
+
const args = configArgs(value);
|
|
143
|
+
if (args.length !== 1 || !args[0]) throw new Error('~/.ssh/config 的 HostName 需要一个地址');
|
|
144
|
+
const [hostname] = args;
|
|
145
|
+
for (const p of currentPatterns) {
|
|
146
|
+
const host = table.get(p);
|
|
147
|
+
host.hostname ??= hostname;
|
|
69
148
|
}
|
|
70
149
|
}
|
|
71
150
|
}
|
|
151
|
+
if (paths && !routesIncluded)
|
|
152
|
+
throw new Error(`~/.ssh/config 需要在首个 Host 或 Match 之前写入 Include ${ROUTES_INCLUDE}——请运行 dot apply ssh`);
|
|
72
153
|
return table;
|
|
73
154
|
}
|