reversed 0.4.0 → 0.4.1

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: 286ce5f0f135e9561569d67b8478230d02ef5a2e27dd2f3d8a591dc9e601db3b
4
- data.tar.gz: ca6efcc17b1bb62a89fa8ce3cc24f12a972f6eae5e74ef544d71283f150f0b40
3
+ metadata.gz: dd9f6328cbd5be97594a5bae2f2a48506628cf6fcf17924408442647cccc27e2
4
+ data.tar.gz: 5adcd195cfd69de89460f51c2306058e124f41d5db714a2970cf4ef555bf13c0
5
5
  SHA512:
6
- metadata.gz: 6f1bf7e842529f458165545bf5cab3bdfa2b4cbfbfec2666ce2de5c2a0dcc3731116f9f3435e9889b5c73eaa14f7084ab715dd7cabfb0a52353cf1a96ac745bf
7
- data.tar.gz: d00ed17e5ce2150078f949fdd8f65f28696e0d3e1cf0d556d94638bed979041d9fe3e3087c617104ebb98934291baf641659149def5d7bab6c3898aea402c31c
6
+ metadata.gz: b67e975eee622d55fdd878888e7e1049091f253a50aceb388d9b943bb71d738d13107752b014c07fbb418c67a29b81377ca18cb8732fe6e7758bfeb96c94e34f
7
+ data.tar.gz: 797949b1d5ce6a8535bbe63b28e9f565e887cc205aaf719b81e33f3b6b28f57c1e73404f0a50a3f96f343565d4c3ccc4417423069fd3fbaf765952651b6f3c66
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.1 (2022-12-28)
2
+
3
+ - Added `fallback` option
4
+
1
5
  ## 0.4.0 (2022-06-12)
2
6
 
3
7
  - Dropped support for Ruby < 2.7
data/README.md CHANGED
@@ -38,6 +38,12 @@ Set nameservers
38
38
  Reversed.lookup(ip, nameservers: ["1.1.1.1"])
39
39
  ```
40
40
 
41
+ Disable SOA fallback (only check PTR record) [unreleased]
42
+
43
+ ```ruby
44
+ Reversed.lookup(ip, fallback: false)
45
+ ```
46
+
41
47
  ## History
42
48
 
43
49
  View the [changelog](https://github.com/ankane/reversed/blob/master/CHANGELOG.md)
@@ -1,3 +1,3 @@
1
1
  module Reversed
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/reversed.rb CHANGED
@@ -8,7 +8,7 @@ require "ipaddr"
8
8
  require "reversed/version"
9
9
 
10
10
  module Reversed
11
- def self.lookup(ip, timeout: 5, nameservers: nil)
11
+ def self.lookup(ip, timeout: 5, nameservers: nil, fallback: true)
12
12
  ip = ip.to_s
13
13
  unless ip.empty?
14
14
  begin
@@ -25,7 +25,10 @@ module Reversed
25
25
  options[:nameservers] = nameservers if nameservers
26
26
  begin
27
27
  resolver = Net::DNS::Resolver.new(options).search(ip.reverse, Net::DNS::PTR)
28
- answer = resolver.answer.first || resolver.authority.first
28
+ answer = resolver.answer.first
29
+ if !answer && fallback
30
+ answer = resolver.authority.first
31
+ end
29
32
  if answer && !answer.value.empty?
30
33
  answer.value.split(" ").first[0..-2]
31
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reversed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-12 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-dns
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  requirements: []
57
- rubygems_version: 3.3.7
57
+ rubygems_version: 3.4.1
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: Reverse DNS / IP Lookup for Ruby