src/vs/workbench/contrib/remote/browser/tunnelFactory.ts/TunnelFactoryContribution/constructor
class TunnelFactoryContribution:	constructor(
		@ITunnelService tunnelService: ITunnelService,
		@IBrowserWorkbenchEnvironmentService environmentService: IBrowserWorkbenchEnvironmentService,
		@IOpenerService private openerService: IOpenerService,
		@IRemoteExplorerService remoteExplorerService: IRemoteExplorerService,
		@ILogService logService: ILogService
	) {
		super();
		const tunnelFactory = environmentService.options?.tunnelProvider?.tunnelFactory;
		if (tunnelFactory) {
			let privacyOptions = environmentService.options?.tunnelProvider?.features?.privacyOptions ?? [];
			if (environmentService.options?.tunnelProvider?.features?.public
				&& (privacyOptions.length === 0)) {
				privacyOptions = [
					{
						id: 'private',
						label: nls.localize('tunnelPrivacy.private', "Private"),
						themeIcon: 'lock'
					},
					{
						id: 'public',
						label: nls.localize('tunnelPrivacy.public', "Public"),
						themeIcon: 'eye'
					}
				];
			}

			this._register(tunnelService.setTunnelProvider({
				forwardPort: async (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions): Promise<RemoteTunnel | undefined> => {
					let tunnelPromise: Promise<ITunnel> | undefined;
					try {
						tunnelPromise = tunnelFactory(tunnelOptions, tunnelCreationOptions);
					} catch (e) {
						logService.trace('tunnelFactory: tunnel provider error');
					}

					if (!tunnelPromise) {
						return undefined;
					}
					let tunnel: ITunnel;
					try {
						tunnel = await tunnelPromise;
					} catch (e) {
						logService.trace('tunnelFactory: tunnel provider promise error');
						return undefined;
					}
					const localAddress = tunnel.localAddress.startsWith('http') ? tunnel.localAddress : `http://${tunnel.localAddress}`;
					const remoteTunnel: RemoteTunnel = {
						tunnelRemotePort: tunnel.remoteAddress.port,
						tunnelRemoteHost: tunnel.remoteAddress.host,
						// The tunnel factory may give us an inaccessible local address.
						// To make sure this doesn't happen, resolve the uri immediately.
						localAddress: await this.resolveExternalUri(localAddress),
						privacy: tunnel.privacy ?? (tunnel.public ? TunnelPrivacyId.Public : TunnelPrivacyId.Private),
						protocol: tunnel.protocol ?? TunnelProtocol.Http,
						dispose: async () => { await tunnel.dispose(); }
					};
					return remoteTunnel;
				}
			}));
			const tunnelInformation = environmentService.options?.tunnelProvider?.features ?
				{
					features: {
						elevation: !!environmentService.options?.tunnelProvider?.features?.elevation,
						public: !!environmentService.options?.tunnelProvider?.features?.public,
						privacyOptions
					}
				} : undefined;
			remoteExplorerService.setTunnelInformation(tunnelInformation);
		}
	}