0.2.12 • Published 10 years ago

geoip-stream v0.2.12

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

geoip-stream

Maxmind GeoIP Stream. Transforms a JSON string stream of objects by looking for an ip field (as defined) and appending maxmind data to the stream if it is found. Uses readable-stream for node < 0.10 to ensure stream2+ sanity.

Install

npm install geoip-stream

Maxmind data installed, ex: free Maxmind GeoLiteCity stored in ./GeoLiteCity.dat

Usage

Sample logfile.json line:

{"ip": "198.55.125.23", "timestamp":"2014-02-24 10:29:42", "url": "http:\/\/somedomain.com"}
var fs          = require('fs');
var logstream   = fs.createReadStream('logfile.json');
var split       = new require('split')();
var geoipStream = require('geoip-stream');
var geoip       = new geoipStream({
	dataPath:        './GeoLiteCity.dat', // default
	memoryCache:     true,                // default
	checkForUpdates: true,                // default
	ipField:         'ip',                // default
	dropIpField:     true                 // default is false
});

logstream
.pipe(split)
.pipe(geoip)
.pipe(process.stdout) // { "timestamp": ..., "countryCode": "US", "city":"Dallas", ...}

License

MIT

0.2.12

10 years ago

0.2.11

10 years ago

0.2.10

10 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.4

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago