truemail 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f597eb293f10835d12b766da633b9d1808424760924a89472416729e60241c23
4
- data.tar.gz: a4fe4b473856a44d312bfb15fdd831a412d5764fedc33274f5923b75b59b5ce0
3
+ metadata.gz: 232ed298a07a579faf90cacc3026134e5ddf7115341df4f337c1108d262e284a
4
+ data.tar.gz: 997c3a81c6fcf3faa2e797fcd9047970a7a39f66551252529aaaa3a4ea978428
5
5
  SHA512:
6
- metadata.gz: dd936cd55b94200bb344d78236527f31cb298e2a453ca660f4d825ba0538c9d6057e730b975319f68130fe64d847cdacb7937a4dbb0344f3ceaf43efb7f3b7b0
7
- data.tar.gz: 3d8814c197319adb5fb8e9fb2e1c5b5d46dee8adb3bab204199d98b78137b9cbdf8ca28873405b65af8c570ff499a93981851a2bd5e962f1c5910c9303c00125
6
+ metadata.gz: ffa32874a430e4af6a04828744f0d5c9f1adc7d9f5a58de547c62666ecc639c7b4af2a1979368a2e1264196e391dfbfe1df33ab2fa42efef39d13447ed94c571
7
+ data.tar.gz: 1546da1c4106c114a0eb3180ad4361749b5334ca5c791a5f11b6f98aabffa3a4a52f57c52666b82972b7e2a75529c781ff22430180c6c8c529cf2f2a0f7450ae
data/.reek.yml CHANGED
@@ -29,7 +29,7 @@ detectors:
29
29
  - Truemail::Validator#select_validation_type
30
30
  - Truemail::Validate::Mx#null_mx?
31
31
  - Truemail::Validate::Mx#a_record
32
- - Truemail::Audit::Ptr#current_host_address
32
+ - Truemail::Audit::Base#verifier_domain
33
33
 
34
34
  ControlParameter:
35
35
  exclude:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truemail (0.1.7)
4
+ truemail (0.1.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,6 +8,10 @@ module Truemail
8
8
  def add_warning(message)
9
9
  result.warnings[self.class.name.split('::').last.downcase.to_sym] = message
10
10
  end
11
+
12
+ def verifier_domain
13
+ Truemail.configuration.verifier_domain
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -6,23 +6,32 @@ module Truemail
6
6
  require 'ipaddr'
7
7
  require 'resolv'
8
8
 
9
- NOT_FOUND = 'ptr record for current host address was not found'
10
- NOT_REFERENCES = 'ptr record does not reference to current verifier domain'
9
+ GET_MY_IP_URL = 'https://api.ipify.org'
10
+ IPIFY_ERROR = 'impossible to detect current host address via third party service'
11
+ PTR_NOT_FOUND = 'ptr record for current host address was not found'
12
+ PTR_NOT_REFER = 'ptr record does not reference to current verifier domain'
13
+ VERIFIER_DOMAIN_NOT_REFER = ''
11
14
 
12
15
  def run
13
- return if ptr_records.empty? && add_warning(Truemail::Audit::Ptr::NOT_FOUND)
14
- return if ptr_references_to_verifier_domain?
15
- add_warning(Truemail::Audit::Ptr::NOT_REFERENCES)
16
+ return if !current_host_address && add_warning(Truemail::Audit::Ptr::IPIFY_ERROR)
17
+ return if ptr_records.empty? && add_warning(Truemail::Audit::Ptr::PTR_NOT_FOUND)
18
+ return if ptr_not_refer_to_verifier_domain? && add_warning(Truemail::Audit::Ptr::PTR_NOT_REFER)
19
+ return if verifier_domain_refer_to_current_host_address?
20
+ add_warning(Truemail::Audit::Ptr::VERIFIER_DOMAIN_NOT_REFER)
16
21
  end
17
22
 
18
23
  private
19
24
 
25
+ def detect_ip_via_ipify
26
+ Net::HTTP.get(URI(Truemail::Audit::Ptr::GET_MY_IP_URL))
27
+ end
28
+
20
29
  def current_host_address
21
- Resolv.getaddress(Socket.gethostname)
30
+ @current_host_address ||= Truemail::Wrapper.call { IPAddr.new(detect_ip_via_ipify) }
22
31
  end
23
32
 
24
33
  def current_host_reverse_lookup
25
- IPAddr.new(current_host_address).reverse
34
+ current_host_address.reverse
26
35
  end
27
36
 
28
37
  def ptr_records
@@ -33,8 +42,16 @@ module Truemail
33
42
  end || []
34
43
  end
35
44
 
36
- def ptr_references_to_verifier_domain?
37
- ptr_records.include?(Truemail.configuration.verifier_domain)
45
+ def ptr_not_refer_to_verifier_domain?
46
+ !ptr_records.include?(verifier_domain)
47
+ end
48
+
49
+ def a_record
50
+ Truemail::Wrapper.call { Resolv::DNS.new.getaddress(verifier_domain).to_s }
51
+ end
52
+
53
+ def verifier_domain_refer_to_current_host_address?
54
+ a_record == current_host_address.to_s
38
55
  end
39
56
  end
40
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Truemail
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.8'
5
5
  end
@@ -14,7 +14,7 @@ module Truemail
14
14
 
15
15
  def call(&block)
16
16
  Timeout.timeout(Truemail.configuration.connection_timeout, &block)
17
- rescue Resolv::ResolvError
17
+ rescue Resolv::ResolvError, IPAddr::InvalidAddressError
18
18
  false
19
19
  rescue Timeout::Error
20
20
  retry unless (self.attempts -= 1).zero?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truemail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-17 00:00:00.000000000 Z
11
+ date: 2019-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.7.8
232
+ rubygems_version: 2.7.9
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: truemail