1.0.0 • Published 8 years ago

docean-dyn-dns v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

docean-dyn-dns

A dynamic DNS updater for DigitalOcean domains.

Intended to be used as a cronjob (Either via crontab or pm2 cron) to update the IP address of a particular DNS A record on DigitalOcean.

Description

This package exports a constructor module that is instantiated with a DigitalOcean API key. The resulting instance is an object with an update function.

The update function takes 3 parameters, domainName, recordName, and data.

domainName and recordName are required. They should be the values of the domain the record is located under and the A record name, respectively.

The data parameter is optional. If provided, it should be the value of the record in a string format. If data is not provided, the script will attempt to retrieve the external (public) IP address via the 'external-ip' package and use that for data.

The update function returns a Promise.

The update function will update an existing record if an A record with domainName/recordName match is found, otherwise it will create a new record.

Example

This example will set the A record for subdomain.mydomain.com to the detected external IP address.

var dynDns = require('docean-dyn-dns');
var updater = new dynDns('MY_DIGITAL_OCEAN_API_KEY');

updater.update('mydomain.com','subdomain')
.then(function(record){
  console.log('The result record is ' + record);
})
.catch(function(err){
  console.log('Some error has occurred ', err);
});