Sha256: a2788a53339ccfbf41024e9b3f31598029cb6a220036c8d81609e393ad9ee975
Contents?: true
Size: 997 Bytes
Versions: 16
Compression:
Stored size: 997 Bytes
Contents
class GitHubPages class HealthCheck class CloudFlare include Singleton CONFIG_PATH = File.expand_path("../../config/cloudflare-ips.txt", File.dirname(__FILE__)) # Public: Does cloudflare control this address? def self.controls_ip?(address) instance.controls_ip?(address) end # Internal: Create a new cloudflare info instance. def initialize(options = {}) @path = options.fetch(:path) { CONFIG_PATH } end # Internal: The path of the config file. attr_reader :path # Internal: Does cloudflare control this address? def controls_ip?(address) ranges.any? { |range| range.include?(address) } end # Internal: The IP address ranges that cloudflare controls. def ranges @ranges ||= load_ranges end # Internal: Load IPAddr ranges from #path def load_ranges File.read(path).lines.map { |line| IPAddr.new(line.chomp) } end end end end
Version data entries
16 entries across 16 versions & 1 rubygems