Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boomcatch

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boomcatch

Standalone beacon server for boomerang.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-45.45%
Maintainers
1
Weekly downloads
 
Created
Source

boomcatch

Standalone, node.js-based beacon server for boomerang. Read more.

Build status

  • boomcatch version: 1.0.0
  • node.js versions: 0.8, 0.10, 0.11

Installation

At the system level

First you must install node.

You can then install boomcatch via npm:

npm install -g boomcatch

Local to a node.js project

Add boomcatch to the dependencies in your project's package.json, then run:

npm install

Usage

From the command line

To see the list of command line options run:

boomcatch --help

Available options are:

  • --host <name>: Host name to accept HTTP connections on. The default is 0.0.0.0 (INADDR_ANY).

  • --port <port>: Port to accept HTTP connections on. The default is 80.

  • --path <path>: URL path to accept requests to. The default is /beacon.

  • --referer <regex>: HTTP referers to accept requests from. The default is .*.

  • --origin <origin>: Comma-separated list of URL(s) for the Access-Control-Allow-Origin header. The default is * (any origin), specify 'null' to force same origin.

  • --limit <milliseconds>: Minimum elapsed time to allow between requests from the same IP adderss. The default is 0.

  • --maxSize <bytes>: Maximum body size to allow for POST requests. The default is -1 (unlimited).

  • --silent: Prevent the command from logging output to the console.

  • --validator <path>: Validator used to accept or reject request data. The default is permissive (always accept requests).

  • --mapper <path>: Data mapper used to transform data before forwarding, loaded with require. The default is statsd.

  • --prefix <prefix>: Prefix for mapped metric names. The default is the empty string (no prefix).

  • --forwarder <path>: Forwarder used to send data, loaded with require. The default is udp.

  • --fwdHost <name>: Host name to forward mapped data to. The default is 127.0.0.1. This option is only effective with the UDP forwarder.

  • --fwdPort <port>: Port to forward mapped data on. The default is 8125. This option is only effective with the UDP forwarder.

  • --fwdUrl <url>: URL to forward mapped data to. This option is only effective with the HTTP forwarder.

  • --fwdMethod <method>: Method to forward mapped data with. The default is GET. This option is only effective with the HTTP forwarder.

From a node.js project

var path = require('path'),
    boomcatch = require('boomcatch');

boomcatch.listen({
    host: 'rum.example.com',                  // Defaults to '0.0.0.0' (INADDR_ANY)
    port: 8080,                               // Defaults to 80
    path: '/perf',                            // Defaults to '/beacon'
    referer: /^\w+\.example\.com$/,           // Defaults to /.*/
    origin: [                                 // Defaults to *
      'http://foo.example.com',
      'http://bar.example.com'
    ],
    limit: 100,                               // Defaults to 0
    maxSize: 1048576,                         // Defaults to -1
    log: console.log,                         // Defaults to function () {}
    validator: path.resolve('./myvalidator'), // Defaults to 'permissive'
    mapper: path.resolve('./mymapper'),       // Defaults to 'statsd'
    prefix: 'mystats.rum.',                   // Defaults to ''
    forwarder: 'http',                        // Defaults to 'udp'
    fwdUrl: 'https://stats.example.com/',     // No default
    fwdMethod: 'POST'                         // Defaults to 'GET'
});

Data mappers

Mappers are used to transform data into appropriate formats for back-end stats consumers. Currently, one mapper is available out-of-the-box, which formats the metrics as statsd timers.

Defining a custom data mapper is straightforward. The source code for the statsd mapper should be easy to follow, but the basic pattern is to export an interface that looks like this:

{
    initialise: function (options) {
    }
}

The initialise function should return a function that is passed a data object and a referring URL as parameters, and returns the mapped data as its result.

If you then specify the path to your new mapper with the mapper option, a first attempt to load it is made relative to this project's src/mappers directory. When that call to require fails, a second attempt will be made using the path that you specified verbatim.

Data forwarders

Forwarders are used to send mapped data to back-end stats consumers. At the moment, two forwarders are implemented, dispatching the data over UDP or HTTP.

Defining a custom forwarder takes broadly the same form as defining a custom mapper and can be seen in the source code for the udp forwarder. Again, the module should export an interface that looks like this:

{
    initialise: function (options) {
    }
}

In this case, the initialise function should return a function that is passed the mapped data and a callback function as its two parameters. When the forwarding process has completed, the callback function should be invoked, following the node.js convention of the first argument containing any error, or a falsey value if things went okay. The second argument should contain the number of bytes that were sent.

Once your custom forwarder is ready, you can specify the path to it using the forwarder option.

Request validators

Validators are used to test whether each request should be accepted or rejected. Typically, they check for the presence of a valid nonce in the query string, as a preventative measure against denial-of-service attacks. One validator is available out-of-the-box, which simply accepts all requests.

As with mappers and forwarders, defining your own validator is easy and the basic interface looks the same:

{
    initialise: function (options) {
    }
}

Here, the initialise function should return a function that receives an object representing the parsed query string and returns either true or false, signifying that the request is valid or invalid respectively.

Requests that are identified as invalid will fail with an HTTP 400 status.

Development

Before sumitting any pull requests, please ensure that you have adhered to the contribution guidelines.

To clone the repository:

git clone git@github.com:nature/boomcatch.git

To set up the development environment:

npm install

To lint the code:

npm run lint

To run the unit tests:

npm test

Change log

History

License

GPL 3

Copyright © 2014 Nature Publishing Group

Keywords

FAQs

Package last updated on 19 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc