From f6fb74f62525e55fee7395b0d71ef7309f212422 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 27 Oct 2017 23:45:52 -0600 Subject: [PATCH 01/22] update urls --- README.md | 10 ++++++---- package.json | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 80c4699..4b3bc11 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ digd.js ======= -| [dns-suite](https://git.daplie.com/Daplie/dns-suite) -| [dig.js](https://git.daplie.com/Daplie/dig.js) +| [dns-suite](https://git.coolaj86.com/coolaj86/dns-suite) +| [dig.js](https://git.coolaj86.com/coolaj86/dig.js) | **digd.js** +Sponsored by [Daplie](https://daplie.com). + A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command. @@ -16,12 +18,12 @@ Install ```bash # Install the latest of v1.x -npm install -g 'git+https://git@git.daplie.com/Daplie/digd.js.git#v1' +npm install -g 'git+https://git.coolaj86.com/coolaj86/digd.js.git#v1' ``` ```bash # Install exactly v1.0.0 -npm install -g 'git+https://git@git.daplie.com/Daplie/digd.js.git#v1.0.0' +npm install -g 'git+https://git.coolaj86.com/coolaj86/digd.js.git#v1.0.0' ``` ### without git diff --git a/package.json b/package.json index dc5afce..c9622a8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "repository": { "type": "git", - "url": "git@git.daplie.com:Daplie/digd.js.git" + "url": "https://git.coolaj86.com/coolaj86/digd.js.git" }, "keywords": [ "mdig", @@ -46,7 +46,7 @@ "author": "AJ ONeal (https://coolaj86.com)", "license": "MIT OR Apache-2.0", "dependencies": { - "dig.js": "git+https://git.daplie.com/Daplie/dig.js#v1.3", - "hexdump.js": "git+https://git.daplie.com/Daplie/hexdump.js#v1.0.4" + "dig.js": "git+https://git.coolaj86.com/coolaj86/dig.js#v1.3", + "hexdump.js": "git+https://git.coolaj86.com/coolaj86/hexdump.js#v1.0.4" } } From a8061dbc6c6aa1a32c676d5fcc2bcdda29ab7e98 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 27 Oct 2017 23:47:21 -0600 Subject: [PATCH 02/22] update urls --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b3bc11..39589f2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ digd.js ======= -| [dns-suite](https://git.coolaj86.com/coolaj86/dns-suite) +| [dns-suite.js](https://git.coolaj86.com/coolaj86/dns-suite.js) | [dig.js](https://git.coolaj86.com/coolaj86/dig.js) | **digd.js** From ade2e97270b186128f34e809255cabe995e8a7e3 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 27 Oct 2017 23:53:43 -0600 Subject: [PATCH 03/22] whitespace --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 39589f2..a2719f5 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ digd.js | [dns-suite.js](https://git.coolaj86.com/coolaj86/dns-suite.js) | [dig.js](https://git.coolaj86.com/coolaj86/dig.js) | **digd.js** +| Sponsored by [Daplie](https://daplie.com). From 3f8fc8799cdc532f6005a055eb11c86385805210 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Oct 2017 02:15:32 -0600 Subject: [PATCH 04/22] v1.1.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9622a8..4d055a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "digd.js", - "version": "1.1.4", + "version": "1.1.5", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", "bin": { From c09d5f8a103bdf09d898a7aff04b80a016e3bb57 Mon Sep 17 00:00:00 2001 From: coolaj86 Date: Sun, 29 Oct 2017 03:40:26 +0000 Subject: [PATCH 05/22] Update 'README.md' --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index a2719f5..9f911a2 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,7 @@ digd.js | [dns-suite.js](https://git.coolaj86.com/coolaj86/dns-suite.js) | [dig.js](https://git.coolaj86.com/coolaj86/dig.js) | **digd.js** -| - -Sponsored by [Daplie](https://daplie.com). +| Sponsored by [Daplie](https://daplie.com). A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. From 5f3aa51aec17ad0370e0492e171e14dee07a9f94 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Oct 2017 22:03:58 -0600 Subject: [PATCH 06/22] update urls --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d055a7..9f04ab9 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.1.5", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", + "homepage": "https://git.coolaj86.com:coolaj86/digd.js", "bin": { "digd.js": "bin/digd.js" }, @@ -11,7 +12,7 @@ }, "repository": { "type": "git", - "url": "https://git.coolaj86.com/coolaj86/digd.js.git" + "url": "git://git.coolaj86.com:coolaj86/digd.js.git" }, "keywords": [ "mdig", From da2d503226347021bc0dd8f318f32668424dfd5a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Oct 2017 22:04:23 -0600 Subject: [PATCH 07/22] v1.1.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f04ab9..93e75f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "digd.js", - "version": "1.1.5", + "version": "1.1.6", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", "homepage": "https://git.coolaj86.com:coolaj86/digd.js", From 91154c3d2aee1913f280abb1317e004d6b284e99 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Oct 2017 22:04:41 -0600 Subject: [PATCH 08/22] v1.1.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93e75f5..8643d6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "digd.js", - "version": "1.1.6", + "version": "1.1.7", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", "homepage": "https://git.coolaj86.com:coolaj86/digd.js", From 901c31e7bf933942029fc2e7d3451fe3f93bcce6 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Oct 2017 22:13:32 -0600 Subject: [PATCH 09/22] update urls --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8643d6e..1e8032c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.1.7", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", - "homepage": "https://git.coolaj86.com:coolaj86/digd.js", + "homepage": "https://git.coolaj86.com/coolaj86/digd.js", "bin": { "digd.js": "bin/digd.js" }, From e9db7fc12e235c7f58f83450144330c6014109c5 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Oct 2017 22:13:52 -0600 Subject: [PATCH 10/22] v1.1.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e8032c..c482eed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "digd.js", - "version": "1.1.7", + "version": "1.1.8", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", "homepage": "https://git.coolaj86.com/coolaj86/digd.js", From d6251156892d94e1eb5dfc194a6fe11d4106e508 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 29 Oct 2017 01:43:28 -0600 Subject: [PATCH 11/22] Note setting glue and ns records --- HOWTO-NS.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 HOWTO-NS.md diff --git a/HOWTO-NS.md b/HOWTO-NS.md new file mode 100644 index 0000000..2b546c2 --- /dev/null +++ b/HOWTO-NS.md @@ -0,0 +1,7 @@ +```bash +# Create a glue record for the nameserver +daplie glue:set -n ns1.example.com -a 12.55.12.33 + +# Set the nameservers for a domain +daplie ns:set -n example.com --nameservers ns1.example.com +``` From 5af2cb51d634fbbf8cfbc63f3c47d44a7a2e7d65 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 29 Oct 2017 02:26:38 -0600 Subject: [PATCH 12/22] print number of records --- lib/dns-store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dns-store.js b/lib/dns-store.js index ef89016..8e199cf 100644 --- a/lib/dns-store.js +++ b/lib/dns-store.js @@ -395,7 +395,7 @@ module.exports.query = function (input, query, cb) { // NS records are returned as ANSWER for NS and ANY, and as AUTHORITY when an externally-delegated domain would return an SOA (no records) // SOA records are returned as ANSWER for SOA and ANY, and as AUTHORITY when no records are found, but the domain is controlled here - console.log("[DEV] has records"); + console.log("[DEV] has", someRecords.length, "records"); // filter out NS (delegation) records, unless that is what is intended someRecords = someRecords.filter(function (r) { From c49c398c3946430d431e9c86541d84c9c29f520c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 00:09:30 -0600 Subject: [PATCH 13/22] some examples --- EXAMPLE-SET-GLUE-NS-DNS.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 EXAMPLE-SET-GLUE-NS-DNS.sh diff --git a/EXAMPLE-SET-GLUE-NS-DNS.sh b/EXAMPLE-SET-GLUE-NS-DNS.sh new file mode 100644 index 0000000..220a6fb --- /dev/null +++ b/EXAMPLE-SET-GLUE-NS-DNS.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +node bin/daplie.js ns:set -n hellabit.com --nameserver ns1.daplie.com,ns2.daplie.domains,ns3.hellabit.com + +# glue setting is rate-limited, or so it would seem +echo "sleeping between setting glue for rate limit" +sleep 5 +node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.daplie.com +sleep 5 +node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.daplie.domains +sleep 5 +node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.daplie.me --tld me +sleep 5 +node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.hellabit.com --tld com +sleep 5 + +node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.com +node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.domains +node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.me --tld me +node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.hellabit.com --tld com From 861ffa1b80fff101f86276d819d6b4434c960e40 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 22:15:17 -0600 Subject: [PATCH 14/22] add systemd launch file --- dist/etc/systemd/system/digd.js.service | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 dist/etc/systemd/system/digd.js.service diff --git a/dist/etc/systemd/system/digd.js.service b/dist/etc/systemd/system/digd.js.service new file mode 100644 index 0000000..bdc0825 --- /dev/null +++ b/dist/etc/systemd/system/digd.js.service @@ -0,0 +1,61 @@ +[Unit] +Description=digd.js - A lightweight DNS server in node.js. +Documentation=https://git.coolaj86.com/coolaj86/digd.js +After=network-online.target +Wants=network-online.target systemd-networkd-wait-online.service + +[Service] +# Restart on crash (bad signal), but not on 'clean' failure (error exit code) +# Allow up to 3 restarts within 10 seconds +# (it's unlikely that a user or properly-running script will do this) +Restart=on-abnormal +StartLimitInterval=10 +StartLimitBurst=3 + +# User and group the process will run as +# (git is the de facto standard on most systems) +User=digd +Group=digd + +WorkingDirectory=/opt/digd +# custom directory cannot be set and will be the place where gitea exists, not the working directory +ExecStart=/opt/digd/bin/digd.js --config /srv/digd.js/db.json +ExecReload=/bin/kill -USR1 $MAINPID + +# Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings. +# Unmodified gitea is not expected to use more than this. +LimitNOFILE=1048576 +LimitNPROC=64 + +# Use private /tmp and /var/tmp, which are discarded after gitea stops. +PrivateTmp=true +# Use a minimal /dev +PrivateDevices=true +# Hide /home, /root, and /run/user. Nobody will steal your SSH-keys. +ProtectHome=true +# Make /usr, /boot, /etc and possibly some more folders read-only. +ProtectSystem=full +# ... except /opt/gitea because we want a place for the database +# and /var/log/gitea because we want a place where logs can go. +# This merely retains r/w access rights, it does not add any new. +# Must still be writable on the host! +ReadWriteDirectories=/opt/digd.js /srv/digd.js /var/log/digd.js + +# Note: in v231 and above ReadWritePaths has been renamed to ReadWriteDirectories +; ReadWritePaths=/opt/digd.js /srv/digd.js /var/log/digd.js + +# The following additional security directives only work with systemd v229 or later. +# They further retrict privileges that can be gained by gitea. +# Note that you may have to add capabilities required by any plugins in use. +CapabilityBoundingSet=CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_BIND_SERVICE +NoNewPrivileges=true + +# Caveat: Some features may need additional capabilities. +# For example an "upload" may need CAP_LEASE +; CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_LEASE +; AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_LEASE +; NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target From 8f34294c8872510105199012fb2127cb92545696 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 22:56:44 -0600 Subject: [PATCH 15/22] create installer with systemd service and example db --- dist/etc/systemd/system/digd.js.service | 16 ++-- install.sh | 33 +++++++++ samples/db.js | 7 +- samples/db.json | 98 +++++++++++++++++++++++++ 4 files changed, 143 insertions(+), 11 deletions(-) create mode 100644 install.sh create mode 100644 samples/db.json diff --git a/dist/etc/systemd/system/digd.js.service b/dist/etc/systemd/system/digd.js.service index bdc0825..b734ac0 100644 --- a/dist/etc/systemd/system/digd.js.service +++ b/dist/etc/systemd/system/digd.js.service @@ -17,17 +17,17 @@ StartLimitBurst=3 User=digd Group=digd -WorkingDirectory=/opt/digd -# custom directory cannot be set and will be the place where gitea exists, not the working directory -ExecStart=/opt/digd/bin/digd.js --config /srv/digd.js/db.json +WorkingDirectory=/opt/digd.js +# TODO use --config instead of commandline params +ExecStart=/opt/digd.js/bin/node /opt/digd/bin/digd.js --port 53 --input /srv/digd.js/db.json +norecurse ExecReload=/bin/kill -USR1 $MAINPID # Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings. -# Unmodified gitea is not expected to use more than this. +# Unmodified digd.js is not expected to use more than this. LimitNOFILE=1048576 LimitNPROC=64 -# Use private /tmp and /var/tmp, which are discarded after gitea stops. +# Use private /tmp and /var/tmp, which are discarded after digd.js stops. PrivateTmp=true # Use a minimal /dev PrivateDevices=true @@ -35,8 +35,8 @@ PrivateDevices=true ProtectHome=true # Make /usr, /boot, /etc and possibly some more folders read-only. ProtectSystem=full -# ... except /opt/gitea because we want a place for the database -# and /var/log/gitea because we want a place where logs can go. +# ... except /srv/digd.js because we want a place for the database +# and /var/log/digd.js because we want a place where logs can go. # This merely retains r/w access rights, it does not add any new. # Must still be writable on the host! ReadWriteDirectories=/opt/digd.js /srv/digd.js /var/log/digd.js @@ -45,7 +45,7 @@ ReadWriteDirectories=/opt/digd.js /srv/digd.js /var/log/digd.js ; ReadWritePaths=/opt/digd.js /srv/digd.js /var/log/digd.js # The following additional security directives only work with systemd v229 or later. -# They further retrict privileges that can be gained by gitea. +# They further retrict privileges that can be gained by digd.js. # Note that you may have to add capabilities required by any plugins in use. CapabilityBoundingSet=CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_BIND_SERVICE diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c08f05d --- /dev/null +++ b/install.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +sudo adduser --home /opt/digd.js --gecos '' --nopasswd --disabled-password digd +sudo mkdir -p /opt/digd.js/ /srv/digd.js /var/log/digd.js +sudo mkdir -p /opt/digd.js /srv/digd.js +chown $(whoami):$(whoami) /opt/digd.js /srv/digd.js + +echo "v8.9.0" > /tmp/NODEJS_VER +export NODE_PATH=/opt/digd.js/lib/node_modules +export NPM_CONFIG_PREFIX=/opt/digd.js +curl -fsSL https://bit.ly/install-min-node -o ./install-node.sh.tmp +bash ./install-node.sh.tmp +/opt/digd.js/bin/npm install -g npm@4 + +git clone https://git.coolaj86.com/coolaj86/digd.js /opt/digd.js/lib/node_modules/digd.js +pushd /opt/digd.js/lib/node_modules/digd.js + git checkout v1.1 + /opt/digd.js/bin/npm install +popd + +sudo rsync -v /opt/digd.js/lib/node_modules/digd.js/dist/etc/systemd/system/digd.js.service /etc/systemd/system/ +sudo rsync -v /opt/digd.js/lib/node_modules/digd.js/samples/db.json /srv/digd.js/db.json +sudo ln -s /opt/digd.js/lib/node_modules/digd.js/bin/digd.js /opt/digd.js/bin/ + +sudo chown -R digd:digd /opt/digd.js/ /srv/digd.js /var/log/digd.js + +sudo systemctl daemon-reload +sudo systemctl restart digd.js + +dig @localhost -p 53 example.com + +#sudo journalctl -xefu digd.js +sudo journalctl -xeu digd.js diff --git a/samples/db.js b/samples/db.js index f07173a..5e6da5d 100644 --- a/samples/db.js +++ b/samples/db.js @@ -1,12 +1,13 @@ 'use strict'; -module.exports = { - "primaryNameservers": [ 'localhost' ] // 'ns1.vanity-dns.org' +module.exports = +{ + "primaryNameservers": [ "localhost" ] // 'ns1.vanity-dns.org' , "domains": [ { "id": "example.com", "revokedAt": 0 } , { "id": "smith.example.com", "revokedAt": 0 } , { "id": "in-delegated.example.com", "revokedAt": 0 } - , { "id": "john.smith.example.com", "revokedAt": 0, "vanityNs": [ 'ns1.dns-server.net', 'ns2.dns-server.net' ] } + , { "id": "john.smith.example.com", "revokedAt": 0, "vanityNs": [ "ns1.dns-server.net", "ns2.dns-server.net" ] } // test and probably remove //, { "id": "out-delegated.example.com", "revokedAt": 0 } ] diff --git a/samples/db.json b/samples/db.json new file mode 100644 index 0000000..47cedb6 --- /dev/null +++ b/samples/db.json @@ -0,0 +1,98 @@ +{ + "primaryNameservers": [ "localhost" ] +, "domains": [ + { "id": "example.com", "revokedAt": 0 } + , { "id": "smith.example.com", "revokedAt": 0 } + , { "id": "in-delegated.example.com", "revokedAt": 0 } + , { "id": "john.smith.example.com", "revokedAt": 0, "vanityNs": [ "ns1.dns-server.net", "ns2.dns-server.net" ] } + ] +, "records": [ + { "zone": "example.com", "name": "example.com", "tld": "com", "sld": "example", "sub": "" + , "type": "A", "address": "1.2.3.4", "aname": "fido.devices.example.com" } + , { "zone": "example.com", "name": "example.com", "tld": "com", "sld": "example", "sub": "" + , "type": "MX", "priority": 10, "exchange": "mxa.example.org" } + , { "zone": "example.com", "name": "example.com", "tld": "com", "sld": "example", "sub": "" + , "type": "MX", "priority": 10, "exchange": "mxb.example.org" } + , { "zone": "example.com", "name": "example.com", "tld": "com", "sld": "example", "sub": "" + , "type": "SRV", "priority": 10, "weight": 20, "port": 65065, "target": "spot.devices.example.com" } + , { "zone": "example.com", "name": "example.com", "tld": "com", "sld": "example", "sub": "" + , "type": "TXT", "data": [ "foo bar baz" ] } + , { "zone": "example.com", "name": "example.com", "tld": "com", "sld": "example", "sub": "" + , "type": "TXT", "data": [ "foo", "bar", "baz" ] } + + , { "zone": "example.com", "name": "a.example.com", "tld": "com", "sld": "example", "sub": "a" + , "type": "A", "address": "4.3.2.1" } + , { "zone": "example.com", "name": "aaaa.example.com", "tld": "com", "sld": "example", "sub": "aaaa" + , "type": "AAAA", "address": "::1" } + , { "zone": "example.com", "name": "aname.example.com", "tld": "com", "sld": "example", "sub": "aname" + , "type": "A", "aname": "amazon.com" } + , { "zone": "example.com", "name": "devname.example.com", "tld": "com", "sld": "example", "sub": "devname" + , "type": "A", "address": "1.2.3.4", "aname": "fido.devices.example.com" } + , { "zone": "example.com", "name": "cname.example.com", "tld": "com", "sld": "example", "sub": "cname" + , "type": "CNAME", "data": "example.com" } + , { "zone": "example.com", "name": "mx.example.com", "tld": "com", "sld": "example", "sub": "mx" + , "type": "MX", "priority": 10, "exchange": "mxa.example.org" } + , { "zone": "example.com", "name": "mx.example.com", "tld": "com", "sld": "example", "sub": "mx" + , "type": "MX", "priority": 10, "exchange": "mxb.example.org" } + , { "zone": "example.com", "name": "srv.example.com", "tld": "com", "sld": "example", "sub": "srv" + , "type": "SRV", "priority": 10, "weight": 20, "port": 65065, "target": "spot.devices.example.com" } + , { "zone": "example.com", "name": "txt.example.com", "tld": "com", "sld": "example", "sub": "txt" + , "type": "TXT", "data": [ "foo bar baz" ] } + , { "zone": "example.com", "name": "mtxt.example.com", "tld": "com", "sld": "example", "sub": "mtxt" + , "type": "TXT", "data": [ "foo", "bar", "baz" ] } + , { "zone": "example.com", "type": "NS", "name": "ns.example.com" + , "tld": "com", "sld": "example", "sub": "ns", "data": "ns1.vanity-dns.org" } + , { "zone": "example.com", "type": "NS", "name": "ns.example.com" + , "tld": "com", "sld": "example", "sub": "ns", "data": "ns2.vanity-dns.org" } + + , { "zone": "example.com", "name": "www.example.com", "tld": "com", "sld": "example", "sub": "www" + , "type": "A", "address": "1.2.3.4", "aname": "fido.devices.example.com" } + , { "zone": "example.com", "name": "email.example.com", "tld": "com", "sld": "example", "sub": "email" + , "type": "CNAME", "data": "mailgun.org" } + + , { "zone": "example.com", "name": "*.wild.example.com", "tld": "com", "sld": "example", "sub": "*.wild" + , "type": "A", "address": "12.34.56.78" } + , { "zone": "example.com", "name": "exists.wild.example.com", "tld": "com", "sld": "example", "sub": "exists.wild" + , "type": "A", "address": "123.0.0.45" } + + , { "zone": "example.com", "type": "NS", "name": "out-delegated.example.com" + , "tld": "com", "sld": "example", "sub": "out-delegated", "data": "ns1.vanity-dns.org" } + , { "zone": "example.com", "type": "NS", "name": "out-delegated.example.com" + , "tld": "com", "sld": "example", "sub": "out-delegated", "data": "ns2.vanity-dns.org" } + + , { "zone": "example.com", "type": "NS", "name": "in-delegated.example.com" + , "tld": "com", "sld": "example", "sub": "in-delegated", "data": "localhost" } + + , { "zone": "example.com", "name": "fido.devices.example.com", "tld": "com", "sld": "example", "sub": "fido.devices" + , "device": "abcdef123" + , "type": "ANAME", "address": "1.2.3.4" } + + , { "zone": "example.com", "type": "NS", "name": "smith.example.com" + , "tld": "com", "sld": "example", "sub": "smith", "data": "ns1.vanity-dns.org" } + + , { "zone": "example.com", "name": "smith.example.com", "tld": "com", "sld": "example", "sub": "smith" + , "type": "NS", "data": "ns2.vanity-dns.org" } + + , { "zone": "smith.example.com", "name": "smith.example.com", "tld": "example.com", "sld": "smith", "sub": "" + , "type": "A", "address": "45.56.59.142", "aname": "rex.devices.smith.example.com" } + + , { "zone": "smith.example.com", "name": "www.smith.example.com", "tld": "example.com", "sld": "smith", "sub": "www" + , "type": "CNAME", "data": "smith.example.com" } + + , { "zone": "smith.example.com", "name": "john.smith.example.com", "tld": "example.com", "sld": "smith", "sub": "john" + , "type": "NS", "data": "ns1.vanity-dns.org" } + + , { "zone": "smith.example.com", "name": "john.smith.example.com", "tld": "example.com", "sld": "smith", "sub": "john" + , "type": "NS", "data": "ns2.vanity-dns.org" } + + , { "zone": "smith.example.com", "name": "*.smith.example.com", "tld": "example.com", "sld": "smith", "sub": "*" + , "type": "A", "address": "45.56.59.142", "aname": "rex.devices.smith.example.com" } + + , { "zone": "smith.example.com", "name": "exception.john.smith.example.com", "tld": "example.com", "sld": "smith", "sub": "exception.john" + , "type": "A", "address": "45.56.59.142", "aname": "rex.devices.smith.example.com" } + + + , { "zone": "john.smith.example.com", "name": "john.smith.example.com", "tld": "smith.example.com", "sld": "john", "sub": "" + , "type": "A", "address": "45.56.59.142", "aname": "rex.devices.smith.example.com" } + ] +} From 718e41b71a7331c3af02987c65d8f5ddacf454cc Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 23:14:44 -0600 Subject: [PATCH 16/22] add installer, bump to v1.1.9 --- EXAMPLE-SET-GLUE-NS-DNS.sh | 58 ++++++++++++++++++++++++++++++++------ README.md | 10 +++++-- package.json | 2 +- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/EXAMPLE-SET-GLUE-NS-DNS.sh b/EXAMPLE-SET-GLUE-NS-DNS.sh index 220a6fb..ddb0db6 100644 --- a/EXAMPLE-SET-GLUE-NS-DNS.sh +++ b/EXAMPLE-SET-GLUE-NS-DNS.sh @@ -1,20 +1,60 @@ #!/bin/bash -node bin/daplie.js ns:set -n hellabit.com --nameserver ns1.daplie.com,ns2.daplie.domains,ns3.hellabit.com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com ns:set -n hellabit.com --nameserver ns1.daplie.com,ns2.daplie.domains,ns3.hellabit.com + + # glue setting is rate-limited, or so it would seem echo "sleeping between setting glue for rate limit" sleep 5 -node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.daplie.com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.1.122 -n ns1.daplie.com sleep 5 -node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.daplie.domains +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.1.122 -n ns1.daplie.domains sleep 5 -node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.daplie.me --tld me +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.1.122 -n ns1.daplie.me --tld me sleep 5 -node bin/daplie.js glue:set -a 45.55.1.122 -n ns1.hellabit.com --tld com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.1.122 -n ns1.hellabit.com --tld com sleep 5 -node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.com -node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.domains -node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.me --tld me -node bin/daplie.js devices:attach -d ns1-do -a 45.55.1.122 -n ns1.hellabit.com --tld com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.domains +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns1-do -a 45.55.1.122 -n ns1.daplie.me --tld me +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns1-do -a 45.55.1.122 -n ns1.hellabit.com --tld com + + + +# glue setting is rate-limited, or so it would seem +echo "sleeping between setting glue for rate limit" +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.254.197 -n ns2.daplie.com +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.254.197 -n ns2.daplie.domains +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.254.197 -n ns2.daplie.me --tld me +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 45.55.254.197 -n ns2.hellabit.com --tld com +sleep 5 + +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns2-do -a 45.55.254.197 -n ns2.daplie.com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns2-do -a 45.55.254.197 -n ns2.daplie.domains +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns2-do -a 45.55.254.197 -n ns2.daplie.me --tld me +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns2-do -a 45.55.254.197 -n ns2.hellabit.com --tld com + + + +# glue setting is rate-limited, or so it would seem +echo "sleeping between setting glue for rate limit" +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 159.203.25.112 -n ns3.daplie.com +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 159.203.25.112 -n ns3.daplie.domains +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 159.203.25.112 -n ns3.daplie.me --tld me +sleep 5 +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com glue:set -a 159.203.25.112 -n ns3.hellabit.com --tld com +sleep 5 + +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns3-do -a 159.203.25.112 -n ns3.daplie.com +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns3-do -a 159.203.25.112 -n ns3.daplie.domains +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns3-do -a 159.203.25.112 -n ns3.daplie.me --tld me +node bin/daplie.js --oauth3-config ~/.oauth3+domains@daplie.com devices:attach -d ns3-do -a 159.203.25.112 -n ns3.hellabit.com --tld com diff --git a/README.md b/README.md index 9f911a2..d04c08a 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ Options are similar to the Unix dig command. Install ------- +### systemd service + +```bash +curl -L https://git.coolaj86.com/coolaj86/digd.js/raw/v1.1/install.sh | bash +``` + ### with git ```bash @@ -21,8 +27,8 @@ npm install -g 'git+https://git.coolaj86.com/coolaj86/digd.js.git#v1' ``` ```bash -# Install exactly v1.0.0 -npm install -g 'git+https://git.coolaj86.com/coolaj86/digd.js.git#v1.0.0' +# Install exactly v1.1.9 +npm install -g 'git+https://git.coolaj86.com/coolaj86/digd.js.git#v1.1.9' ``` ### without git diff --git a/package.json b/package.json index c482eed..1ac9c2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "digd.js", - "version": "1.1.8", + "version": "1.1.9", "description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.", "main": "bin/digd.js", "homepage": "https://git.coolaj86.com/coolaj86/digd.js", From b1b43a62576f1ea29f286ab9d81ae5249d925c32 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 23:19:12 -0600 Subject: [PATCH 17/22] fix adduser options --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c08f05d..977cfb1 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -sudo adduser --home /opt/digd.js --gecos '' --nopasswd --disabled-password digd +sudo adduser --home /opt/digd.js --gecos '' --disabled-password digd sudo mkdir -p /opt/digd.js/ /srv/digd.js /var/log/digd.js sudo mkdir -p /opt/digd.js /srv/digd.js chown $(whoami):$(whoami) /opt/digd.js /srv/digd.js From 9d4489f36afd2a785f4fa575f7fdbe5290c7917b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 23:20:02 -0600 Subject: [PATCH 18/22] remove node installer tmp file --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 977cfb1..b7dc49a 100644 --- a/install.sh +++ b/install.sh @@ -10,6 +10,7 @@ export NODE_PATH=/opt/digd.js/lib/node_modules export NPM_CONFIG_PREFIX=/opt/digd.js curl -fsSL https://bit.ly/install-min-node -o ./install-node.sh.tmp bash ./install-node.sh.tmp +rm ./install-node.sh.tmp /opt/digd.js/bin/npm install -g npm@4 git clone https://git.coolaj86.com/coolaj86/digd.js /opt/digd.js/lib/node_modules/digd.js From a617eb176c7c30d816974fadb5cec1bf65159ec8 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 23:26:38 -0600 Subject: [PATCH 19/22] fix chown --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b7dc49a..5e72b9c 100644 --- a/install.sh +++ b/install.sh @@ -3,7 +3,8 @@ sudo adduser --home /opt/digd.js --gecos '' --disabled-password digd sudo mkdir -p /opt/digd.js/ /srv/digd.js /var/log/digd.js sudo mkdir -p /opt/digd.js /srv/digd.js -chown $(whoami):$(whoami) /opt/digd.js /srv/digd.js +#chown -R $(whoami):$(whoami) /opt/digd.js /srv/digd.js +chown -R digd:digd /opt/digd.js /srv/digd.js echo "v8.9.0" > /tmp/NODEJS_VER export NODE_PATH=/opt/digd.js/lib/node_modules From 58a48a2877a380e27393141b56bc3367ab1a2569 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 23:31:21 -0600 Subject: [PATCH 20/22] fix npm paths --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 5e72b9c..4e85c29 100644 --- a/install.sh +++ b/install.sh @@ -12,12 +12,12 @@ export NPM_CONFIG_PREFIX=/opt/digd.js curl -fsSL https://bit.ly/install-min-node -o ./install-node.sh.tmp bash ./install-node.sh.tmp rm ./install-node.sh.tmp -/opt/digd.js/bin/npm install -g npm@4 +/opt/digd.js/bin/node /opt/digd.js/bin/npm install -g npm@4 git clone https://git.coolaj86.com/coolaj86/digd.js /opt/digd.js/lib/node_modules/digd.js pushd /opt/digd.js/lib/node_modules/digd.js git checkout v1.1 - /opt/digd.js/bin/npm install + /opt/digd.js/bin/node /opt/digd.js/bin/npm install popd sudo rsync -v /opt/digd.js/lib/node_modules/digd.js/dist/etc/systemd/system/digd.js.service /etc/systemd/system/ From d4646dba061e4ea1e901b97a8110c64e92094378 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Nov 2017 23:32:57 -0600 Subject: [PATCH 21/22] fix path name --- dist/etc/systemd/system/digd.js.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/etc/systemd/system/digd.js.service b/dist/etc/systemd/system/digd.js.service index b734ac0..e162836 100644 --- a/dist/etc/systemd/system/digd.js.service +++ b/dist/etc/systemd/system/digd.js.service @@ -19,7 +19,7 @@ Group=digd WorkingDirectory=/opt/digd.js # TODO use --config instead of commandline params -ExecStart=/opt/digd.js/bin/node /opt/digd/bin/digd.js --port 53 --input /srv/digd.js/db.json +norecurse +ExecStart=/opt/digd.js/bin/node /opt/digd.js/bin/digd.js --port 53 --input /srv/digd.js/db.json +norecurse ExecReload=/bin/kill -USR1 $MAINPID # Limit the number of file descriptors and processes; see `man systemd.exec` for more limit settings. From 49811bd321e8a9f128d86a56532078b2cc105150 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 2 Nov 2017 12:14:44 -0600 Subject: [PATCH 22/22] fix and/or logic --- lib/dns-store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dns-store.js b/lib/dns-store.js index 8e199cf..be01be4 100644 --- a/lib/dns-store.js +++ b/lib/dns-store.js @@ -439,7 +439,7 @@ module.exports.query = function (input, query, cb) { results.header.rcode = NOERROR; //console.log('[DEV] ANSWER results', results); - if (255 === query.question[0].type && 'ANY' === query.question[0].typeName) { + if (255 === query.question[0].type || 'ANY' === query.question[0].typeName) { getNsAndSoa(false, true); return; }