Sha256: 27f74fa92bdec3bf84946e3110e41a29a1bb970f7480c8c3bf4273326a5ea61c

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require_relative "base"

module Neetob
  class CLI
    module Cloudflare
      class DnsProxyStatus < Base
        attr_accessor :domain

        def initialize(domain)
          super()
          @domain = domain
        end

        def run
          zone_id = ZONE_IDS[domain.to_sym]
          raise(StandardError, "Domain '#{domain}' not found.") if zone_id.nil?

          url = create_url(zone_id, "dns_records")
          response = get(url)

          unless Thread.current[:audit_mode]
            raise(StandardError, "No DNS records found") if response[:result].empty?
          end

          response[:result].each do |record|
            if record[:proxiable]
              ui.info(
                "DNS proxy is turned #{record[:proxied] ? print_success("on") : print_failure("off")} " \
                                "for #{record[:type]} record #{record[:name]}", print_to_audit_log: false)
            end
          end

          if Thread.current[:audit_mode]
            response[:result].select { |record| record[:proxiable] }
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
neetob-0.5.29 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.28 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.27 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.26 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.25 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.24 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.23 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.22 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.21 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.20 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.19 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.18 lib/neetob/cli/cloudflare/dns_proxy_status.rb
neetob-0.5.17 lib/neetob/cli/cloudflare/dns_proxy_status.rb