Commit 75eee2c2 authored by nanahira's avatar nanahira

enable cdn recursive

parent d4254bb4
Pipeline #783 passed with stages
in 13 minutes and 46 seconds
......@@ -66,6 +66,9 @@ class Checker {
cdnRecordsRegex: RegExp[];
static order: number = 0;
id: number;
records: DomainRecordInfo[];
nonCDNRecords: DomainRecordInfo[];
CDNRecords: DomainRecordInfo[];
constructor(config: Config) {
this.config = config;
this.client = new Aliyun(config.aliyun);
......@@ -143,13 +146,19 @@ class Checker {
const good = await this.checkNode(record.Value, recordInfo.port);
await this.handleRecordResult(recordInfo, good);
}
async checkCDNRecord(recordInfo: DomainRecordInfo, nonCDNRecords: DomainRecordInfo[]) {
const record = recordInfo.record;
this.message(`Checking CDN record ${this.getRecordPattern(recordInfo)} with old status of ${record.Status}.`)
const valuePrefix = this.getRecordPrefix(record);
const good = _.any(nonCDNRecords, r => {
return r.record.RR === valuePrefix && r.good;
});
isRecordGood(recordInfo: DomainRecordInfo): boolean {
if (recordInfo.isCDN) {
const valuePrefix = this.getRecordPrefix(recordInfo.record);
return _.any(this.records, r => {
return r.record.RR === valuePrefix && this.isRecordGood(r);
});
} else {
return recordInfo.good;
}
}
async checkCDNRecord(recordInfo: DomainRecordInfo) {
this.message(`Checking CDN record ${this.getRecordPattern(recordInfo)} with old status of ${recordInfo.record.Status}.`)
const good = this.isRecordGood(recordInfo);
this.message(`CDN Record ${this.getRecordPattern(recordInfo)} is ${good ? "good" : "bad"}.`);
await this.handleRecordResult(recordInfo, good);
}
......@@ -168,15 +177,15 @@ class Checker {
}
async start() {
this.message(`Started.`);
const records = await this.getRecords();
const nonCDNRecords = records.filter(m => !m.isCDN);
const CDNRecords = records.filter(m => !!m.isCDN);
await Promise.all(nonCDNRecords.map(r => {
this.records = await this.getRecords();
this.nonCDNRecords = this.records.filter(m => !m.isCDN);
this.CDNRecords = this.records.filter(m => !!m.isCDN);
await Promise.all(this.nonCDNRecords.map(r => {
return this.checkRecord(r);
}));
//await Promise.all(CDNRecords.map(r => {
// return this.checkCDNRecord(r, nonCDNRecords);
//}));
await Promise.all(this.CDNRecords.map(r => {
return this.checkCDNRecord(r);
}));
this.message(`Finished.`);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment