1
>
/*---------------------------------------------------------------------------------------------
serverUrls.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import * as os from 'os';
7
>
8
>
export interface IResolvedServerUrls {
9
>
readonly local: readonly string[];
10
>
readonly network: readonly string[];
11
>
}
12
>
13
>
const loopbackHosts = new Set(['localhost', '127.0.0.1', '::1', '0000:0000:0000:0000:0000:0000:0000:0001']);
14
>
const wildcardHosts = new Set(['0.0.0.0', '::', '0000:0000:0000:0000:0000:0000:0000:0000']);
15
>
16
>
export function resolveServerUrls(host: string | undefined, port: number, networkInterfaces: ReturnType<typeof os.networkInterfaces> = os.networkInterfaces()): IResolvedServerUrls {
17
>
if (host === undefined) {
18
return { local: [formatWebSocketUrl('localhost', port)], network: [] };
19
}