failover-dns
v1.0.1
Published
Use local cache dns query result when dns query fail.
Downloads
1
Readme
failover-dns
Use local cache dns query result when dns query fail.
- Support dns lookup with
options.timeout
.
Installation
$ npm install failover-dns
Quick start
const dns = require('failover-dns');
// must listen `error` event to logging by yourself
dns.on('error', err => console.error(err));
dns.lookup('cnpmjs.org', { family: 4, timeout: 2000 }, (err, ip, family) => {
if (err) throw err;
console.log(ip, family);
});
Default dns query timeout
Default is 0
:
exports.defaultTimeout = 0;
Maybe you want to set global default timeout is 2000ms
:
exports.defaultTimeout = 2000;