Skip to content

Commit

Permalink
refactor: use paths.runtime in socket proxyPipe
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjoeio committed May 13, 2021
1 parent 2a657ab commit d7f1415
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/node/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import * as path from "path"
import * as tls from "tls"
import { Emitter } from "../common/emitter"
import { generateUuid } from "../common/util"
import { tmpdir } from "./constants"
import { canConnect } from "./util"
import { canConnect, paths } from "./util"

/**
* Provides a way to proxy a TLS socket. Can be used when you need to pass a
* socket to a child process since you can't pass the TLS socket.
*/
export class SocketProxyProvider {
private readonly onProxyConnect = new Emitter<net.Socket>()
private proxyPipe = path.join(tmpdir, "tls-proxy")
private proxyPipe = path.join(paths.runtime, "tls-proxy")
private _proxyServer?: Promise<net.Server>
private readonly proxyTimeout = 5000

Expand Down Expand Up @@ -76,7 +75,10 @@ export class SocketProxyProvider {
this._proxyServer = this.findFreeSocketPath(this.proxyPipe)
.then((pipe) => {
this.proxyPipe = pipe
return Promise.all([fs.mkdir(tmpdir, { recursive: true }), fs.rmdir(this.proxyPipe, { recursive: true })])
return Promise.all([
fs.mkdir(paths.runtime, { recursive: true }),
fs.rmdir(this.proxyPipe, { recursive: true }),
])
})
.then(() => {
return new Promise((resolve) => {
Expand Down

0 comments on commit d7f1415

Please sign in to comment.