mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 02:51:14 +08:00
FEATURE: support MaxMind DB downloads using a license key
MaxMind now requires an account with a license key to download files. Discourse admins can register for such an account at: https://www.maxmind.com/en/geolite2/signup License key generation is available in the profile section. Once registered you can set the license key using `DISCOURSE_MAXMIND_LICENSE_KEY` This amends it so we unconditionally skip MaxMind DB downloads if no license key exists.
This commit is contained in:
@ -25,10 +25,19 @@ class DiscourseIpInfo
|
||||
end
|
||||
|
||||
def self.mmdb_download(name)
|
||||
|
||||
if GlobalSetting.maxmind_license_key.blank?
|
||||
STDERR.puts "MaxMind IP database updates require a license"
|
||||
STDERR.puts "Please set DISCOURSE_MAXMIND_LICENSE_KEY to one you generated at https://www.maxmind.com"
|
||||
return
|
||||
end
|
||||
|
||||
FileUtils.mkdir_p(path)
|
||||
|
||||
url = "https://download.maxmind.com/app/geoip_download?license_key=#{GlobalSetting.maxmind_license_key}&edition_id=#{name}&suffix=tar.gz"
|
||||
|
||||
gz_file = FileHelper.download(
|
||||
"https://geolite.maxmind.com/geoip/databases/#{name}/update",
|
||||
url,
|
||||
max_file_size: 100.megabytes,
|
||||
tmp_file_name: "#{name}.gz",
|
||||
validate_uri: false,
|
||||
|
Reference in New Issue
Block a user