Allow tunnel providers to define port privacy options (#133677)

This commit is contained in:
Alex Ross
2021-09-23 16:24:51 +02:00
committed by GitHub
parent fd6adaf30a
commit a15378a9db
16 changed files with 254 additions and 143 deletions

View File

@@ -6,7 +6,7 @@
import { ExtHostTunnelServiceShape } from 'vs/workbench/api/common/extHost.protocol';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import * as vscode from 'vscode';
import { ProvidedPortAttributes, RemoteTunnel, TunnelCreationOptions, TunnelOptions } from 'vs/platform/remote/common/tunnel';
import { ProvidedPortAttributes, RemoteTunnel, TunnelCreationOptions, TunnelOptions, TunnelPrivacyId } from 'vs/platform/remote/common/tunnel';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
@@ -17,12 +17,19 @@ export interface TunnelDto {
remoteAddress: { port: number, host: string };
localAddress: { port: number, host: string } | string;
public: boolean;
privacy: TunnelPrivacyId | string;
protocol: string | undefined;
}
export namespace TunnelDto {
export function fromApiTunnel(tunnel: vscode.Tunnel): TunnelDto {
return { remoteAddress: tunnel.remoteAddress, localAddress: tunnel.localAddress, public: !!tunnel.public, protocol: tunnel.protocol };
return {
remoteAddress: tunnel.remoteAddress,
localAddress: tunnel.localAddress,
public: !!tunnel.public,
privacy: tunnel.privacy ?? (tunnel.public ? TunnelPrivacyId.Public : TunnelPrivacyId.Private),
protocol: tunnel.protocol
};
}
export function fromServiceTunnel(tunnel: RemoteTunnel): TunnelDto {
return {
@@ -31,7 +38,8 @@ export namespace TunnelDto {
port: tunnel.tunnelRemotePort
},
localAddress: tunnel.localAddress,
public: tunnel.public,
public: tunnel.privacy !== TunnelPrivacyId.ConstantPrivate && tunnel.privacy !== TunnelPrivacyId.ConstantPrivate,
privacy: tunnel.privacy,
protocol: tunnel.protocol
};
}