1
0
Fork 0

no idea whats happening but i object

refactor/models
Matthew 2020-03-28 04:57:40 -04:00
parent c77c2f5702
commit 2af97851e1
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 7 additions and 2 deletions

View File

@ -34,7 +34,7 @@ export default class CWG_Create extends Command {
let certs: { cert: string, key: string }; let certs: { cert: string, key: string };
if (!this.urlRegex.test(args[1])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid URL***`); if (!this.urlRegex.test(args[1])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid URL***`);
if (Number(args[2]) < 1024 || Number(args[2]) > 65535) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Port must be greater than 1024 and less than 65535***`); if (Number(args[2]) <= 1024 || Number(args[2]) >= 65535) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Port must be greater than 1024 and less than 65535***`);
if (!args[1].endsWith('.cloud.libraryofcode.org') && !args[4]) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Certificate Chain and Private Key are required for custom domains***`); if (!args[1].endsWith('.cloud.libraryofcode.org') && !args[4]) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Certificate Chain and Private Key are required for custom domains***`);
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }] }); const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }] });
@ -74,7 +74,7 @@ export default class CWG_Create extends Command {
const domain = await this.createDomain(account, args[1], Number(args[2]), certs); const domain = await this.createDomain(account, args[1], Number(args[2]), certs);
const tasks = [message.delete(), this.client.util.exec('systemctl reload')]; const tasks = [message.delete(), this.client.util.exec('systemctl reload nginx')];
// @ts-ignore // @ts-ignore
await Promise.all(tasks); await Promise.all(tasks);
@ -149,6 +149,11 @@ export default class CWG_Create extends Command {
let x509: { cert: string, key: string }; let x509: { cert: string, key: string };
if (x509Certificate) { if (x509Certificate) {
x509 = await this.createCertAndPrivateKey(domain, x509Certificate.cert, x509Certificate.key); x509 = await this.createCertAndPrivateKey(domain, x509Certificate.cert, x509Certificate.key);
} else {
x509 = {
cert: '/etc/ssl/private/cloud-libraryofcode-org.chain.crt',
key: '/etc/ssl/private/cloud-libraryofcode-org.key',
};
} }
let cfg = await fs.readFile('/opt/CloudServices/dist/static/nginx.conf', { encoding: 'utf8' }); let cfg = await fs.readFile('/opt/CloudServices/dist/static/nginx.conf', { encoding: 'utf8' });
cfg = cfg.replace(/\[DOMAIN]/g, domain); cfg = cfg.replace(/\[DOMAIN]/g, domain);