added defaults to allow local certs to be used when not specified
This commit is contained in:
parent
737d856a32
commit
6fc0199f01
3 changed files with 88 additions and 0 deletions
42
example/TLSSocket/basic-local-only/hello-client.js
Normal file
42
example/TLSSocket/basic-local-only/hello-client.js
Normal 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);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
42
example/TLSSocket/basic-local-only/world-server.js
Normal file
42
example/TLSSocket/basic-local-only/world-server.js
Normal 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();
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue