node package manager

port-drop

port-drop Build status for port-drop on Circle CI.

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.

  1. Fork it.
  2. Make a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

License

MPL-2.0 © Seth Holladay

Go make something, dang it.