Sha256: f459f34987f09cccaad619033b0b4bbce6a2bfb283ee359fcd8f6d4886f5d59f

Contents?: true

Size: 1014 Bytes

Versions: 49

Compression:

Stored size: 1014 Bytes

Contents

# frozen_string_literal: true

module Truemail
  module Audit
    class Ptr < Truemail::Audit::Base
      PTR_NOT_FOUND = 'PTR-record for current host ip address was not found'
      PTR_NOT_REFER = 'PTR-record does not reference to current verifier domain'

      def run
        return add_warning(Truemail::Audit::Ptr::PTR_NOT_FOUND) if ptr_records.empty?
        return if ptr_refer_to_verifier_domain?
        add_warning(Truemail::Audit::Ptr::PTR_NOT_REFER)
      end

      private

      def current_host_reverse_lookup
        ::IPAddr.new(current_host_ip).reverse
      end

      def ptr_records
        @ptr_records ||= Truemail::Wrapper.call(configuration: configuration) do
          Truemail::Dns::Resolver.ptr_records(
            current_host_reverse_lookup,
            configuration: configuration
          ).map { |ptr_record| ptr_record.name.to_s }
        end || []
      end

      def ptr_refer_to_verifier_domain?
        ptr_records.include?(verifier_domain)
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
truemail-2.4.3 lib/truemail/audit/ptr.rb
truemail-2.4.2 lib/truemail/audit/ptr.rb
truemail-2.4.1 lib/truemail/audit/ptr.rb
truemail-2.4.0 lib/truemail/audit/ptr.rb
truemail-2.3.4 lib/truemail/audit/ptr.rb
truemail-2.3.3 lib/truemail/audit/ptr.rb
truemail-2.3.2 lib/truemail/audit/ptr.rb
truemail-2.3.1 lib/truemail/audit/ptr.rb
truemail-2.3.0 lib/truemail/audit/ptr.rb