Commit 2675aeff authored by nanahira's avatar nanahira

add maintaince

parent 479d0773
Pipeline #16855 passed with stages
in 2 minutes and 16 seconds
...@@ -30,6 +30,7 @@ interface Config { ...@@ -30,6 +30,7 @@ interface Config {
retryCount: number; retryCount: number;
interval: number; interval: number;
cocurrent: number; cocurrent: number;
maintainance?: string[];
} }
interface DomainRecordObject { interface DomainRecordObject {
...@@ -350,6 +351,9 @@ class Checker { ...@@ -350,6 +351,9 @@ class Checker {
return ConnectResult.CDNBad; return ConnectResult.CDNBad;
} }
} }
maintainance: Set<string>;
constructor(private config: Config) { constructor(private config: Config) {
this.queue = new PQueue({ concurrency: this.config.cocurrent || 10 }); this.queue = new PQueue({ concurrency: this.config.cocurrent || 10 });
this.client = new Aliyun(config.aliyun); this.client = new Aliyun(config.aliyun);
...@@ -367,6 +371,7 @@ class Checker { ...@@ -367,6 +371,7 @@ class Checker {
this.checkMethods.set('icmp', (record: Source, address: string) => { this.checkMethods.set('icmp', (record: Source, address: string) => {
return this.checkIcmp(record, address); return this.checkIcmp(record, address);
}); });
this.maintainance = new Set(config.maintainance || []);
} }
private message(msg: string) { private message(msg: string) {
console.log(`${this.id} => ${msg}`); console.log(`${this.id} => ${msg}`);
...@@ -442,6 +447,15 @@ class Checker { ...@@ -442,6 +447,15 @@ class Checker {
} }
async checkSource(source: Source, address: string): Promise<ConnectResult> { async checkSource(source: Source, address: string): Promise<ConnectResult> {
if (this.maintainance.has(address)) {
this.message(
`Skip ${this.getSourcePattern(
source,
address,
)} because it is in maintainance.`,
);
return ConnectResult.CDNBad;
}
const checkMethodFunction = this.checkMethods.get(source.protocol); const checkMethodFunction = this.checkMethods.get(source.protocol);
assert( assert(
checkMethodFunction, checkMethodFunction,
......
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