Commit 1a1256bec41432b9cc60731f9414d63e48b18d28

Authored by Adhidarma Hadiwinoto
1 parent 67c0d11178
Exists in master

config host no_ssl

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

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 8
9 fs.existsSync('certs') || fs.mkdirSync('certs'); 9 fs.existsSync('certs') || fs.mkdirSync('certs');
10 10
11 const redbird = require('redbird')(config.server_options); 11 const redbird = require('redbird')(config.server_options);
12 12
13 const hostsCount = config.hosts.length; 13 const hostsCount = config.hosts.length;
14 for (let i=0; i < hostsCount; i++) { 14 for (let i=0; i < hostsCount; i++) {
15 let host = config.hosts[i] 15 let host = config.hosts[i]
16 console.log(`Registering ${host.host} to ${host.target}`); 16 console.log(`Registering ${host.host} to ${host.target}`);
17 if (!host.disable) { 17 if (!host.disable) {
18 const options = host.options || config.default_host_options; 18 const options = host.options || config.default_host_options;
19 const optionsWoSSL = JSON.parse(JSON.stringify(options)); 19 const optionsWoSSL = JSON.parse(JSON.stringify(options));
20 delete optionsWoSSL.ssl; 20 delete optionsWoSSL.ssl;
21 21
22 if (!options) { 22 if (!options) {
23 redbird.register(host.host, host.target); 23 redbird.register(host.host, host.target);
24 } 24 }
25 else { 25 else {
26 26
27 if (isIp(host.host.split('/')[0])) { 27 if (host.no_ssl || isIp(host.host.split('/')[0])) {
28 console.log('Register ' + host.host + ' without SSL') 28 console.log('Register ' + host.host + ' without SSL')
29 redbird.register(host.host, host.target, optionsWoSSL); 29 redbird.register(host.host, host.target, optionsWoSSL);
30 } 30 }
31 else { 31 else {
32 console.log('Register ' + host.host + ' with SSL if exists'); 32 console.log('Register ' + host.host + ' with SSL if exists');
33 redbird.register(host.host, host.target, options); 33 redbird.register(host.host, host.target, options);
34 } 34 }
35 35
36 } 36 }
37 37
38 } 38 }
39 } 39 }
40 40