- Notifications
You must be signed in to change notification settings - Fork7
MaxMind GeoIP2 Reader for Crystal
License
NotificationsYou must be signed in to change notification settings
delef/geoip2.cr
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Pure Crystal GeoIP2databases reader.
Add this to your application'sshard.yml:
dependencies:geoip2:github:delef/geoip2.cr
require"geoip2"reader=GeoIP2.open("/path/to/GeoLite2-Country.mmdb")record= reader.country("128.101.101.101")record.country.iso_code# => "US"record.country.in_european_union?# => falserecord.country.name# => "United States"record.country.names["de"]# => "USA"record.continent.code# => "NA"record.continent.name# => "North America"record.registered_country.iso_code# => "US"record.registered_country.name# => "United States"
require"geoip2"reader=GeoIP2.open("/path/to/GeoLite2-City.mmdb", ["en","ru","de"])record= reader.city("128.101.101.101")record.city.geoname_id# => 5045360record.city.name# => "Minneapolis"record.city.names["ru"]# => "Миннеаполис"record.country.iso_code# => "US"record.country.in_european_union?# => falserecord.country.name# => "United States"record.country.names["de"]# => "USA"record.continent.code# => "NA"record.continent.name# => "North America"record.location.accuracy_radius# => 20record.location.latitude# => 44.9532record.location.longitude# => -93.158record.location.metro_code# => 613record.location.time_zone# => "America/Chicago"record.postal.code# => "55104"record.registered_country.iso_code# => "US"record.registered_country.name# => "United States"record.subdivisions[0].iso_code# => "MN"record.subdivisions[0].name# => "Minnesota"
require"geoip2"reader=GeoIP2.open("/path/to/GeoIP2-Enterprise.mmdb")record= reader.enterprise("128.101.101.101")record.city.name# => "Minneapolis"record.city.confidence# => 60record.country.iso_code# => "US"record.country.name# => "United States"record.country.names["zh-CN"]# => "美国"record.country.confidence# => 99record.subdivisions[0].name# => "Minnesota"record.subdivisions[0].iso_code# => "MN"record.subdivisions[0].confidence# => 77record.postal.code# => "55455"record.postal.confidence# => "55455"record.location.latitude# => 44.9733record.location.longitude# => -93.2323record.location.accuracy_radius# => 50
require"geoip2"reader=GeoIP2.open("/path/to/GeoIP2-Anonymous-IP.mmdb")record= reader.anonymous_ip("128.101.101.101")record.anonymous?# => falserecord.anonymous_vpn?# => falserecord.hosting_provider?# => falserecord.public_proxy?# => falserecord.tor_exit_node?# => falserecord.ip_address# => "128.101.101.101"
require"geoip2"reader=GeoIP2.open("/path/to/GeoIP2-Connection-Type.mmdb")record= reader.connection_type("128.101.101.101")record.connection_type# => "Corporate"record.ip_address# => "128.101.101.101"
require"geoip2"reader=GeoIP2.open("/path/to/GeoIP2-Domain.mmdb")record= reader.domain("128.101.101.101")record.domain# => "umn.edu"record.ip_address# => "128.101.101.101"
require"geoip2"reader=GeoIP2.open("/path/to/GeoIP2-ISP.mmdb")record= reader.isp("128.101.101.101")record.autonomous_system_number# => 217record.autonomous_system_organization# => "University of Minnesota"record.isp# => "University of Minnesota"record.organization# => "University of Minnesota"record.ip_address# => "128.101.101.101"
- MaxMind DB readerhttps://github.com/delef/maxminddb.cr
- MaxMind DB file format specificationhttp://maxmind.github.io/MaxMind-DB/
- MaxMind test/sample DB fileshttps://github.com/maxmind/MaxMind-DB
- GeoLite2 Free Downloadable Databaseshttp://dev.maxmind.com/geoip/geoip2/geolite2/
- Fork it (https://github.com/delef/geoip2.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
About
MaxMind GeoIP2 Reader for Crystal
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.