Commit b87f93bfe32ac1c9ec4ed60b125eaf8fc8a0e758
1 parent
1a1256bec4
Exists in
master
Optimalisasi config
Showing 1 changed file with 2 additions and 1 deletions Inline Diff
index.js
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | 3 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; |
4 | 4 | ||
5 | const fs = require('fs'); | 5 | const fs = require('fs'); |
6 | const isIp = require('is-ip'); | 6 | const isIp = require('is-ip'); |
7 | const config = require(__dirname + '/config.json'); | 7 | // const config = require(__dirname + '/config.json'); |
8 | const config = require('./config'); | ||
8 | 9 | ||
9 | fs.existsSync('certs') || fs.mkdirSync('certs'); | 10 | fs.existsSync('certs') || fs.mkdirSync('certs'); |
10 | 11 | ||
11 | const redbird = require('redbird')(config.server_options); | 12 | const redbird = require('redbird')(config.server_options); |
12 | 13 | ||
13 | const hostsCount = config.hosts.length; | 14 | const hostsCount = config.hosts.length; |
14 | for (let i=0; i < hostsCount; i++) { | 15 | for (let i=0; i < hostsCount; i++) { |
15 | let host = config.hosts[i] | 16 | let host = config.hosts[i] |
16 | console.log(`Registering ${host.host} to ${host.target}`); | 17 | console.log(`Registering ${host.host} to ${host.target}`); |
17 | if (!host.disable) { | 18 | if (!host.disable) { |
18 | const options = host.options || config.default_host_options; | 19 | const options = host.options || config.default_host_options; |
19 | const optionsWoSSL = JSON.parse(JSON.stringify(options)); | 20 | const optionsWoSSL = JSON.parse(JSON.stringify(options)); |
20 | delete optionsWoSSL.ssl; | 21 | delete optionsWoSSL.ssl; |
21 | 22 | ||
22 | if (!options) { | 23 | if (!options) { |
23 | redbird.register(host.host, host.target); | 24 | redbird.register(host.host, host.target); |
24 | } | 25 | } |
25 | else { | 26 | else { |
26 | 27 | ||
27 | if (host.no_ssl || isIp(host.host.split('/')[0])) { | 28 | if (host.no_ssl || isIp(host.host.split('/')[0])) { |
28 | console.log('Register ' + host.host + ' without SSL') | 29 | console.log('Register ' + host.host + ' without SSL') |
29 | redbird.register(host.host, host.target, optionsWoSSL); | 30 | redbird.register(host.host, host.target, optionsWoSSL); |
30 | } | 31 | } |
31 | else { | 32 | else { |
32 | console.log('Register ' + host.host + ' with SSL if exists'); | 33 | console.log('Register ' + host.host + ' with SSL if exists'); |
33 | redbird.register(host.host, host.target, options); | 34 | redbird.register(host.host, host.target, options); |
34 | } | 35 | } |
35 | 36 | ||
36 | } | 37 | } |
37 | 38 | ||
38 | } | 39 | } |
39 | } | 40 | } |
40 | 41 |