forked from cracker0dks/Accelerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigLoader.js
More file actions
67 lines (62 loc) · 2.28 KB
/
configLoader.js
File metadata and controls
67 lines (62 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var fs = require('fs');
var defaultConfig = {
"http": { "port": 8080 },
"mcuConfig": {
webRtcConfig: { //This is the configs for the peer connections
iceServers: [
{
urls: "stun:stun.l.google.com:19302",
},
// {
// urls: "stun:yourStunServerIP?transport=udp",
// username: "username",
// credential: "123456"
// },
// {
// urls: "turn:YourTurnServerIp?transport=tcp",
// username: "username",
// credential: "123456"
// },
]
},
loadBalancerAuthKey: (Math.random() + "").replace(".", ""), //Key for the loadbalancers to auth on the master (Must be the same on Master and loadbalancer)
isMaster : true, //Set to false if this is a loadbalancer instance
masterURL : 'https://yourAcceleratorURL.tl', //the web URL of your main instance (only used on loadbalancers)
enableLocalMCU : true //Set to false if this is master and this server should not handle any streams -> be sure you set up a loadbalancer in that case
},
"accConfig": {
"etherpadUrl": "", //Set to an url to enable etherpad (https://yourURL.tl/etherpad/p/)
"deleteUnusedRoomsAfterDays": 0, //0 is no deletion at all
"screenshareConfig" : {
"maxFPS" : 30,
"maxResolution" : "1080p" //1080p, 720p, 480p, 360p
},
"webcamConfig" : {
"maxFPS" : 30,
"maxResolution" : "1080p" //1080p, 720p, 480p, 360p
}
}
}
module.exports = {
getConfigs: function () {
if (!fs.existsSync("./config")) {
fs.mkdirSync("./config");
}
var returnConfig = JSON.parse(JSON.stringify(defaultConfig)); //Copy default config
if (fs.existsSync('./config/config.json')) {
var conf = fs.readFileSync('./config/config.json', 'utf8');
var newConfig = JSON.parse(conf);
for (var i in newConfig) {
for (var k in newConfig[i]) {
returnConfig[i][k] = newConfig[i][k];
}
}
}
setTimeout(function () {
fs.writeFile("./config/config.json", JSON.stringify(returnConfig, null, 4), function (err) { if(err) console.log(err) });
//Write default config files
fs.writeFile("./config/defaultConfig.json", JSON.stringify(defaultConfig, null, 4), function (err) { if(err) console.log(err) });
}, 500)
return JSON.parse(JSON.stringify(returnConfig)); //Return a copy from the org config
}
}