README
port-drop
Bind to a port and drop privileges.
Why?
- Running as root is unsafe.
- Ports below 1024 require root privileges.
- Drop privileges fast by binding to a port early.
Install
npm install port-drop --save
Usage
Get it into your program.
const portDrop = require('port-drop');
Allocate file descriptors for some ports you intend to use and immediately drop privileges.
const fd = portDrop.allocate({
http : 80,
https : 443
});
The returned fd
object has the same properties as the input object, but with the values being file descriptors. You can then pass these to Node's Server#listen() method, for example.
Contributing
See our contributing guidelines for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
License
Go make something, dang it.