reversed 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +17 -1
- data/lib/reversed.rb +14 -2
- data/lib/reversed/version.rb +1 -1
- metadata +11 -15
- data/.gitignore +0 -9
- data/Gemfile +0 -4
- data/Rakefile +0 -11
- data/reversed.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e3b4c985d2b327609a7949bc759185fb4c168c9eeee9d4027d39d100468e9ff1
|
4
|
+
data.tar.gz: 61413538ab3f1ca493f1704906ac3560dd914eb36facf3560b85d804743ef991
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 782b5033b06e3ec7ce06f138c4e5c43c68779471553fa187b314c27be9a01931d871b080b1280cd9448293d18cfc299fe4ee437a9c2132a2a7956fb714686582
|
7
|
+
data.tar.gz: 964caee270849d6671363c1085a36edcc091acdfab250a54f0eebb0697b4ba7d3c058550ccbe8131f4d89f1e2292aef797d1bb84bed50b8def80edeb0e0a6a5c
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016-2019 Andrew Kane
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
Reversed.lookup("8.8.4.4")
|
7
|
-
# "
|
7
|
+
# "dns.google"
|
8
8
|
```
|
9
9
|
|
10
10
|
Works with IPv4 and IPv6
|
@@ -14,6 +14,8 @@ Reversed.lookup("2a03:2880:2110:df07:face:b00c::1")
|
|
14
14
|
# "a.ns.facebook.com"
|
15
15
|
```
|
16
16
|
|
17
|
+
[](https://travis-ci.org/ankane/reversed)
|
18
|
+
|
17
19
|
## Installation
|
18
20
|
|
19
21
|
Add this line to your application’s Gemfile:
|
@@ -28,6 +30,20 @@ And then execute:
|
|
28
30
|
bundle
|
29
31
|
```
|
30
32
|
|
33
|
+
## Reference
|
34
|
+
|
35
|
+
Set timeout
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Reversed.lookup(ip, timeout: 3)
|
39
|
+
```
|
40
|
+
|
41
|
+
Set nameservers
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Reversed.lookup(ip, nameservers: ["8.8.8.8"])
|
45
|
+
```
|
46
|
+
|
31
47
|
## History
|
32
48
|
|
33
49
|
View the [changelog](https://github.com/ankane/reversed/blob/master/CHANGELOG.md)
|
data/lib/reversed.rb
CHANGED
@@ -1,23 +1,35 @@
|
|
1
1
|
require "reversed/version"
|
2
2
|
require "net/dns"
|
3
|
+
require "ipaddr"
|
3
4
|
|
4
5
|
module Reversed
|
5
6
|
def self.lookup(ip, timeout: 5, nameservers: nil)
|
6
7
|
ip = ip.to_s
|
7
8
|
unless ip.empty?
|
9
|
+
begin
|
10
|
+
# ensure valid ip
|
11
|
+
ip = IPAddr.new(ip)
|
12
|
+
rescue IPAddr::InvalidAddressError
|
13
|
+
raise ArgumentError, "Invalid IP"
|
14
|
+
end
|
15
|
+
|
8
16
|
options = {
|
9
|
-
|
17
|
+
retry_number: 3,
|
10
18
|
udp_timeout: timeout
|
11
19
|
}
|
12
20
|
options[:nameservers] = nameservers if nameservers
|
13
21
|
begin
|
14
|
-
resolver = Net::DNS::Resolver.new(options).search(ip)
|
22
|
+
resolver = Net::DNS::Resolver.new(options).search(ip.reverse, Net::DNS::PTR)
|
15
23
|
answer = resolver.answer.first || resolver.authority.first
|
16
24
|
if answer && !answer.value.empty?
|
17
25
|
answer.value.split(" ").first[0..-2]
|
18
26
|
end
|
19
27
|
rescue Net::DNS::Resolver::NoResponseError
|
20
28
|
nil
|
29
|
+
rescue Errno::EAFNOSUPPORT
|
30
|
+
options[:use_tcp] = true
|
31
|
+
options[:tcp_timeout] = timeout
|
32
|
+
retry
|
21
33
|
end
|
22
34
|
end
|
23
35
|
end
|
data/lib/reversed/version.rb
CHANGED
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
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-dns
|
@@ -58,31 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '5'
|
69
69
|
description:
|
70
|
-
email:
|
71
|
-
- andrew@chartkick.com
|
70
|
+
email: andrew@chartkick.com
|
72
71
|
executables: []
|
73
72
|
extensions: []
|
74
73
|
extra_rdoc_files: []
|
75
74
|
files:
|
76
|
-
- ".gitignore"
|
77
75
|
- CHANGELOG.md
|
78
|
-
-
|
76
|
+
- LICENSE.txt
|
79
77
|
- README.md
|
80
|
-
- Rakefile
|
81
78
|
- lib/reversed.rb
|
82
79
|
- lib/reversed/version.rb
|
83
|
-
- reversed.gemspec
|
84
80
|
homepage: https://github.com/ankane/reversed
|
85
|
-
licenses:
|
81
|
+
licenses:
|
82
|
+
- MIT
|
86
83
|
metadata: {}
|
87
84
|
post_install_message:
|
88
85
|
rdoc_options: []
|
@@ -92,15 +89,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
89
|
requirements:
|
93
90
|
- - ">="
|
94
91
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
92
|
+
version: '2.4'
|
96
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
94
|
requirements:
|
98
95
|
- - ">="
|
99
96
|
- !ruby/object:Gem::Version
|
100
97
|
version: '0'
|
101
98
|
requirements: []
|
102
|
-
|
103
|
-
rubygems_version: 2.6.11
|
99
|
+
rubygems_version: 3.0.3
|
104
100
|
signing_key:
|
105
101
|
specification_version: 4
|
106
102
|
summary: Reverse DNS / IP Lookup for Ruby
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/reversed.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "reversed/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "reversed"
|
7
|
-
spec.version = Reversed::VERSION
|
8
|
-
spec.authors = ["Andrew Kane"]
|
9
|
-
spec.email = ["andrew@chartkick.com"]
|
10
|
-
|
11
|
-
spec.summary = "Reverse DNS / IP Lookup for Ruby"
|
12
|
-
spec.homepage = "https://github.com/ankane/reversed"
|
13
|
-
|
14
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
-
spec.bindir = "exe"
|
16
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
-
spec.require_paths = ["lib"]
|
18
|
-
|
19
|
-
spec.add_dependency "net-dns"
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "minitest"
|
24
|
-
end
|