Automatically updates Node DNS resolver configuration if resolv.conf
changes.
Watches /etc/resolv.conf
(or similar) for changes and updates Node DNS resolver accordingly.
Detects if resolv.conf
is created, deleted, renamed or modified.
Current versions of Node.js or io.js do not update their DNS resolver configuration after application has been started.
This is due to DNS client library (c-ares
) lacking support for reinitialization or monitoring of system setting changes.
If the system DNS resolver is unconfigured at the time of application startup or the configuration is modified afterwards, Node engine does not keep up with the changes.
This module allows monitoring of /etc/resolv.conf
file and updates the runtime DNS resolver configuration of the Node application without restarting it.
Supports Node.js v0.12.0+ and io.js v1.0.0+
Node.js version v0.10 or earlier are not supported due to the lack of dns.setServers()
function.
Please let me know if you have problems running it on a later version of Node or have platform-specific problems.
Install resolvmon
using npm:
$ npm install resolvmon
Or get resolvmon
directly from:
https://github.com/imyller/node-resolvmon
// import the module and start monitoring
var resolvmon = require('resolvmon').start();
// import the module
var resolvmon = require('resolvmon');
// listen for error events
resolvmon.on('error', function (err) {
console.error(err);
});
// listen for update events
resolvmon.on('update', function (nameservers) {
console.dir(nameservers);
});
// trigger manual update
resolvmon.update();
// start monitoring
resolvmon.start();
$ npm test
You can find the repository at: https://github.com/imyller/node-resolvmon
Issues/Feature Requests can be submitted at: https://github.com/imyller/node-resolvmon/issues
I'd really like to hear your feedback, and I'd love to receive your pull-requests!
Copyright 2015-2016 Ilkka Myller. This software is licensed
under the MIT License, see LICENSE
for details.