ddns-updater
Library for updating dynamic DNS.
The library supports the following Dynamic DNS services:
For external IP resolving it uses service:
- https://ipify.org
- STUN Google server
Introduction blog post with details on how the package can be used in QNAP NAS.
Usage
var UpdaterClient = ;var config = ;var updater = config;updaterstart;
where config.json
:
It makes sense to run the package via pm2 or the similar.
More advanced usage
var UpdaterClient = ;var config = /* skipped*/ ;var updater = config; updater; updater; updater; updater; updater; updaterstart;
API
Config
domains
Type: Array
An array of objects describing a domain.
Every object in the array:
service
- name of Dynamic DNS service. e.g. "namecheap". Every supported service should have a corresponding module in 'updaters' folder (module file name w/o extension equals to service name, e.g.namecheap.js
for "namecheap" service).name
- name of domain, e.g. "example.com"hosts
- array of host to map to the domain, if you only want naked domain ("example.com") specify "@" or omit field completely.settings
- an object specific for the service, usually containing auth info.enable
- setting tofalse
allow to ignore domain updating (useful to temporary disable)
Example:
"domains" : ,
interval
Type: Object
How often to check external IP (and update if it's changed).
Value: An object in terms of interval.
Default: 1 hour
Example:
"internal":
updateAlways
Type: Boolean
Default: false
true
to update IP every time (once in interval), otherwise update only if IP changed.
resolver
Type: String
Default: "ipify"
Name of public IP resolve service. Currently supported:
- "ipify" (default) - via https://ipify.org
- "stun" - via STUN (Google server will be used)
updaters
Type: Object
An object with mapping of service name to updater class.
See Updaters below.
Events
"ip:resolve:success"
External IP was resolved. Arguments:
service
(String) - service name used for resolvingip
(String) - IP address
"ip:resolve:error"
An error occurred during IP resolving.
Arguments:
service
(String) - service name used for resolvingerr
(Object) - error
"ip:change"
External IP change was detected.
Arguments:
newIP
(String) - new IPoldIP
(String) - old IP
"update:success"
IP update successully completed.
Arguments:
domain
(Object):service
(String)name
(String)host
(String)
"update:error"
An error occured during updating IP.
Arguments:
err
(Object)domain
(Object):service
(String)name
(String)host
(String)
Updaters
Every service from config (domains[].service
) is an Updater module.
The tool expects every updater to implement the following API:
- module exports a class (will be created via
new
) - updater class should implement
update
method:
/** * @param * @param * @param * @param * @return */
By default tool loads updaters from updaters
folder. By you can specify them explicitly with updaters
option:
var UpdaterClient = ;var SomeUpdater = ;var config = ;configupdaters = "some": SomeUpdater;var updater = config;
Resolvers
Resolver is a module loaded from resolvers
folder. Module should implement the following API:
- module exports a class (will be created via
new
) - resolver class implements
resolve
method returning a Promise resolved to IP value
Name of resolver to use is specified in resolver
config option.
Acknowledgments
The package was inspired by:
License
MIT