ignored user agents
This commit is contained in:
@@ -40,6 +40,8 @@ module WarpEngine
|
||||
end
|
||||
|
||||
def log_download(relative, asset:, ip:, user_agent:, referer:, subject:)
|
||||
return if WarpEngine.config.ignored_user_agent?(user_agent)
|
||||
|
||||
download = WarpEngine::Download.create!(
|
||||
file_path: relative,
|
||||
release: asset&.release,
|
||||
|
||||
@@ -17,7 +17,8 @@ module WarpEngine
|
||||
:subject_resolver,
|
||||
:identity_verification_url,
|
||||
:device_code_ttl,
|
||||
:device_code_interval
|
||||
:device_code_interval,
|
||||
:ignored_user_agents
|
||||
|
||||
def initialize
|
||||
@site_url = nil
|
||||
@@ -37,6 +38,22 @@ module WarpEngine
|
||||
@identity_verification_url = nil
|
||||
@device_code_ttl = 600
|
||||
@device_code_interval = 5
|
||||
@ignored_user_agents = []
|
||||
end
|
||||
|
||||
def ignored_user_agent?(ua)
|
||||
return false if ua.blank?
|
||||
|
||||
@_ignored_ua_patterns ||= Array(@ignored_user_agents).map do |pattern|
|
||||
pattern.is_a?(Regexp) ? pattern : Regexp.new("\\A#{Regexp.escape(pattern).gsub("\\*", ".*")}\\z", Regexp::IGNORECASE)
|
||||
end
|
||||
|
||||
@_ignored_ua_patterns.any? { |re| re.match?(ua) }
|
||||
end
|
||||
|
||||
def ignored_user_agents=(value)
|
||||
@ignored_user_agents = value
|
||||
@_ignored_ua_patterns = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module WarpEngine
|
||||
VERSION = "0.8.0"
|
||||
VERSION = "0.9.0"
|
||||
|
||||
VERSION_HEADER = "WarpEngine-Version".freeze
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user