()
| 75 | } |
| 76 | |
| 77 | private async startProxyServer(): Promise<net.Server> { |
| 78 | if (!this._proxyServer) { |
| 79 | this._proxyServer = this.findFreeSocketPath(this.proxyPipe) |
| 80 | .then((pipe) => { |
| 81 | this.proxyPipe = pipe |
| 82 | return Promise.all([ |
| 83 | fs.mkdir(path.dirname(this.proxyPipe), { recursive: true }), |
| 84 | fs.rm(this.proxyPipe, { force: true, recursive: true }), |
| 85 | ]) |
| 86 | }) |
| 87 | .then(() => { |
| 88 | return new Promise((resolve) => { |
| 89 | const proxyServer = net.createServer((p) => this.onProxyConnect.emit(p)) |
| 90 | proxyServer.once("listening", () => resolve(proxyServer)) |
| 91 | proxyServer.listen(this.proxyPipe) |
| 92 | }) |
| 93 | }) |
| 94 | } |
| 95 | return this._proxyServer |
| 96 | } |
| 97 | |
| 98 | public async findFreeSocketPath(basePath: string, maxTries = 100): Promise<string> { |
| 99 | let i = 0 |
no test coverage detected