Browse Source

don't define host and port, even as null

pull/8/head
AJ ONeal 6 years ago
parent
commit
8f7ab08a99
  1. 20
      bin/telebitd.js
  2. 20
      tests/windows-pipe.js
  3. 22
      tests/windows-spawn-pipe.js

20
bin/telebitd.js

@ -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

@ -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());
});

22
tests/windows-spawn-pipe.js

@ -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');
});
Loading…
Cancel
Save