$ gnpm install nat-sampler
Sample addresses to figure out if a host + port is consistent
npm install nat-sampler
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)
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.hostWhat the sampler thinks your host is.
If your host is unknown it will be null.
s.portWhat the sampler thinks your port is.
If your port is random or unknown it will be 0.
s.sizeHow many samples the sampler is basing this on.
The sampler applies some simple error correction to make sure bad samples do not mess it up.
<= 3 samples, it will disregard none outliers.<= 7 samples, it will disregard one outliers.<= 11 samples, it will disregard two outliers.> 11 samples, it will disregard three outliers.At max it keeps 16 samples of { host, port } pairs for the analysis.
MIT
Copyright 2013 - present © cnpmjs.org | Home |