WIP get peer ns addresses

This commit is contained in:
AJ ONeal 2018-01-30 12:03:25 -07:00
parent d5d1cf5782
commit 98a64a3d34
3 changed files with 25 additions and 4 deletions

View File

@ -24,7 +24,10 @@
<h3>Peers:</h3>
<ul class="js-peer-tpl">
<li class="js-peer-name">peer-name</li>
<li class="js-peer">
<span class="js-peer-name">nsx.example.com</span>
<span class="js-peer-address">127.0.0.1</span>
</li>
</ul>
<div>

View File

@ -94,6 +94,8 @@
console.log($qs('.js-peer-name', el));
$qs('.js-peer-name', el).innerText = peer.name;
$qs('.js-peer-name', el).dataset.id = peer.name;
$qs('.js-peer', el).dataset.id = peer.name;
$qs('.js-peer-address', el).innerText = peer.address || '';
console.log(el.innerHTML);
tpl += el.innerHTML;
console.log(tpl);

View File

@ -116,10 +116,26 @@ module.exports.create = function (opts) {
};
engine.peers = {
all: function (cb) {
process.nextTick(function () {
var dns = require('dns');
var count = db.primaryNameservers.length;
function gotRecord() {
count -= 1;
if (!count) {
cb(null, db.primaryNameservers);
}
}
function getRecord(ns) {
dns.resolve4(ns.name, function (err, addresses) {
console.log('ns addresses:');
console.log(addresses);
if (err) { console.error(err); gotRecord(); return; }
ns.type = 'A';
ns.address = addresses[0];
gotRecord();
});
}
db.primaryNameservers.forEach(getRecord);
}
};
engine.zones = {
all: function (cb) {