-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.ts
43 lines (37 loc) · 1.09 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import cloudflare from 'cloudflare';
import dSec from './dsec';
export function dnsToString(r: cloudflare.DnsRecord) {
const type = r.type;
switch (type) {
case 'SRV':
//TODO
return [r.type, r.data.name, r.data.service];
case 'MX':
case 'URI':
default:
return [r.type, r.name, r.content];
}
}
export function missingRecordsInDSec(records: cloudflare.DnsRecord[], descClient: dSec) {
const missingRecords: cloudflare.DnsRecord[] = [];
if (records != null) {
for (let cRecord of records) {
const exists = descClient.checkExits(cRecord);
if (!exists) {
console.error('missing record', ...dnsToString(cRecord));
missingRecords.push(cRecord);
} else {
// console.info('existing record', cRecord);
}
}
}
return missingRecords;
}
declare module 'cloudflare' {
interface DnsRecordWithPriority {
zone_name: string;
}
interface DnsRecordWithoutPriority {
zone_name: string;
}
}