Skip to content

Automatically update Node.js DNS resolver configuration if resolv.conf changes

License

Notifications You must be signed in to change notification settings

imyller/node-resolvmon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-resolvmon

Build Status npm version Flattr this git repo

NPM NPM

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.

Why?

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.

Node Compatibility

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.

Installation

Install resolvmon using npm:

$ npm install resolvmon

Or get resolvmon directly from: https://github.com/imyller/node-resolvmon

Synopsis

Basic

// import the module and start monitoring

var resolvmon = require('resolvmon').start();

Advanced

// 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();

Testing

$ npm test

Contributing

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

Copyright 2015-2016 Ilkka Myller. This software is licensed under the MIT License, see LICENSE for details.

About

Automatically update Node.js DNS resolver configuration if resolv.conf changes

Resources

License

Stars

Watchers

Forks

Packages

No packages published