Compare commits

..

2 Commits
v1.2 ... master

Author SHA1 Message Date
c0eb4225dc Update 'README.md' 2019-03-05 23:43:14 +00:00
6ef61a8674 don't let it die, duh!! 2018-05-04 16:05:59 +00:00
5 changed files with 53 additions and 64 deletions

View File

@ -5,7 +5,7 @@ digd.js
| [dig.js](https://git.coolaj86.com/coolaj86/dig.js)
| [mdig.js](https://git.coolaj86.com/coolaj86/mdig.js)
| **digd.js**
| Sponsored by [Daplie](https://daplie.com).
| A [Root project](https://rootprojects.org).
A lightweight DNS / mDNS daemon (server) in node.js.
@ -39,8 +39,7 @@ npm install -g 'git+https://git.coolaj86.com/coolaj86/digd.js.git#v1.2.0'
### without git
Don't have git? Well, you can also bow down to the gods of the centralized, monopolized, concentrated, *dictator*net
(as we like to call it here at Daplie Labs), if that's how you roll:
Don't have git? You can use npm's centralized repository:
```bash
npm install -g digd.js

View File

@ -8,7 +8,7 @@ Wants=network-online.target systemd-networkd-wait-online.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
Restart=always
StartLimitInterval=10
StartLimitBurst=3

View File

@ -27,10 +27,9 @@ module.exports.create = function (cli, dnsd) {
// TODO pad two bytes for lengths
dnsd.onMessage(nb, function (err, newAb, dbgmsg) {
var lenbuf = Buffer.from([ newAb.length >> 8, newAb.length & 255 ]);
// TODO XXX generate legit error packet
if (err) { console.error("Error", err); c.end(); return; }
var lenbuf = Buffer.from([ newAb.length >> 8, newAb.length & 255 ]);
console.log('TCP ' + dbgmsg);
c.write(lenbuf);
@ -54,11 +53,10 @@ module.exports.create = function (cli, dnsd) {
process.exit(0);
}
console.error("TCP Server Error:");
console.error(err.stack);
console.error(err);
tcpServer.close(function () {
setTimeout(runTcp, 1000);
});
//throw new Error(err);
});
tcpServer.listen(cli.port, function () {

View File

@ -1,7 +1,6 @@
'use strict';
module.exports.create = function (cli, dnsd) {
function runUdp() {
var server = require('dgram').createSocket({
type: cli.udp6 ? 'udp6' : 'udp4'
, reuseAddr: true
@ -20,12 +19,8 @@ module.exports.create = function (cli, dnsd) {
process.exit(123);
return;
}
console.error("UDP Server Error:");
console.error(err.stack);
server.close(function () {
setTimeout(runUdp, 1000);
});
//throw new Error(err);
console.error("error:", err.stack);
server.close();
};
handlers.onMessage = function (nb, rinfo) {
@ -34,9 +29,9 @@ module.exports.create = function (cli, dnsd) {
dnsd.onMessage(nb, function (err, newAb, dbgmsg) {
// TODO send legit error message
if (err) { server.send(Buffer.from([0x00]), rinfo.port, rinfo.address); return; }
if (err) { server.send(Buffer.from([0x00])); return; }
server.send(newAb, rinfo.port, rinfo.address, function () {
console.log('[dnsd.onMessage] ' + dbgmsg, rinfo.port, rinfo.address);
console.log(dbgmsg, rinfo.port, rinfo.address);
});
});
};
@ -60,7 +55,4 @@ module.exports.create = function (cli, dnsd) {
server.on('listening', handlers.onListening);
return server;
}
return runUdp();
};

View File

@ -1,6 +1,6 @@
{
"name": "digd.js",
"version": "1.2.2",
"version": "1.2.1",
"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",