Mattias Bodlund 3 weeks ago
parent
commit
75a323f3a6
1 changed files with 15 additions and 7 deletions
  1. +15
    -7
      config/initializers/geocoder.rb

+ 15
- 7
config/initializers/geocoder.rb View File

@ -1,11 +1,19 @@
Geocoder.configure( Geocoder.configure(
# IP-address geolocation service used by `request.location`.
# ipinfo.io works without an API key at low volume; add an ipinfo_token to the
# Rails credentials to raise the rate limit. For a no-rate-limit /
# privacy-friendly setup, swap this for an offline MaxMind GeoLite2 lookup
# (ip_lookup: :geoip2 + the .mmdb file).
ip_lookup: :ipinfo_io,
ipinfo_io: { api_key: Rails.application.credentials.ipinfo_token.presence },
# IP-address geolocation, used by ResolvePlayerCountryJob to tag each player
# with the country they played from.
#
# The credential is an **IPinfo Lite** token, so we use the Lite lookup: that
# is the endpoint the token is issued for (api.ipinfo.io/lite), and it is free
# and unmetered. It returns country + ASN only -- no city, no coordinates --
# which is all we need, since the job only reads `country_code`.
#
# Pointing this at :ipinfo_io instead still "works" (the token is accepted on
# ipinfo.io/<ip>/geo) but bills against the metered standard API, so a busy
# day can start returning 429s -- which are swallowed below and silently cost
# us a player's country. For a no-rate-limit / offline setup, swap in MaxMind
# GeoLite2 (ip_lookup: :geoip2 + the .mmdb file).
ip_lookup: :ipinfo_io_lite,
ipinfo_io_lite: { api_key: Rails.application.credentials.ipinfo_token.presence },
# A slow or unreachable geo service must never hold up the start of the game. # A slow or unreachable geo service must never hold up the start of the game.
timeout: 2, timeout: 2,


Loading…
Cancel
Save