src/vs/platform/agentHost/common/sshConfigParsing.ts
65 LOC · 65 covered · 0 uncovered · 14 ranges · 109 concepts · 8 introducers · 84 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
sshConfigParsing.ts ×3
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { ISSHResolvedConfig } from './sshRemoteAgentHost.js';
/** Strip inline comments from an SSH config value. */
export function stripSSHComment(s: string): string {
return idx !== -1 ? s.substring(0, idx).trim() : s;
}
/**
* Extract Host aliases from SSH config content (without following Includes).
*/
export function parseSSHConfigHostEntries(content: string): string[] {
for (const line of content.split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) {
}
if (hostMatch) {
const hostValue = stripSSHComment(hostMatch[1]);
for (const h of hostValue.split(/\s+/)) {
if (!h.includes('*') && !h.includes('?') && !h.startsWith('!')) {
hosts.push(h);
}
}
}
return hosts;
}
/**
* Parse `ssh -G` output into a resolved config object.
*/
export function parseSSHGOutput(stdout: string): ISSHResolvedConfig {
const identityFiles: string[] = [];
for (const line of stdout.split('\n')) {
const spaceIdx = line.indexOf(' ');
if (spaceIdx === -1) {
}
const value = line.substring(spaceIdx + 1).trim();
if (key === 'identityfile') {
map.set(key, value);
}
return {
hostname: map.get('hostname') ?? '',
user: map.get('user') || undefined,
port: parseInt(map.get('port') ?? '22', 10),
identityFile: identityFiles,
identityAgent: map.get('identityagent') || undefined,
forwardAgent: map.get('forwardagent') === 'yes',
};
}