1
0
Fork 0

Added system process check

refactor/models
Bsian 2020-01-05 13:27:12 +00:00
parent 56c94a5e33
commit 26e31dece0
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 11 additions and 2 deletions

View File

@ -3,7 +3,6 @@ import moment from 'moment';
import x509 from '@ghaiklor/x509'; import x509 from '@ghaiklor/x509';
import { createPaginationEmbed } from 'eris-pagination'; import { createPaginationEmbed } from 'eris-pagination';
import { Message } from 'eris'; import { Message } from 'eris';
import { promisify } from 'util';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';
import { Client } from '..'; import { Client } from '..';
@ -21,7 +20,17 @@ export default class CWG_Data extends Command {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, ['cwg', this.name]); if (!args[0]) return this.client.commands.get('help').run(message, ['cwg', this.name]);
const dom = await this.client.db.Domain.find({ $or: [{ domain: args[0] }, { port: Number(args[0]) || '' }] }); const dom = await this.client.db.Domain.find({ $or: [{ domain: args[0] }, { port: Number(args[0]) || '' }] });
if (!dom.length) return message.channel.createMessage(`***${this.client.stores.emojis.error} The domain or port you provided could not be found.***`); if (!dom.length) {
if (!Number.isNaN(Number(args[0]))) {
try {
await this.client.util.exec(`fuser ${args[0]}/tcp`);
return message.channel.createMessage(`***${this.client.stores.emojis.error} The port you provided is being used by a system process.***`);
} catch (error) {
return message.channel.createMessage(`***${this.client.stores.emojis.error} The domain or port you provided could not be found.***`);
}
}
return message.channel.createMessage(`***${this.client.stores.emojis.error} The domain or port you provided could not be found.***`);
}
const embeds = dom.map((domain) => { const embeds = dom.map((domain) => {
const cert = fs.readFileSync(domain.x509.cert, { encoding: 'utf8' }); const cert = fs.readFileSync(domain.x509.cert, { encoding: 'utf8' });
const embed = new RichEmbed(); const embed = new RichEmbed();