mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-22 19:29:17 +00:00
@@ -10,6 +10,7 @@ import { denodeify } from './util';
|
||||
import * as path from 'path';
|
||||
import * as http from 'http';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
const randomBytes = denodeify<Buffer>(crypto.randomBytes);
|
||||
@@ -38,6 +39,7 @@ export class Askpass implements Disposable {
|
||||
|
||||
private server: http.Server;
|
||||
private ipcHandlePathPromise: Promise<string>;
|
||||
private ipcHandlePath: string | undefined;
|
||||
private enabled = true;
|
||||
|
||||
constructor() {
|
||||
@@ -52,6 +54,7 @@ export class Askpass implements Disposable {
|
||||
const buffer = await randomBytes(20);
|
||||
const nonce = buffer.toString('hex');
|
||||
const ipcHandlePath = getIPCHandlePath(nonce);
|
||||
this.ipcHandlePath = ipcHandlePath;
|
||||
|
||||
try {
|
||||
this.server.listen(ipcHandlePath);
|
||||
@@ -110,5 +113,9 @@ export class Askpass implements Disposable {
|
||||
|
||||
dispose(): void {
|
||||
this.server.close();
|
||||
|
||||
if (this.ipcHandlePath && process.platform !== 'win32') {
|
||||
fs.unlinkSync(this.ipcHandlePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user