node-ipc/entities/Defaults.js

64 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-07-03 07:35:02 +10:00
import os from 'os';
2016-01-12 09:25:48 +11:00
2016-01-11 15:59:40 +11:00
class Defaults{
2016-01-11 15:59:40 +11:00
constructor(){
2021-07-03 07:35:02 +10:00
}
2021-07-03 07:35:02 +10:00
appspace='app.';
socketRoot='/tmp/';
id=os.hostname();
2017-04-16 14:13:15 +10:00
2021-07-03 07:35:02 +10:00
encoding='utf8';
rawBuffer=false;
sync=false;
unlink=true;
2021-07-03 07:35:02 +10:00
delimiter='\f';
2021-07-03 07:35:02 +10:00
silent=false;
logDepth=5;
logInColor=true;
logger=console.log.bind(console);
2021-07-03 07:35:02 +10:00
maxConnections=100;
retry=500;
maxRetries=Infinity;
stopRetrying=false;
IPType=getIPType();
tls=false;
networkHost = (this.IPType == 'IPv6') ? '::1' : '127.0.0.1';
networkPort = 8000;
interface={
localAddress:false,
localPort:false,
family:false,
hints:false,
lookup:false
}
2021-07-03 07:35:02 +10:00
}
function getIPType() {
const networkInterfaces = os.networkInterfaces();
let IPType = '';
if (networkInterfaces
&& Array.isArray(networkInterfaces)
&& networkInterfaces.length > 0) {
// getting the family of first network interface available
IPType = networkInterfaces [
Object.keys( networkInterfaces )[0]
][0].family;
2016-01-11 15:59:40 +11:00
}
return IPType;
2016-01-11 15:59:40 +11:00
}
2021-07-03 07:35:02 +10:00
export {
Defaults as default,
Defaults
}