From 96dd311fc5cd7c697da3c1b555837b72f83d0751 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 10 Jan 2018 01:25:56 -0700 Subject: [PATCH] add http listing --- bin/digd.js | 2 +- lib/httpd.js | 8 +++++--- lib/public/index.html | 3 +++ lib/store.json.js | 4 ++-- lib/tcpd.js | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 lib/public/index.html diff --git a/bin/digd.js b/bin/digd.js index cce2ea8..35c121c 100755 --- a/bin/digd.js +++ b/bin/digd.js @@ -97,6 +97,7 @@ cli.main(function (args, cli) { } var engine; + var path = require('path'); var engineOpts = { filepath: path.resolve(cli.input) }; var dnsd = {}; dnsd.onMessage = function (nb, cb) { @@ -367,7 +368,6 @@ cli.main(function (args, cli) { } // TODO get local answer first, if available - var path = require('path'); if (!cli.input) { console.warn('[WARN] no db path given, must recurse if enabled'); recurse(); diff --git a/lib/httpd.js b/lib/httpd.js index 3fb0c12..43d3d30 100644 --- a/lib/httpd.js +++ b/lib/httpd.js @@ -13,17 +13,19 @@ module.exports.create = function (cli, engine, dnsd) { res.send({ nameservers: [] }); }); app.get('/api/zones', function (req, res) { - engine.zones.all(function (zones) { + engine.zones.all(function (err, zones) { res.send({ zones: zones }); }); }); app.get('/api/records/:zone', function (req, res) { - engine.records.all(function (records) { + engine.records.all(function (err, records) { res.send({ records: records }); }); }); - httpServer.listen(cli.http); + httpServer.listen(cli.http, function () { + console.log(httpServer.address().address + '#' + httpServer.address().port + ' (http)'); + }); } runHttp(); diff --git a/lib/public/index.html b/lib/public/index.html new file mode 100644 index 0000000..b2f74f5 --- /dev/null +++ b/lib/public/index.html @@ -0,0 +1,3 @@ +

/api/peers

+

/api/zones

+

/api/records/:zone

diff --git a/lib/store.json.js b/lib/store.json.js index 8e14003..21adb23 100644 --- a/lib/store.json.js +++ b/lib/store.json.js @@ -8,7 +8,7 @@ module.exports.create = function (opts) { engine.primaryNameservers = db.primaryNameservers; engine.zones = { - all: function (query, cb) { + all: function (cb) { process.nextTick(function () { cb(null, db.domains.slice(0)); }); @@ -23,7 +23,7 @@ module.exports.create = function (opts) { } }; engine.records = { - all: function (query, cb) { + all: function (cb) { process.nextTick(function () { cb(null, db.records.slice(0)); }); diff --git a/lib/tcpd.js b/lib/tcpd.js index 2c4b4e9..5836bdb 100644 --- a/lib/tcpd.js +++ b/lib/tcpd.js @@ -61,7 +61,7 @@ module.exports.create = function (cli, dnsd) { }); tcpServer.listen(cli.port, function () { - console.log('TCP Server bound'); + console.log(tcpServer.address().address + '#' + tcpServer.address().port + ' (tcp)'); }); return tcpServer;