ignored user agents
This commit is contained in:
@@ -40,6 +40,8 @@ module WarpEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def log_download(relative, asset:, ip:, user_agent:, referer:, subject:)
|
def log_download(relative, asset:, ip:, user_agent:, referer:, subject:)
|
||||||
|
return if WarpEngine.config.ignored_user_agent?(user_agent)
|
||||||
|
|
||||||
download = WarpEngine::Download.create!(
|
download = WarpEngine::Download.create!(
|
||||||
file_path: relative,
|
file_path: relative,
|
||||||
release: asset&.release,
|
release: asset&.release,
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ module WarpEngine
|
|||||||
:subject_resolver,
|
:subject_resolver,
|
||||||
:identity_verification_url,
|
:identity_verification_url,
|
||||||
:device_code_ttl,
|
:device_code_ttl,
|
||||||
:device_code_interval
|
:device_code_interval,
|
||||||
|
:ignored_user_agents
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@site_url = nil
|
@site_url = nil
|
||||||
@@ -37,6 +38,22 @@ module WarpEngine
|
|||||||
@identity_verification_url = nil
|
@identity_verification_url = nil
|
||||||
@device_code_ttl = 600
|
@device_code_ttl = 600
|
||||||
@device_code_interval = 5
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module WarpEngine
|
module WarpEngine
|
||||||
VERSION = "0.8.0"
|
VERSION = "0.9.0"
|
||||||
|
|
||||||
VERSION_HEADER = "WarpEngine-Version".freeze
|
VERSION_HEADER = "WarpEngine-Version".freeze
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user