Sha256: 2d8449722937479088cf62d013af7a2983c3711da60a70701da791fa86056a75
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module GitHubPages module HealthCheck class CDN include Singleton # Internal: The path of the config file. attr_reader :name, :path # Public: Does cloudflare control this address? def self.controls_ip?(address) instance.controls_ip?(address) end # Internal: Create a new CDN info instance. def initialize(options = {}) @name = options.fetch(:name) { self.class.name.split("::").last.downcase } @path = options.fetch(:path) { default_config_path } end # Internal: Does this CDN control this address? def controls_ip?(address) ranges.any? { |range| range.include?(address) } end private # 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 def default_config_path File.expand_path("../../config/#{name}-ips.txt", File.dirname(__FILE__)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
github-pages-health-check-1.3.6 | lib/github-pages-health-check/cdn.rb |
github-pages-health-check-1.4.0 | lib/github-pages-health-check/cdn.rb |