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

nat-sampler

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nat-sampler

Sample addresses to figure out if a host + port is consistent

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
increased by3.94%
Maintainers
1
Weekly downloads
 
Created
Source

nat-sampler

Sample addresses to figure out if a host + port is consistent

npm install nat-sampler

Usage

const NatSampler = require('nat-sampler')

const s = new NatSampler()

// add a sample
const hits = s.add('127.0.0.1', 9090)

console.log('In there this many times:', hits)
console.log('Estimated host + port', s.host, s.port)

API

s = new NatSampler()

Make a new sampler.

hits = s.add(host, port)

Add a sample of your host and port. Returns how many hits this entry has.

s.host

What the sampler thinks your host is.

If your host is unknown it will be null.

s.port

What the sampler thinks your port is.

If your port is random or unknown it will be 0.

s.size

How many samples the sampler is basing this on.

Error correction

The sampler applies some simple error correction to make sure bad samples do not mess it up.

  • If it has <= 3 samples, it will disregard none outliers.
  • If it has <= 7 samples, it will disregard one outliers.
  • If it has <= 11 samples, it will disregard two outliers.
  • If it has > 11 samples, it will disregard three outliers.

At max it keeps 16 samples of { host, port } pairs for the analysis.

License

MIT

FAQs

Package last updated on 21 Jul 2021

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