npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ddns-updater

v1.2.1

Published

Pluggable Dynamic DNS updater

Downloads

9

Readme

ddns-updater

Library for updating dynamic DNS.

NPM

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 = require("ddns-updater");
var config = require('./config.json');
var updater = new UpdaterClient(config);
updater.start();

where config.json:

{
    "domains" : [{
        "service"   : "namecheap",
        "name"      : "chebyrashka.guru",
        "hosts"     : ["@"],
        "settings"  : {
            "password": "1a111v11111111a1aaa11a11111111a1"
        }
    }],
    "interval"      : { "hours": 1 },
    "updateAlways"  : false
}

It makes sense to run the package via pm2 or the similar.

More advanced usage

var UpdaterClient = require("ddns-updater");
var config = { /* skipped*/ };
var updater = new UpdaterClient(config);

updater.on('ip:resolve:success', function (service, ip) {
    console.log('External IP resolved via ' + service + ' : ' + ip);
});

updater.on('ip:resolve:error', function (service, err) {
    .log('Failed to resolve external IP: ');
    console.log(err);
});

updater.on('ip:change', function (newIP, oldIP) {
    console.log("IP changed from " + oldIP + " to " + newIP);
});

updater.on('update:success', function (domain) {
    console.log("updated: " + JSON.stringify(domain));
});

updater.on('update:error', function (err, domain) {
    console.log('Failed to update IP via ' + domain.service + ':');
    console.log(err);
});

updater.start();

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 to false allow to ignore domain updating (useful to temporary disable)

Example:

    "domains" : [{
        "service"  : "namecheap",
        "name"     : "chebyrashka.guru",
        "hosts"    : ["@", "www"],
        "settings" : {
            "password": "1a111v11111111a1aaa11a11111111a1"
        },
        "enable"   :  false
    }, {
        "service"  : "noip",
        "name"     : "my-awesome-cloud.ddns.net",
        "settings" : {
            "username": "[email protected]",
            "password": "my no-ip password"
        }
    }],

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": {"days": 1}

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 resolving
  • ip (String) - IP address

"ip:resolve:error"

An error occurred during IP resolving.
Arguments:

  • service (String) - service name used for resolving
  • err (Object) - error

"ip:change"

External IP change was detected.
Arguments:

  • newIP (String) - new IP
  • oldIP (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 {String} domain
 * @param {String} host
 * @param {String} ip
 * @param {Object} settings
 * @return {Promise}
 */
function update (domain, host, ip, settings)

By default tool loads updaters from updaters folder. By you can specify them explicitly with updaters option:

var UpdaterClient = require("ddns-updater");
var SomeUpdater = require("ddns-updater-someservice");
var config = require('./config.json');
config.updaters = {"some": SomeUpdater};
var updater = new UpdaterClient(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