don't define host and port, even as null

This commit is contained in:
AJ ONeal 2018-07-03 04:37:41 -06:00
parent 219166670b
commit 8f7ab08a99
3 changed files with 54 additions and 8 deletions

View File

@ -571,17 +571,21 @@ function serveControlsHelper() {
// mask is so that processes owned by other users
// can speak to this process, which is probably root-owned
var oldUmask = process.umask(0x0000);
var serverOpts = {
writableAll: true
, readableAll: true
, exclusive: false
};
if ('socket' === state._ipc.type) {
require('mkdirp').sync(path.dirname(state._ipc.path));
}
controlServer.listen({
path: state._ipc.path || null
, host: 'localhost'
, port: state._ipc.port || null
, writableAll: true
, readableAll: true
, exclusive: false
}, function () {
if (state._ipc.port) {
serverOpts.host = 'localhost';
serverOpts.port = state._ipc.port;
} else {
serverOpts.path = state._ipc.path;
}
controlServer.listen(serverOpts, function () {
process.umask(oldUmask);
var address = this.address();
if (address.port) {

20
tests/windows-pipe.js Normal file
View File

@ -0,0 +1,20 @@
'use strict';
var os = require('os');
var net = require('net');
var ipc = {
path: /^win/.test(os.platform()) ? '\\\\.\\pipe\\X:/name/of/pipe' : (__dirname + '/tmp.sock')
};
var oldUmask = process.umask(0x0000);
var server = net.createServer();
server.listen({
path: ipc.path || null
, host: 'localhost'
, port: ipc.port || null
, writeableAll: true
, readableAll: true
}, function () {
process.umask(oldUmask);
console.log("Listening on", this.address());
});

View File

@ -0,0 +1,22 @@
'use strict';
var path = require('path');
var spawn = require('child_process').spawn;
var args = [
path.join(__dirname, 'windows-pipe.js')
];
var subprocess = spawn(
'node'
, args
, { detached: true
, stdio: [ 'ignore', process.stdout, process.stderr ]
}
);
//console.log('[debug]', vars.telebitNode, args.join(' '));
subprocess.unref();
subprocess.on('error', function (_err) {
console.error(_err);
});
subprocess.on('exit', function (code, signal) {
console.error('' + code + ' ' + signal + ' failure to launch');
});