don't throw on error

This commit is contained in:
AJ ONeal 2017-12-15 04:20:16 +00:00
parent d8ead3181d
commit e2393d965a
2 changed files with 58 additions and 49 deletions

View File

@ -53,10 +53,11 @@ module.exports.create = function (cli, dnsd) {
process.exit(0);
}
console.error("TCP Server Error:");
console.error(err);
console.error(err.stack);
tcpServer.close(function () {
setTimeout(runTcp, 1000);
});
//throw new Error(err);
});
tcpServer.listen(cli.port, function () {

View File

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