MCPcopy Index your code
hub / github.com/coder/code-server / startProxyServer

Method startProxyServer

src/node/socket.ts:77–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

createProxyMethod · 0.95

Calls 5

findFreeSocketPathMethod · 0.95
resolveFunction · 0.85
emitMethod · 0.80
onceMethod · 0.80
listenMethod · 0.80

Tested by

no test coverage detected