src/vs/platform/remote/common/remoteHosts.ts
109 LOC · 94 covered · 15 uncovered · 22 ranges · 5749 concepts · 14 introducers · 3094 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.
/*---------------------------------------------------------------------------------------------
remoteHosts.ts ×7
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Schemas } from '../../../base/common/network.js';
import { URI } from '../../../base/common/uri.js';
export function getRemoteAuthority(uri: URI): string | undefined {
return uri.scheme === Schemas.vscodeRemote ? uri.authority : undefined;
}
export function getRemoteName(authority: string): string;
export function getRemoteName(authority: undefined): undefined;
export function getRemoteName(authority: string | undefined): string | undefined;
export function getRemoteName(authority: string | undefined): string | undefined {
return undefined;
}
if (pos < 0) {
return authority;
}
}
/**
* Returns the suffix part of the authority after the '+' character.
* For remote connections, this is typically the server/tunnel identifier.
* Examples:
* - For tunnels: `tunnel+myTunnel` returns `myTunnel`
* - For SSH: `ssh+myserver` returns `myserver`
* - For localhost: `localhost:8000` returns `undefined`
* @param authority The remote authority string.
* @returns The suffix after the '+' character, or undefined if there is no '+' character.
*/
export function getRemoteServerRootPath(authority: string): string | undefined;
export function getRemoteServerRootPath(authority: undefined): undefined;
export function getRemoteServerRootPath(authority: string | undefined): string | undefined;
export function getRemoteServerRootPath(authority: string | undefined): string | undefined {
if (!authority) {
return undefined;
}
const pos = authority.indexOf('+');
if (pos < 0) {
return undefined;
}
return authority.substring(pos + 1);
}
export function parseAuthorityWithPort(authority: string): { host: string; port: number } {
if (typeof port === 'undefined') {
throw new Error(`Invalid remote authority: ${authority}. It must either be a remote of form <remoteName>+<arg> or a remote host of form <host>:<port>.`);
}
}
export function parseAuthorityWithOptionalPort(authority: string, defaultPort: number): { host: string; port: number } {
if (typeof port === 'undefined') {
port = defaultPort;
}
return { host, port };
}
function parseAuthority(authority: string): { host: string; port: number | undefined } {
remoteHosts.ts ×1
// check for ipv6 with port
const m1 = authority.match(/^(\[[0-9a-z:]+\]):(\d+)$/);
if (m1) {
}
// check for ipv6 without port
const m2 = authority.match(/^(\[[0-9a-z:]+\])$/);
if (m2) {
}
// anything with a trailing port
const m3 = authority.match(/(.*):(\d+)$/);
if (m3) {
}
// doesn't contain a port
return { host: authority, port: undefined };
}
const loopbackHosts = new Set([
'localhost',
'127.0.0.1',
'::1',
'[::1]',
'0000:0000:0000:0000:0000:0000:0000:0001',
'[0000:0000:0000:0000:0000:0000:0000:0001]'
]);
/**
* Returns whether the given host (as found in a direct `<host>:<port>` remote
* authority) refers to the local loopback interface. The check is intentionally
* strict: only `localhost` and the IPv4/IPv6 loopback literals are considered
* local. Any other host (a routable IP address or a hostname) is treated as a
* connection that leaves the local machine.
*/
export function isLoopbackHost(host: string): boolean {
}