2019-08-27 21:11:49 +00:00
|
|
|
'use strict'
|
2019-08-27 18:17:33 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
const os = require('os')
|
|
|
|
const path = require('path')
|
2020-07-22 15:11:48 +00:00
|
|
|
const crypto = require('crypto')
|
|
|
|
|
|
|
|
function uuid () {
|
|
|
|
return crypto.randomBytes(16).toString('hex')
|
|
|
|
}
|
2019-08-27 18:17:33 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
function getSock () {
|
2019-08-27 18:17:33 +00:00
|
|
|
if (process.platform === 'win32') {
|
2019-08-27 21:11:49 +00:00
|
|
|
return '\\\\.\\pipe\\' + uuid()
|
2019-08-27 18:17:33 +00:00
|
|
|
} else {
|
2019-08-27 21:11:49 +00:00
|
|
|
return path.join(os.tmpdir(), uuid())
|
2019-08-27 18:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2020-07-22 15:11:48 +00:00
|
|
|
getSock,
|
|
|
|
uuid
|
2019-08-27 18:17:33 +00:00
|
|
|
}
|