Use golang parseCertificate
parent
d5be7f6e0f
commit
7b3963dc54
|
@ -4,6 +4,7 @@ import { readdirSync } from 'fs';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Client } from '..';
|
import { Client } from '..';
|
||||||
import { Command, RichEmbed } from '../class';
|
import { Command, RichEmbed } from '../class';
|
||||||
|
import { parseCertificate } from '../functions';
|
||||||
|
|
||||||
export default class Parseall extends Command {
|
export default class Parseall extends Command {
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
|
@ -30,7 +31,7 @@ export default class Parseall extends Command {
|
||||||
accounts.forEach(async (a) => {
|
accounts.forEach(async (a) => {
|
||||||
try {
|
try {
|
||||||
const certFile = readdirSync(`${a.homepath}/Validation`)[0];
|
const certFile = readdirSync(`${a.homepath}/Validation`)[0];
|
||||||
const { notAfter } = parseCert(`${a.homepath}/Validation/${certFile}`);
|
const { notAfter } = await parseCertificate(this.client, `${a.homepath}/Validation/${certFile}`);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true);
|
const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true);
|
||||||
const precise: [number, string][] = [];
|
const precise: [number, string][] = [];
|
||||||
|
@ -43,8 +44,8 @@ export default class Parseall extends Command {
|
||||||
});
|
});
|
||||||
const time = precise.filter((n) => n[0]).map(((v) => v.join(''))).join(', ');
|
const time = precise.filter((n) => n[0]).map(((v) => v.join(''))).join(', ');
|
||||||
|
|
||||||
if (notAfter < new Date()) final.push(`${this.client.stores.emojis.error} **${a.username}** Certificate expired ${time} ago`);
|
if (notAfter < new Date()) final.push(`${this.client.stores.emojis.error} **${a.username}** Expired ${time} ago`);
|
||||||
else final.push(`${this.client.stores.emojis.success} **${a.username}** Certificate expires in ${time}`);
|
else final.push(`${this.client.stores.emojis.success} **${a.username}** Expires in ${time}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) final.push(`${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`);
|
if (error.message.includes('no such file or directory') || error.message.includes('File doesn\'t exist.')) final.push(`${this.client.stores.emojis.error} **${a.username}** Unable to locate certificate`);
|
||||||
else throw error;
|
else throw error;
|
||||||
|
|
Loading…
Reference in New Issue