<commit_before>GeoIP API for node.
===================


##Description

Get geolocation information based on domain or IP address.

__Live Demo__

[http://192.168.3.11:8124/](http://192.168.3.11:8124)


##Compatibility

v0.3.2, Passed test on nodejs v0.2.0 ~ 0.2.6, v0.3.0 ~ 0.3.6.

__Note: next release(0.3.3)  will drop the support for 0.2.0.__


##Architecture

![architecture](https://github.com/kuno/GeoIP/raw/master/misc/architecture.png)


##Data

Befor you can use this package, you need to download or buy some data from [www.maxmind.com](http://www.maxmind.com/app/ip-location).

There are three free versions data among with some commercial versions.

__Note: This package only support binary data and IP address version 4, not any other formats.__

GeoIP ASN Edition [Download](http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz)  

GeoIP City Lite Edition [Download](http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz)  

GeoIP Country Lite Edition [Download](http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz).



##Install

    npm install geoip


##Usage

__Open the binary data file__

    var data = geoip.open('/path/to/file');

__Check the type of opened data__

    var type = geoip.check(data);
    // Return one of these: 'country', 'city', 'org', 'netspeed', 'region';
    // Or return null, if not a valid data

__Close the opened data__

    geoip.close(data);

##Examples

###Country Information<commit_msg>added async style open file<commit_after>GeoIP API for node.
===================


##Description

Get geolocation information based on domain or IP address.

__Live Demo__

[http://192.168.3.11:8124/](http://192.168.3.11:8124)


##Compatibility

v0.3.2, Passed test on nodejs v0.2.0 ~ 0.2.6, v0.3.0 ~ 0.3.6.

__Note: next release(0.3.3)  will drop the support for 0.2.0.__


##Architecture

![architecture](https://github.com/kuno/GeoIP/raw/master/misc/architecture.png)


##Data

Befor you can use this package, you need to download or buy some data from [www.maxmind.com](http://www.maxmind.com/app/ip-location).

There are three free versions data among with some commercial versions.

__Note: This package only support binary data and IP address version 4, not any other formats.__

GeoIP ASN Edition [Download](http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz)  

GeoIP City Lite Edition [Download](http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz)  

GeoIP Country Lite Edition [Download](http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz).



##Install

    npm install geoip


##Usage

###Open the binary data file

__The synchronous way:__

    var data = geoip.open('/path/to/file');

    var type = geoip.check(data);
    // Return one of these: 'country', 'city', 'org', 'netspeed', 'region';
    // Or return null, if not a valid data

__The asynchronous way:__

    geoip.filter('/path/to/file', function(err, type, data) {
        if (err) {throw err;}  // The given path is not a valid data file.
        if (type === 'country') {
            console.log(geoip.Country.code_by_addr(data, '8.8.8.8')); // prints 'US'
        }
    });

###Close the opened data object

    geoip.close(data);


##Examples

###Country Information
{'fraction_non_alphanumeric': 0.14225563909774436, 'fraction_numerical': 0.03007518796992481, 'mean_word_length': 3.6713483146067416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6356136', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1118, 'n_words': 314}