Skip to content

Commit 7259610

Browse files
committed
Use ssh-config for fork until new version is published
1 parent 38e532d commit 7259610

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
"glob": "^9.3.1",
364364
"simple-socks": "git+https://github.com/jeanp413/simple-socks#main",
365365
"socks": "^2.5.0",
366-
"ssh-config": "^4.3.0",
366+
"ssh-config": "git+https://github.com/jeanp413/ssh-config#master",
367367
"ssh2": "git+https://github.com/jeanp413/ssh2#master"
368368
}
369369
}

src/ssh/sshConfig.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ async function parseSSHConfigFromFile(filePath: string, userConfig: boolean) {
6969
for (let i = 0; i < config.length; i++) {
7070
const line = config[i];
7171
if (isIncludeDirective(line)) {
72-
const includePaths = await glob(normalizeToSlash(untildify(line.value)), {
73-
absolute: true,
74-
cwd: normalizeToSlash(path.dirname(userConfig ? defaultSSHConfigPath : systemSSHConfig))
75-
});
76-
for (const p of includePaths) {
77-
includedConfigs.set(i, await parseSSHConfigFromFile(p, userConfig));
72+
const values = (line.value as string).split(',').map(s => s.trim());
73+
for (const value of values) {
74+
const includePaths = await glob(normalizeToSlash(untildify(value)), {
75+
absolute: true,
76+
cwd: normalizeToSlash(path.dirname(userConfig ? defaultSSHConfigPath : systemSSHConfig))
77+
});
78+
for (const p of includePaths) {
79+
includedConfigs.set(i, await parseSSHConfigFromFile(p, userConfig));
80+
}
7881
}
7982
}
8083
}
@@ -101,7 +104,7 @@ export default class SSHConfiguration {
101104
const hosts = new Set<string>();
102105
for (const line of this.sshConfig) {
103106
if (isHostSection(line)) {
104-
const value = Array.isArray(line.value as string[] | string) ? line.value[0] : line.value;
107+
const value = Array.isArray(line.value) ? line.value[0] : line.value;
105108
const isPattern = /^!/.test(value) || /[?*]/.test(value);
106109
if (!isPattern) {
107110
hosts.add(value);
@@ -113,6 +116,8 @@ export default class SSHConfiguration {
113116
}
114117

115118
getHostConfiguration(host: string): Record<string, string> {
116-
return this.sshConfig.compute(host);
119+
// Only a few directives return an array
120+
// https://github.com/jeanp413/ssh-config/blob/8d187bb8f1d83a51ff2b1d127e6b6269d24092b5/src/ssh-config.ts#L9C1-L9C118
121+
return this.sshConfig.compute(host) as Record<string, string>;
117122
}
118123
}

yarn.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,10 +1526,9 @@ spdx-license-ids@^3.0.0:
15261526
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz#50c0d8c40a14ec1bf449bae69a0ea4685a9d9f95"
15271527
integrity sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==
15281528

1529-
ssh-config@^4.3.0:
1529+
"ssh-config@git+https://github.com/jeanp413/ssh-config#master":
15301530
version "4.3.0"
1531-
resolved "https://registry.yarnpkg.com/ssh-config/-/ssh-config-4.3.0.tgz#3a132c656374a5fbdd57c9f9e8aa8542eff1a666"
1532-
integrity sha512-VOsrKxYnes0A3NGzzuOAy2yB36gv+hie77ltuqLXOWRiYrmAWI9WrKAKJ2+/4f+6vx4eEDSnGYGaCbyqX8aHxg==
1531+
resolved "git+https://github.com/jeanp413/ssh-config#8d187bb8f1d83a51ff2b1d127e6b6269d24092b5"
15331532

15341533
"ssh2@git+https://github.com/jeanp413/ssh2#master":
15351534
version "1.11.0"

0 commit comments

Comments
 (0)