How to use dns-zonefile - 2 common examples

To help you get started, we’ve selected a few dns-zonefile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / google-cloud-node / packages / dns / src / zone.js View on Github external
fs.readFile(localPath, 'utf-8', function(err, file) {
    if (err) {
      callback(err);
      return;
    }

    var parsedZonefile = zonefile.parse(file);
    var recordTypes = Object.keys(parsedZonefile);
    var recordsToCreate = [];

    recordTypes.forEach(function(recordType) {
      var recordTypeSet = arrify(parsedZonefile[recordType]);

      recordTypeSet.forEach(function(record) {
        recordsToCreate.push(Record.fromZoneRecord_(self, recordType, record));
      });
    });

    self.addRecords(recordsToCreate, callback);
  });
};
github googleapis / nodejs-dns / src / zone.ts View on Github external
fs.readFile(localPath, 'utf-8', (err, file) => {
    if (err) {
      callback(err);
      return;
    }
    const parsedZonefile = zonefile.parse(file);
    const defaultTTL = parsedZonefile.$ttl;
    delete parsedZonefile.$ttl;
    const recordTypes = Object.keys(parsedZonefile);
    const recordsToCreate: Array<{}> = [];
    recordTypes.forEach(recordType => {
      const recordTypeSet = arrify(parsedZonefile[recordType]);
      recordTypeSet.forEach(record => {
        record.ttl = record.ttl || defaultTTL;
        recordsToCreate.push(Record.fromZoneRecord_(this, recordType, record));
      });
    });
    this.addRecords(recordsToCreate, callback);
    });
  }

dns-zonefile

A DNS zone file parser and generator.

ISC
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular dns-zonefile functions