reversed 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +6 -0
- data/lib/reversed/version.rb +1 -1
- data/lib/reversed.rb +13 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b38ef6ac048b44ecefdebe3a9eeae19cb76d2cdad5d03535e175da267c03eb3
|
4
|
+
data.tar.gz: b341d25f2d60f239bdc4c8b01e9415d9f862790acbd41e4ff55720dc21d0cc80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2feaa96527df5e165c87642ff1a4b74e8713d1cc2f6ebbc1d9bdf0c20cc26c17d2684383c9ee6d22a76011ff3fd805591b629124860cf861a2f980dbe74be15
|
7
|
+
data.tar.gz: 602179691e1db8288df87c0ae650b2d24786df7e698ad281ec8cfe8c4170423bb1baf495d6db857cd52e78c2e0363399dd25b8c8bcb61dfc91e6ec7bc7e08e4f
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
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)
|
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)
|
data/lib/reversed/version.rb
CHANGED
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
|
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
|
@@ -39,3 +42,11 @@ module Reversed
|
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
45
|
+
|
46
|
+
# not ideal, but fixes error on timeout with Ruby 3.1+
|
47
|
+
# (which removed TimeoutError)
|
48
|
+
# need to define rather than rescue NameError
|
49
|
+
# to allow for multiple nameservers to be checked
|
50
|
+
# define here rather than for duration of search method for thread-safety
|
51
|
+
# apply to all Ruby versions to fix deprecation warnings
|
52
|
+
Net::DNS::Resolver::TimeoutError = Timeout::Error
|
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.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-11 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.
|
57
|
+
rubygems_version: 3.4.1
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Reverse DNS / IP Lookup for Ruby
|