homegames-common 0.3.1 → 0.9.9
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 +30 -2
- 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
|
+
"HTTPS_ENABLED": true,
|
|
21
|
+
"HOMENAMES_PORT": 7400,
|
|
22
|
+
"HOME_PORT": 9801,
|
|
23
|
+
"LOG_LEVEL": "INFO",
|
|
24
|
+
"GAME_SERVER_PORT_RANGE_MIN": 8300,
|
|
25
|
+
"GAME_SERVER_PORT_RANGE_MAX": 8400,
|
|
26
|
+
"IS_DEMO": false,
|
|
27
|
+
"BEZEL_SIZE_Y": 15,
|
|
28
|
+
"BEZEL_SIZE_X": 15,
|
|
29
|
+
"PUBLIC_GAMES": true,
|
|
30
|
+
"DOWNLOADED_GAME_DIRECTORY": "hg-games",
|
|
31
|
+
"LOG_PATH": "hg_log.txt"
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
const getLocalIP = () => {
|
|
19
35
|
const ifaces = os.networkInterfaces();
|
|
20
36
|
let localIP;
|
|
@@ -430,7 +446,7 @@ const guaranteeCerts = (authPath, certPath) => new Promise((resolve, reject) =>
|
|
|
430
446
|
const linkInit = (authPath) => new Promise((resolve, reject) => {
|
|
431
447
|
|
|
432
448
|
getLoginInfo(authPath).then((loginInfo) => {
|
|
433
|
-
const client = new WebSocket('wss://
|
|
449
|
+
const client = new WebSocket('wss://homegames.link:7080');
|
|
434
450
|
|
|
435
451
|
client.on('open', () => {
|
|
436
452
|
console.log('opened connection to link');
|
|
@@ -440,6 +456,11 @@ const linkInit = (authPath) => new Promise((resolve, reject) => {
|
|
|
440
456
|
accessToken: loginInfo.tokens.accessToken
|
|
441
457
|
}));
|
|
442
458
|
});
|
|
459
|
+
|
|
460
|
+
client.on('error', (err) => {
|
|
461
|
+
console.log('some error happened');
|
|
462
|
+
console.log(err);
|
|
463
|
+
});
|
|
443
464
|
});
|
|
444
465
|
|
|
445
466
|
});
|
|
@@ -609,7 +630,7 @@ const getConfig = () => {
|
|
|
609
630
|
}
|
|
610
631
|
|
|
611
632
|
const options = [process.cwd(), require.main.filename, process.mainModule.filename, __dirname]
|
|
612
|
-
let _config =
|
|
633
|
+
let _config = null;
|
|
613
634
|
|
|
614
635
|
for (let i = 0; i < options.length; i++) {
|
|
615
636
|
if (fs.existsSync(`${options[i]}/config.json`)) {
|
|
@@ -619,6 +640,13 @@ const getConfig = () => {
|
|
|
619
640
|
}
|
|
620
641
|
}
|
|
621
642
|
|
|
643
|
+
if (!_config) {
|
|
644
|
+
_config = DEFAULT_CONFIG;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
console.log('Using config: ');
|
|
648
|
+
console.log(_config);
|
|
649
|
+
|
|
622
650
|
cachedConfig = _config;
|
|
623
651
|
|
|
624
652
|
return _config;
|