ts-zone-file
Version:
This module is designed for manaing a BIND name server.
28 lines (27 loc) • 1.16 kB
TypeScript
import { ZONE, VRECORD, SRVRECORD, MXRECORD, CAARecord } from './types';
/**
* Takes BIND9 Zonefile as string, parses it and returns an object of the values within the zone
* @param zone Valid BIND9 Zonefile as a string
* @example
* ```typescript
* import { parseZoneFile } from 'ts-zone-file';
* import { readFile } from 'fs-extra';
* const file = await readFile('/zones/example.com');
* const zone = await parseZoneFile(file.toString());
* if (zone.a) zone.a.map((RR) => console.log(RR.host, RR.ttl, RR.value));
* ```
*/
export declare const parseZoneFile: (zone: string) => Promise<ZONE>;
/**
* Extracts TTL, host, and value from a zonefile line
* @param line line of Zonefile
* @exmaple
* ```typescript
* const line = 'example.com. 300 IN NS ns1.exmaple.xyz.'
* const { ttl, host, value } = await ProcessValueRecord(value)
* ```
*/
export declare const ProcessValueRecord: (line: string) => Promise<VRECORD>;
export declare const ProcessSRV: (line: string) => Promise<SRVRECORD>;
export declare const ProcessPref: (line: string) => Promise<MXRECORD>;
export declare const ProcessCAA: (line: string) => Promise<CAARecord>;