Skip to content

joevennix/GeoIP-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeoIP.js

A fast IP Address geocoder for node.js

NOTE: A better, faster, more in-depth IP geocoder for node.js called GeoIP -- inspired by this project -- is now available from Kuno. I would recommend using that library.

###FAQ

What is it?

GeoIP.js is a simple, three method class that allows you to enter an IP address and get back a latitude/longitude.

How does it work?

GeoIP.js works by providing v8->C++ glue code that interfaces with the free MaxMind geocoding library.

Installation

  1. Download the MaxMind C API from here.

  2. Install the MaxMind C API:

    wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
    

tar -xvzf GeoIP-1.4.6.tar.gz cd GeoIP-1.4.6 ./configure make sudo make install

Note: 'sudo make install' also installs a few command line programs: geoiplookup, geoiplookup6, and geoipupdate. You probably don't want them. To remove them, just delete them from '/usr/local/bin/'.

  1. Download this project and build it:
    git clone git@github.com:joevennix/GeoIP-js.git
    

cd GeoIP-js node-waf configure build

  1. Download the MaxMind Geocoding Database file, GeoLiteCity.dat.gz. Un-gzip this file and stick it where ever you want.

  2. That's it! Let's look at some code:

    var geo = require('./GeoIP-js/geoip.js');
    

geo.open({ cache: true, filename: './geoip/GeoLiteCity.dat'}); var coord = geo.lookup('74.125.227.16'); console.log(coord); geo.close(); You should see the ouput:

$ node test.js
[ 37.4192008972168, -122.05740356445312 ]
$ 

About

A fast IP Address geocoder for node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published