Package Exports
- hostile
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hostile) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hostile
Simple, programmatic /etc/hosts manipulation (in node.js)

install
npm install hostileos support
- OS X and Linux: Assumes hosts file will be at
/etc/hosts. - Windows: Assumes hosts file is at
C:/Windows/System32/drivers/etc/hosts.
must use sudo!
If your OS requires admin privileges to edit the hosts file (most OSs do), then you'll need to run your node script with sudo. I use hostile in a command line script, so running with sudo is easy and not a security risk.
I wouldn't recommend running your production node server with admin privileges unless you downgrade to a normal user with process.setuid(id) before you start accepting requests.
usage
var hostile = require('hostile')
hostile.set('127.0.0.1', 'cdn.peercdn.com', function (err) {
if (err) {
console.error(err)
} else {
console.log('set /etc/hosts successfully!')
}
})This adds a rule to /etc/hosts. If the rule already exists, then this does nothing.
hostile.remove('127.0.0.1', 'cdn.peercdn.com', function (err) {
if (err) {
console.error(err)
} else {
console.log('set /etc/hosts successfully!')
}
})This removes a rule from /etc/hosts. If the rule does not exist, then this does nothing.
advanced usage
For other features (not documented), see index.js. If this module doesn't do exactly what you need, feel free to send a pull request!
license
MIT. Copyright (c) Feross Aboukhadijeh.