homegames-common 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,6 +15,22 @@ const getUserHash = (username) => {
|
|
|
15
15
|
return crypto.createHash('md5').update(username).digest('hex');
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
const DEFAULT_CONFIG = {
|
|
19
|
+
"LINK_ENABLED": true,
|
|
20
|
+
"HOMENAMES_PORT": 7400,
|
|
21
|
+
"HOME_PORT": 9801,
|
|
22
|
+
"LOG_LEVEL": "INFO",
|
|
23
|
+
"GAME_SERVER_PORT_RANGE_MIN": 8300,
|
|
24
|
+
"GAME_SERVER_PORT_RANGE_MAX": 8400,
|
|
25
|
+
"IS_DEMO": false,
|
|
26
|
+
"BEZEL_SIZE_Y": 15,
|
|
27
|
+
"BEZEL_SIZE_X": 15,
|
|
28
|
+
"DOWNLOADED_GAME_DIRECTORY": "hg-games",
|
|
29
|
+
"LOG_PATH": "hg_log.txt",
|
|
30
|
+
"LOCAL_GAME_DIRECTORY": "local-games",
|
|
31
|
+
"PUBLIC_GAMES": false
|
|
32
|
+
};
|
|
33
|
+
|
|
18
34
|
const getLocalIP = () => {
|
|
19
35
|
const ifaces = os.networkInterfaces();
|
|
20
36
|
let localIP;
|
|
@@ -609,7 +625,7 @@ const getConfig = () => {
|
|
|
609
625
|
}
|
|
610
626
|
|
|
611
627
|
const options = [process.cwd(), require.main.filename, process.mainModule.filename, __dirname]
|
|
612
|
-
let _config =
|
|
628
|
+
let _config = null;
|
|
613
629
|
|
|
614
630
|
for (let i = 0; i < options.length; i++) {
|
|
615
631
|
if (fs.existsSync(`${options[i]}/config.json`)) {
|
|
@@ -619,6 +635,13 @@ const getConfig = () => {
|
|
|
619
635
|
}
|
|
620
636
|
}
|
|
621
637
|
|
|
638
|
+
if (!_config) {
|
|
639
|
+
_config = DEFAULT_CONFIG;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
console.log('Using config: ');
|
|
643
|
+
console.log(_config);
|
|
644
|
+
|
|
622
645
|
cachedConfig = _config;
|
|
623
646
|
|
|
624
647
|
return _config;
|