Class: SourceMonitor::Fetching::CloudflareBypass

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/fetching/cloudflare_bypass.rb

Constant Summary collapse

USER_AGENTS =
[
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
  "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15",
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0",
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0"
].freeze
CLOUDFLARE_MARKERS =
FeedFetcher::CLOUDFLARE_MARKERS
SNIFF_LIMIT =
FeedFetcher::SNIFF_LIMIT
DEFAULT_MAX_ATTEMPTS =
2
BYPASS_TIMEOUT =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:, feed_url:, max_attempts: DEFAULT_MAX_ATTEMPTS) ⇒ CloudflareBypass

Returns a new instance of CloudflareBypass.



20
21
22
23
24
# File 'lib/source_monitor/fetching/cloudflare_bypass.rb', line 20

def initialize(response:, feed_url:, max_attempts: DEFAULT_MAX_ATTEMPTS)
  @response = response
  @feed_url = feed_url
  @max_attempts = max_attempts
end

Instance Attribute Details

#feed_urlObject (readonly)

Returns the value of attribute feed_url.



18
19
20
# File 'lib/source_monitor/fetching/cloudflare_bypass.rb', line 18

def feed_url
  @feed_url
end

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



18
19
20
# File 'lib/source_monitor/fetching/cloudflare_bypass.rb', line 18

def max_attempts
  @max_attempts
end

#responseObject (readonly)

Returns the value of attribute response.



18
19
20
# File 'lib/source_monitor/fetching/cloudflare_bypass.rb', line 18

def response
  @response
end

Instance Method Details

#callObject



26
27
28
# File 'lib/source_monitor/fetching/cloudflare_bypass.rb', line 26

def call
  attempt_cookie_replay || attempt_ua_rotation
end