Require users who signup using proxies to verify their email addresses before they can perform any edits. For verification purposes, the email must be a nondisposable address from a whitelist of trusted email providers.
32 lines
787 B
Ruby
32 lines
787 B
Ruby
# API client for https://ipregistry.co/
|
|
|
|
class IpLookup
|
|
extend Memoist
|
|
|
|
attr_reader :ip_addr, :api_key, :cache_duration
|
|
|
|
def self.enabled?
|
|
Danbooru.config.ip_registry_api_key.present?
|
|
end
|
|
|
|
def initialize(ip_addr, api_key: Danbooru.config.ip_registry_api_key, cache_duration: 1.day)
|
|
@ip_addr = ip_addr
|
|
@api_key = api_key
|
|
@cache_duration = cache_duration
|
|
end
|
|
|
|
def info
|
|
return {} unless api_key.present?
|
|
response = Danbooru::Http.cache(cache_duration).get("https://api.ipregistry.co/#{ip_addr}?key=#{api_key}")
|
|
return {} if response.status != 200
|
|
json = response.parse.deep_symbolize_keys.with_indifferent_access
|
|
json
|
|
end
|
|
|
|
def is_proxy?
|
|
info[:security].present? && info[:security].values.any?
|
|
end
|
|
|
|
memoize :info, :is_proxy?
|
|
end
|