2016-01-11 15:59:40 +11:00
|
|
|
'use strict';
|
2016-01-12 09:25:48 +11:00
|
|
|
|
2016-08-03 05:04:28 +10:00
|
|
|
/*eslint no-magic-numbers: ["error", { "ignore": [ 0] }]*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @module entities
|
|
|
|
*/
|
|
|
|
|
2016-01-11 15:59:40 +11:00
|
|
|
const os = require('os');
|
|
|
|
|
2016-08-03 05:04:28 +10:00
|
|
|
/**
|
|
|
|
* @class Defaults
|
|
|
|
* @description Defaults Entity
|
|
|
|
*/
|
2016-01-11 15:59:40 +11:00
|
|
|
class Defaults{
|
2016-08-03 05:04:28 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @method constructor
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2016-01-11 15:59:40 +11:00
|
|
|
constructor(){
|
|
|
|
|
|
|
|
Object.defineProperties(
|
|
|
|
this,
|
|
|
|
{
|
|
|
|
appspace : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:'app.'
|
|
|
|
},
|
|
|
|
socketRoot : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:'/tmp/'
|
|
|
|
},
|
|
|
|
networkHost : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
2016-08-03 05:04:28 +10:00
|
|
|
value: ''
|
2016-01-11 15:59:40 +11:00
|
|
|
},
|
|
|
|
networkPort : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:8000
|
|
|
|
},
|
|
|
|
id : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:os.hostname()
|
|
|
|
},
|
|
|
|
encoding : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:'utf8'
|
|
|
|
},
|
|
|
|
rawBuffer : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:false
|
|
|
|
},
|
|
|
|
sync : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:false
|
|
|
|
},
|
|
|
|
silent : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:false
|
|
|
|
},
|
2016-03-23 18:07:37 +11:00
|
|
|
logDepth:{
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:5
|
|
|
|
},
|
|
|
|
logInColor:{
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:true
|
|
|
|
},
|
2016-01-11 15:59:40 +11:00
|
|
|
maxConnections : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:100
|
|
|
|
},
|
|
|
|
retry : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:500
|
|
|
|
},
|
|
|
|
maxRetries : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:Infinity
|
|
|
|
},
|
|
|
|
stopRetrying : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:false
|
|
|
|
},
|
|
|
|
IPType : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
2016-08-03 05:04:28 +10:00
|
|
|
value: getIPType()
|
2016-01-11 15:59:40 +11:00
|
|
|
},
|
|
|
|
tls : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:false
|
2016-10-05 05:16:53 +11:00
|
|
|
},
|
|
|
|
noHandshake : {
|
|
|
|
enumerable:true,
|
|
|
|
writable:true,
|
|
|
|
value:false
|
2016-01-11 15:59:40 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2016-08-03 05:04:28 +10:00
|
|
|
|
|
|
|
this.networkHost = (this.IPType == 'IPv6') ? '::1' : '127.0.0.1';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* method to get ip type
|
|
|
|
*
|
|
|
|
* @method getIPType
|
|
|
|
* @return {string} ip type
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|
2016-08-03 05:04:28 +10:00
|
|
|
return IPType;
|
2016-01-11 15:59:40 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports=Defaults;
|