-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use geop-lite module instead of geoip
- Loading branch information
Showing
4 changed files
with
242 additions
and
766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,51 @@ | ||
Place a Maxmind (or other GeoIP-compatible database) here for country-level lookups. | ||
## GeoIP data for isitchristmas.com | ||
|
||
This has been tested with the MaxMind `GeoIP Legacy Binary` format, which may be provided as a zipped `.dat` file. | ||
This app uses the [`geoip-lite`](https://github.com/bluesmoon/node-geoip) library to process GeoIP2 CSV files into a binary `.dat` format, that is then read in directly by the app. | ||
|
||
Rename the `.dat` file to be `countries.dat`, and place it in this directory. `data/countries.dat` is in this project's `.gitignore`. | ||
Unfortunately, the process of doing this is a little complicated. | ||
|
||
See [kuno/GeoIP](https://github.com/kuno/GeoIP) for more information. | ||
1. Buy the paid GeoIP2 country CSV from Maxmind. | ||
2. Download the free GeoLite2 city CSV from Maxmind. (Needed for parsing, not for looking up user city.) | ||
3. Symlink the `data/` folder in this directory to be the local `data` folder inside `./node_modules/geoip-lite`, so that the results of the update script drop them here. | ||
4. Update `geoip-lite`'s update script to use/download these CSVs during its update process. | ||
5. Run the update script, which should create/update `geoip-city-name.dat`, `geoip-city.dat`, `geoip-city6.dat`, `geoip-country.dat`, and `geoip-country6.dat` inside the `/data` folder. | ||
|
||
Note: Until `kuno/GeoIP` supports newer versions of Node (6.x and up), the project uses a fork that maintains an (outstanding pull request) for Node 6.x support. | ||
When the app is run, running `require('geoip-lite')` should use the `.dat` files to populate the database. | ||
|
||
* Fork: https://github.com/dankang/GeoIP | ||
* Fork backup: https://github.com/konklone/GeoIP | ||
* branch: `feature/support_nodejs_6x` | ||
|
||
### Implementation notes | ||
|
||
Example of database object to use in `updatedb.js`: | ||
|
||
```javascript | ||
var databases = [ | ||
{ | ||
type: 'country', | ||
url: 'http://localhost:5000/GeoIP2-Country-CSV_20181218.zip', | ||
src: [ | ||
'GeoIP2-Country-Locations-en.csv', | ||
'GeoIP2-Country-Blocks-IPv4.csv', | ||
'GeoIP2-Country-Blocks-IPv6.csv' | ||
], | ||
dest: [ | ||
'', | ||
'geoip-country.dat', | ||
'geoip-country6.dat' | ||
] | ||
}, | ||
{ | ||
type: 'city', | ||
url: 'http://localhost:5000/GeoLite2-City-CSV_20181218.zip', | ||
src: [ | ||
'GeoLite2-City-Locations-en.csv', | ||
'GeoLite2-City-Blocks-IPv4.csv', | ||
'GeoLite2-City-Blocks-IPv6.csv' | ||
], | ||
dest: [ | ||
'geoip-city-names.dat', | ||
'geoip-city.dat', | ||
'geoip-city6.dat' | ||
] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.