class GitHubPages::HealthCheck::CAA

Attributes

error[R]
host[R]
nameservers[R]

Public Class Methods

new(host:, nameservers: :default) click to toggle source
# File lib/github-pages-health-check/caa.rb, line 12
def initialize(host:, nameservers: :default)
  raise ArgumentError, "host cannot be nil" if host.nil?

  @host = host
  @nameservers = nameservers
end

Public Instance Methods

errored?() click to toggle source
# File lib/github-pages-health-check/caa.rb, line 19
def errored?
  records # load the records first
  !error.nil?
end
lets_encrypt_allowed?() click to toggle source
# File lib/github-pages-health-check/caa.rb, line 24
def lets_encrypt_allowed?
  return false if errored?
  return true unless records_present?

  records.any? { |r| r.property_value == "letsencrypt.org" }
end
records() click to toggle source
# File lib/github-pages-health-check/caa.rb, line 37
def records
  return @records if defined?(@records)

  @records = get_caa_records(host)
  @records = get_caa_records(parent_host) if @records.nil? || @records.empty?

  @records
end
records_present?() click to toggle source
# File lib/github-pages-health-check/caa.rb, line 31
def records_present?
  return false if errored?

  records && !records.empty?
end

Private Instance Methods

get_caa_records(domain) click to toggle source
# File lib/github-pages-health-check/caa.rb, line 48
def get_caa_records(domain)
  return [] if domain.nil?

  query(domain).select { |r| issue_caa_record?(r) }
end
issue_caa_record?(record) click to toggle source
# File lib/github-pages-health-check/caa.rb, line 54
def issue_caa_record?(record)
  record.type == Dnsruby::Types::CAA && record.property_tag == "issue"
end
parent_host() click to toggle source
# File lib/github-pages-health-check/caa.rb, line 69
def parent_host
  host.split(".").drop(1).join(".")
end
query(domain) click to toggle source
# File lib/github-pages-health-check/caa.rb, line 58
def query(domain)
  resolver(domain).query(Dnsruby::Types::CAA)
rescue Dnsruby::ResolvError, Dnsruby::ResolvTimeout => e
  @error = e
  []
end
resolver(domain) click to toggle source
# File lib/github-pages-health-check/caa.rb, line 65
def resolver(domain)
  GitHubPages::HealthCheck::Resolver.new(domain, :nameservers => nameservers)
end