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-server

v1.0.1

Published

A Dynamic DNS API server and Nameserver and Web Interface

Downloads

20

Readme

| ddnsd | ddns-server | ddns-client |

ddns-server

A Dynamic DNS (DDNS / DynDNS) server written in node.js.

This server is capable of all of the following:

  • static dns
  • dynamic dns
  • device dns
  • multiple device dynamic dns

This module consists of 3 plugins:

  • ddns-rest (external https APIs, typically https port 443)
  • ddns-nameserver (nameserver implementation, typically udp/tcp ports 53)
  • ddns-webapp (web interface, typically https port 443)

Install

Commandline

See ddnsd and ddns

Casual

# Core Library
npm install --save ddns-server

# Default Plugins
npm install --save ddns-rest
npm install --save ddns-nameserver
npm install --save ddns-webapp

For Development

git clone [email protected]:Daplie/node-ddns.git
pushd node-ddns/

mkdir node_modules/
git clone [email protected]:Daplie/ddns-rest.git node_modules/ddns-rest
git clone [email protected]:Daplie/ddns-nameserver.git node_modules/ddns-nameserver
git clone [email protected]:Daplie/ddns-webapp.git node_modules/ddns-webapp

Usage

Here's how to create your own nameserver and ddns api using only the default plugins.

'use strict';

require('ddns-server').create({
  dnsPort: 53
, httpPort: 80
, filepath: path.join(require('os').homedir(), '.ddnsd.sqlite3')
, primaryNameserver: 'ns1.example.com'
, nameservers: [
    { name: 'ns1.example.com', ipv4: '192.168.1.101' }
  , { name: 'ns2.example.com', ipv4: '192.168.1.102' }
  ]
}).listen();

Walkthrough

You can follow this example verbatim and get working results.

There are three steps:

  1. Create a token for a domain and a device
  2. Set a device record
  3. Update the device's ip

Create a Token

The device represents a physical device, like a server, Digital Ocean droplet, VPS, your laptop, or a Raspberry Pi

The domain is a domain the device is allowed to modify.

# node bin/ddns-jwtgen.js <<private key>> <<domain>> <<device name>>
node bin/ddns-jwtgen.js ./privkey.pem example.com digital-ocean-server-1 > srv1-example-com.jwt

Example: A record

curl 'http://localhost:80/api/com.daplie.ddns/dns' \
  -X POST \
  -H "Authorization: Bearer $(cat srv1-example-com.jwt)" \
  -H "Content-Type: application/json; charset=UTF-8" \
  -d '[
    { "registered": true
    , "groupIdx": 1
    , "type": "A"
    , "name": "example.com"
    , "device": "digital-ocean-server-1"
    , "value": "127.0.0.1"
    , "ttl": 600
    , "token": "$(cat srv1-example-com.jwt)"
    }
  ]'

And test

dig @127.0.0.1 example.com

Note: Yes, token is used twice, but that's just a workaround for a current problem.

Note: value will default to the IP address of the connecting client

Note: You can add multiple records for the same DNS host with various devices. This means that some clients will pick any available record at random or will access each device round-robin style.

Update a device IP

All A (and AAAA, if specified) records associated with the device digital-ocean-server-1 will be updated with the supplied IP addresses:

curl 'http://localhost:80/api/com.daplie.ddns/devices' \
  -X POST \
  -H "Authorization: Bearer $(cat srv1-example-com.jwt)" \
  -H "Content-Type: application/json; charset=UTF-8" \
  -d '{
        "name": "digital-ocean-server-1"
      , "addresses": [ { "type": "A", "value": "127.0.0.1" } ]
      }'

Note: groupIdx must exist and token and be the same as set in the dns record

Example: other records

curl 'http://localhost:80/api/com.daplie.ddns/dns' \
  -X POST \
  -H "Authorization: Bearer $(cat srv1-example-com.jwt)" \
  -d '[
    { "registered": true
    , "groupIdx": 1
    , "type": "CNAME"
    , "name": "www.example.com"
    , "value": "example.com"
    , "ttl": 600
    , "token": "'$(cat srv1-example-com.jwt)'"
    }
  ]'

Note: Yes, token is used twice, but that's just a workaround to another bug.

Note: MX records have the additional option priority.

License

MIT + Apache2