Sha256: 0a52d868d2335f4206d441a7fc8a4eee7e29d110ebeac459d83c220e0e80c557

Contents?: true

Size: 747 Bytes

Versions: 12

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

module Truemail
  module Audit
    class Ip < Truemail::Audit::Base
      GET_MY_IP_URL = 'https://api.ipify.org'
      IPIFY_ERROR = 'impossible to detect current host address via third party service'

      def run
        return add_warning(Truemail::Audit::Ip::IPIFY_ERROR) unless detect_current_host_ip
        Truemail::Audit::Dns.check(result)
        Truemail::Audit::Ptr.check(result)
      end

      private

      def detect_ip_via_ipify
        Net::HTTP.get(URI(Truemail::Audit::Ip::GET_MY_IP_URL))
      end

      def detect_current_host_ip
        result.current_host_ip = Truemail::Wrapper.call(configuration: configuration) do
          detect_ip_via_ipify
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
truemail-2.2.3 lib/truemail/audit/ip.rb
truemail-2.2.2 lib/truemail/audit/ip.rb
truemail-2.2.1 lib/truemail/audit/ip.rb
truemail-2.2.0 lib/truemail/audit/ip.rb
truemail-2.1.0 lib/truemail/audit/ip.rb
truemail-2.0.2 lib/truemail/audit/ip.rb
truemail-2.0.1 lib/truemail/audit/ip.rb
truemail-2.0.0 lib/truemail/audit/ip.rb
truemail-1.9.2 lib/truemail/audit/ip.rb
truemail-1.9.1 lib/truemail/audit/ip.rb
truemail-1.9.0 lib/truemail/audit/ip.rb
truemail-1.8.0 lib/truemail/audit/ip.rb