added defaults to allow local certs to be used when not specified

This commit is contained in:
Brandon Nozaki Miller 2015-09-27 22:00:26 -07:00
parent 737d856a32
commit 6fc0199f01
3 changed files with 88 additions and 0 deletions

View file

@ -0,0 +1,42 @@
var ipc=require('../../../node-ipc');
/***************************************\
*
* You should start both hello and world
* then you will see them communicating.
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.tls={
rejectUnauthorized:false
};
ipc.connectToNet(
'world',
function(){
ipc.of.world.on(
'connect',
function(){
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
ipc.of.world.emit(
'message',
'hello'
)
}
);
ipc.of.world.on(
'disconnect',
function(){
ipc.log('disconnected from world'.notice);
}
);
ipc.of.world.on(
'message',
function(data){
ipc.log('got a message from world : '.debug, data);
}
);
}
);

View file

@ -0,0 +1,42 @@
var ipc=require('../../../node-ipc');
/***************************************\
*
* You should start both hello and world
* then you will see them communicating.
*
* *************************************/
ipc.config.id = 'world';
ipc.config.retry= 1500;
//node-ipc will default to its local certs
ipc.config.tls={
rejectUnauthorized:false
}
ipc.serveNet(
function(){
ipc.server.on(
'message',
function(data,socket){
ipc.log('got a message : '.debug, data);
ipc.server.emit(
socket,
'message',
data+' world!'
);
}
);
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
}
);
}
);
ipc.server.define.listen.message='This event type listens for message strings as value of data key.';
ipc.server.start();

View file

@ -110,9 +110,13 @@ function init(path,config,log,port){
server.log('starting TLS server'.debug,server.config.tls);
if(server.config.tls.private){
server.config.tls.key=fs.readFileSync(server.config.tls.private);
}else{
server.config.tls.key=fs.readFileSync(__dirname+'/../local-node-ipc-certs/private/server.key');
}
if(server.config.tls.public){
server.config.tls.cert=fs.readFileSync(server.config.tls.public);
}else{
server.config.tls.cert=fs.readFileSync(__dirname+'/../local-node-ipc-certs/server.pub');
}
if(server.config.tls.dhparam){
server.config.tls.dhparam=fs.readFileSync(server.config.tls.dhparam);