Giter Site home page Giter Site logo

node-geoip-native's Introduction

Node GeoIP Native

This package is a lightning-fast, native JavaScript geoip lookup built on MaxMind's free country database.

It is non-blocking and operates without any IO after initially loading the data into memory.

Results are 4 - 5 times faster than geoip-lite with the caveat that it takes 2 or 3 times longer to initialize and uses 60 or 70 megabytes memory.

This is used in production at Playtomic up to about 20,000 times a second.

Benchmarks on my 2011 Macbook Air whilst running lots of software. The test took the middle 10 results from 20 iterations and averaged them. The APIs are interchangeable so tests were identical.

geoip-native:	average: 1540.3ms / million lookups
geoip-lite: 	average: 8375.3ms / million lookups

Requires

  1. Comes with the standard CSV database by MaxMind which may require updating.

How to use

  1. git clone https://github.com/benlowry/node-geoip-native
  2. cd node-geoip-native
  3. node test.js

or just npm install geoip-native

Methods

Node GeoIP Native provides methods for:

  1. lookup performs the lookup, takes the ip address as a parameter

Examples

var geoip = require("geoip-native");
var ip = "123.123.123.123";
geoip.lookup(ip);
console.log("country: " + ip.name + " / " + ip.code);

// in practice you'd want:
// ip = request.headers["x-forwarded-for"] || request.connection.remoteAddress,

What's missing

Be neat to expand this to include cities.

License

Copyright Playtomic Inc, 2012. Licensed under the MIT license. Certain portions may come from 3rd parties and carry their own licensing terms and are referenced where applicable.

This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.