fix(app.ts): Preparing to use 4 or more SSL certificates.
This commit is contained in:
parent
a969abbcc4
commit
72b645fd2a
19 changed files with 142 additions and 98 deletions
|
@ -60,7 +60,7 @@ import QrScanner from 'qr-scanner';
|
||||||
import pkg from 'whatsapp-web.js';
|
import pkg from 'whatsapp-web.js';
|
||||||
import { ActivityTypes } from 'botbuilder';
|
import { ActivityTypes } from 'botbuilder';
|
||||||
const { List, Buttons } = pkg;
|
const { List, Buttons } = pkg;
|
||||||
import mime from 'mime';
|
import mime from 'mime-types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default check interval for user replay
|
* Default check interval for user replay
|
||||||
|
|
|
@ -254,8 +254,7 @@ export class SecService extends GBService {
|
||||||
if (user['dataValues'] && !value) {
|
if (user['dataValues'] && !value) {
|
||||||
value = user['dataValues'][name];
|
value = user['dataValues'][name];
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
switch(name)
|
switch (name) {
|
||||||
{
|
|
||||||
case 'language':
|
case 'language':
|
||||||
value = 'en';
|
value = 'en';
|
||||||
break;
|
break;
|
||||||
|
@ -275,8 +274,7 @@ export class SecService extends GBService {
|
||||||
let user = await GuaribasUser.findOne(options);
|
let user = await GuaribasUser.findOne(options);
|
||||||
// tslint:disable-next-line:prefer-object-spread
|
// tslint:disable-next-line:prefer-object-spread
|
||||||
let obj = JSON.parse(user.params);
|
let obj = JSON.parse(user.params);
|
||||||
if (!obj)
|
if (!obj) {
|
||||||
{
|
|
||||||
obj = {};
|
obj = {};
|
||||||
}
|
}
|
||||||
obj[name] = value;
|
obj[name] = value;
|
||||||
|
|
|
@ -195,8 +195,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
if (setUrl) {
|
if (setUrl) {
|
||||||
createClient.bind(this)();
|
createClient.bind(this)();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
this.customClient = minBoot.whatsAppDirectLine.customClient;
|
this.customClient = minBoot.whatsAppDirectLine.customClient;
|
||||||
}
|
}
|
||||||
setUrl = false;
|
setUrl = false;
|
||||||
|
|
53
src/app.ts
53
src/app.ts
|
@ -282,6 +282,38 @@ export class GBServer {
|
||||||
};
|
};
|
||||||
const httpsServer = https.createServer(options1, server).listen(port, mainCallback);
|
const httpsServer = https.createServer(options1, server).listen(port, mainCallback);
|
||||||
GBServer.globals.httpsServer = httpsServer;
|
GBServer.globals.httpsServer = httpsServer;
|
||||||
|
|
||||||
|
for (let i = 2; ; i++) {
|
||||||
|
const certPfxEnv = `CERTIFICATE${i}_PFX`;
|
||||||
|
const certPassphraseEnv = `CERTIFICATE${i}_PASSPHRASE`;
|
||||||
|
const certDomainEnv = `CERTIFICATE${i}_DOMAIN`;
|
||||||
|
|
||||||
|
if (process.env[certPfxEnv] && process.env[certPassphraseEnv] && process.env[certDomainEnv]) {
|
||||||
|
const options = {
|
||||||
|
passphrase: process.env[certPassphraseEnv],
|
||||||
|
pfx: Fs.readFileSync(process.env[certPfxEnv])
|
||||||
|
};
|
||||||
|
httpsServer.addContext(process.env[certDomainEnv], options);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
server.listen(port, mainCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
--------------------------------------------------------------------------------------------
|
||||||
|
if (process.env.CERTIFICATE_PFX) {
|
||||||
|
const options1 = {
|
||||||
|
passphrase: process.env.CERTIFICATE_PASSPHRASE,
|
||||||
|
pfx: Fs.readFileSync(process.env.CERTIFICATE_PFX)
|
||||||
|
};
|
||||||
|
const httpsServer = https.createServer(options1, server).listen(port, mainCallback);
|
||||||
|
GBServer.globals.httpsServer = httpsServer;
|
||||||
|
|
||||||
if (process.env.CERTIFICATE2_PFX) {
|
if (process.env.CERTIFICATE2_PFX) {
|
||||||
const options2 = {
|
const options2 = {
|
||||||
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
|
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
|
||||||
|
@ -289,8 +321,23 @@ export class GBServer {
|
||||||
};
|
};
|
||||||
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options2);
|
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options2);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
server.listen(port, mainCallback);
|
if (process.env.CERTIFICATE3_PFX) {
|
||||||
}
|
const options3 = {
|
||||||
|
passphrase: process.env.CERTIFICATE3_PASSPHRASE,
|
||||||
|
pfx: Fs.readFileSync(process.env.CERTIFICATE3_PFX)
|
||||||
|
};
|
||||||
|
httpsServer.addContext(process.env.CERTIFICATE3_DOMAIN, options3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.CERTIFICATE4_PFX) {
|
||||||
|
const options4 = {
|
||||||
|
passphrase: process.env.CERTIFICATE4_PASSPHRASE,
|
||||||
|
pfx: Fs.readFileSync(process.env.CERTIFICATE4_PFX)
|
||||||
|
};
|
||||||
|
httpsServer.addContext(process.env.CERTIFICATE4_DOMAIN, options4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue