class GitHubPages::HealthCheck::CDN

Attributes

name[R]

Internal: The path of the config file.

path[R]

Internal: The path of the config file.

Public Class Methods

controls_ip?(address) click to toggle source

Public: Does cloudflare control this address?

# File lib/github-pages-health-check/cdn.rb, line 12
def self.controls_ip?(address)
  instance.controls_ip?(address)
end
new(options = {}) click to toggle source

Internal: Create a new CDN info instance.

# File lib/github-pages-health-check/cdn.rb, line 17
def initialize(options = {})
  @name = options.fetch(:name) { self.class.name.split("::").last.downcase }
  @path = options.fetch(:path) { default_config_path }
end

Public Instance Methods

controls_ip?(address) click to toggle source

Internal: Does this CDN control this address?

# File lib/github-pages-health-check/cdn.rb, line 23
def controls_ip?(address)
  ranges.any? { |range| range.include?(address.to_s) }
end

Private Instance Methods

default_config_path() click to toggle source
# File lib/github-pages-health-check/cdn.rb, line 39
def default_config_path
  File.expand_path("../../config/#{name}-ips.txt", File.dirname(__FILE__))
end
load_ranges() click to toggle source

Internal: Load IPAddr ranges from path

# File lib/github-pages-health-check/cdn.rb, line 35
def load_ranges
  File.read(path).lines.map { |line| IPAddr.new(line.chomp) }
end
ranges() click to toggle source

Internal: The IP address ranges that cloudflare controls.

# File lib/github-pages-health-check/cdn.rb, line 30
def ranges
  @ranges ||= load_ranges
end