Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jimpick/dat-geoip
Lookup IP addresses using the Dat protocol (hypertrie)
https://github.com/jimpick/dat-geoip
Last synced: 17 days ago
JSON representation
Lookup IP addresses using the Dat protocol (hypertrie)
- Host: GitHub
- URL: https://github.com/jimpick/dat-geoip
- Owner: jimpick
- Created: 2018-08-10T06:21:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-11T00:15:50.000Z (about 6 years ago)
- Last Synced: 2024-10-08T04:33:36.337Z (about 1 month ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - jimpick/dat-geoip - Lookup IP addresses using the Dat protocol (hypertrie) (others)
README
@jimpick/dat-geoip
==================An experiment in using hypertrie to host a peer-to-peer geo ip lookup database.
The data from [MaxMind GeoLite2](https://dev.maxmind.com/geoip/geoip2/geolite2/)
is loaded into a [hypertrie](https://github.com/mafintosh/hypertrie).# Install
```
npm install -g @jimpick/dat-geoip
```# Usage
There is a CLI to look up an IP address:
```
$ dat-geoip 66.6.44.4
{
"ip": "66.6.44.4",
"network": "66.6.32.0/20",
"geonameId": 5128581,
"registeredCountryGeonameId": 6252001,
"representedCountryGeonameId": 0,
"isAnonymousProxy": false,
"isSatelliteProvider": false,
"postalCode": "10010",
"latitude": 40.7391,
"longitude": -73.9826,
"accuracyRadius": 1000,
"localeCode": "en",
"continentCode": "NA",
"continentName": "North America",
"countryIsoCode": "US",
"countryName": "United States",
"subdivision1IsoCode": "NY",
"subdivision1Name": "New York",
"subdivision2IsoCode": "",
"subdivision2Name": "",
"cityName": "New York",
"metroCode": "501",
"timeZone": "America/New_York",
"isInEuropeanUnion": false
}
```# Limitations
* Just a demo - the data I am seeding might not stay online forever
* IPv4 only right now
* English only
* Dat key for database is hardcoded
* No library yet
* Data is stored as JSON - it would be better to store it in a binary format
* The lookup strategy is quite naive and not heavily tested. A high performance
version would probably build a custom index
* Uses the free GeoLite2 database. I haven't tried loading the paid GeoIP2
database (it probably would work, but take care to keep the key private to
avoid violating license terms)# License
This software is MIT licensed.
The data that gets loaded into it from MaxMind has this license:
```
This product includes GeoLite2 data created by MaxMind, available from
http://www.maxmind.com.
```