src/vs/workbench/contrib/remote/common/tunnelFactory.ts/TunnelFactoryContribution/constructor
class TunnelFactoryContribution:	constructor(
		@ITunnelService tunnelService: ITunnelService,
		@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
		@IOpenerService private openerService: IOpenerService,
		@IRemoteExplorerService remoteExplorerService: IRemoteExplorerService,
		@ILogService logService: ILogService
	) {
		super();
		const tunnelFactory = environmentService.options?.tunnelProvider?.tunnelFactory;
		if (tunnelFactory) {
			this._register(tunnelService.setTunnelProvider({
				forwardPort: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions): Promise<RemoteTunnel | undefined> | undefined => {
					let tunnelPromise: Promise<ITunnel> | undefined;
					try {
						tunnelPromise = tunnelFactory(tunnelOptions, tunnelCreationOptions);
					} catch (e) {
						logService.trace('tunnelFactory: tunnel provider error');
					}

					return new Promise(async (resolve) => {
						if (!tunnelPromise) {
							resolve(undefined);
							return;
						}
						let tunnel: ITunnel;
						try {
							tunnel = await tunnelPromise;
						} catch (e) {
							logService.trace('tunnelFactory: tunnel provider promise error');
							resolve(undefined);
							return;
						}
						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),
							public: !!tunnel.public,
							protocol: tunnel.protocol ?? TunnelProtocol.Http,
							dispose: async () => { await tunnel.dispose(); }
						};
						resolve(remoteTunnel);
					});
				}
			}, environmentService.options?.tunnelProvider?.features ?? { elevation: false, public: false }));
			remoteExplorerService.setTunnelInformation(undefined);
		}
	}