Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MaxMind GeoIP2 Reader for Crystal

License

NotificationsYou must be signed in to change notification settings

delef/geoip2.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Built with CrystalBuild StatusReleases

Pure Crystal GeoIP2databases reader.

Installation

Add this to your application'sshard.yml:

dependencies:geoip2:github:delef/geoip2.cr

Usage

Country Example

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"

City Example

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"

Enterprise Example

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

Anonymous IP Example

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"

Connection-Type Example

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"

Domain Example

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"

ISP Example

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"

Links

Contributing

  1. Fork it (https://github.com/delef/geoip2.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

MaxMind GeoIP2 Reader for Crystal

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp