From 1326a4c162af08975d5af63307304ac84ed302e2 Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Sun, 26 Jul 2015 21:52:02 -0700 Subject: [PATCH] updated for default system networking preference ipv4 or ipv6 --- .brackets.json | 3 +++ README.md | 4 ++-- node-ipc.js | 12 ++++++++---- package.json | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .brackets.json diff --git a/.brackets.json b/.brackets.json new file mode 100644 index 0000000..42bf8a6 --- /dev/null +++ b/.brackets.json @@ -0,0 +1,3 @@ +{ + "sbruchmann.staticpreview.basepath": "/home/bmiller/git/node-ipc/" +} diff --git a/README.md b/README.md index 7e847be..84a85cf 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Set these variables in the ``ipc.config`` scope to overwrite or set default valu appspace : 'app.', socketRoot : '/tmp/', id : os.hostname(), - networkHost : '127.0.0.1', //we use this instead of localhost as default because windows without network connection turns dns off and is unable to find localhost like other... smarter... OSes + networkHost : 'localhost', //should resolve to 127.0.0.1 or ::1 see the table below related to this networkPort : 8000, encoding : 'utf8', silent : false, @@ -275,7 +275,7 @@ Used to create TCP, TLS or UDP Socket Server to which Clients can bind or other | variable | required | definition | |----------|----------|------------| -| host | optional | If not specified this defaults to 127.0.0.1. For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or 0.0.0.0 unless you have something like [node-http-server](https://github.com/RIAEvangelist/node-http-server) installed to run subdomains for you. | +| host | optional | If not specified this defaults to the first address in os.networkInterfaces(). For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or ::1 | | port | optional | The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified | | UDPType | optional | If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set. | callback | optional | Function to be called when the server is created | diff --git a/node-ipc.js b/node-ipc.js index fc573d5..7eac337 100644 --- a/node-ipc.js +++ b/node-ipc.js @@ -1,4 +1,5 @@ var os = require('os'), + dns = require('dns'), util = require('util'), colors = require('colors'), pubsub = require('event-pubsub'), @@ -21,7 +22,9 @@ colors.setTheme( var defaults={ appspace : 'app.', socketRoot : '/tmp/', - networkHost : '127.0.0.1', + networkHost : os.networkInterfaces()[ + Object.keys(os.networkInterfaces())[0] + ][0].address, networkPort : 8000, id : os.hostname(), encoding : 'utf8', @@ -160,17 +163,18 @@ function serveNet(host,port,UDPType,callback){ if(!callback) callback=function(){}; - + + ipc.server=new Server( host, ipc.config, log, port ); - + if(UDPType) ipc.server[UDPType]=true; - + ipc.server.on( 'start', callback diff --git a/package.json b/package.json index 4f6d726..191f2f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-ipc", - "version": "1.1.13", + "version": "1.2.1", "description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.", "main": "node-ipc.js", "directories": {