reversed 0.2.0 → 0.4.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 +16 -3
- data/LICENSE.txt +22 -0
- data/README.md +28 -5
- data/lib/reversed/version.rb +1 -1
- data/lib/reversed.rb +33 -5
- metadata +13 -59
- 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: 286ce5f0f135e9561569d67b8478230d02ef5a2e27dd2f3d8a591dc9e601db3b
|
4
|
+
data.tar.gz: ca6efcc17b1bb62a89fa8ce3cc24f12a972f6eae5e74ef544d71283f150f0b40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f1bf7e842529f458165545bf5cab3bdfa2b4cbfbfec2666ce2de5c2a0dcc3731116f9f3435e9889b5c73eaa14f7084ab715dd7cabfb0a52353cf1a96ac745bf
|
7
|
+
data.tar.gz: d00ed17e5ce2150078f949fdd8f65f28696e0d3e1cf0d556d94638bed979041d9fe3e3087c617104ebb98934291baf641659149def5d7bab6c3898aea402c31c
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,24 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.4.0 (2022-06-12)
|
2
|
+
|
3
|
+
- Dropped support for Ruby < 2.7
|
4
|
+
|
5
|
+
## 0.3.0 (2019-10-28)
|
6
|
+
|
7
|
+
- Added support for machines with IPv6 disabled
|
8
|
+
- Raise `ArgumentError` for invalid IP
|
9
|
+
|
10
|
+
## 0.2.1 (2017-05-08)
|
11
|
+
|
12
|
+
- Added `timeout` and `nameservers` options
|
13
|
+
|
14
|
+
## 0.2.0 (2017-01-09)
|
2
15
|
|
3
16
|
- Removed unnecessary dependency
|
4
17
|
|
5
|
-
## 0.1.1
|
18
|
+
## 0.1.1 (2016-11-14)
|
6
19
|
|
7
20
|
- Use machine nameservers
|
8
21
|
|
9
|
-
## 0.1.0
|
22
|
+
## 0.1.0 (2016-11-14)
|
10
23
|
|
11
24
|
- First release
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016-2022 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,23 +4,38 @@
|
|
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
|
11
11
|
|
12
|
+
```ruby
|
13
|
+
Reversed.lookup("2a03:2880:2110:df07:face:b00c::1")
|
14
|
+
# "a.ns.facebook.com"
|
15
|
+
```
|
16
|
+
|
17
|
+
[](https://github.com/ankane/reversed/actions)
|
18
|
+
|
12
19
|
## Installation
|
13
20
|
|
14
21
|
Add this line to your application’s Gemfile:
|
15
22
|
|
16
23
|
```ruby
|
17
|
-
gem
|
24
|
+
gem "reversed"
|
18
25
|
```
|
19
26
|
|
20
|
-
|
27
|
+
## Reference
|
21
28
|
|
22
|
-
|
23
|
-
|
29
|
+
Set timeout
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Reversed.lookup(ip, timeout: 3)
|
33
|
+
```
|
34
|
+
|
35
|
+
Set nameservers
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Reversed.lookup(ip, nameservers: ["1.1.1.1"])
|
24
39
|
```
|
25
40
|
|
26
41
|
## History
|
@@ -36,3 +51,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
36
51
|
- Write, clarify, or fix documentation
|
37
52
|
- Suggest or add new features
|
38
53
|
|
54
|
+
To get started with development:
|
55
|
+
|
56
|
+
```sh
|
57
|
+
git clone https://github.com/ankane/reversed.git
|
58
|
+
cd reversed
|
59
|
+
bundle install
|
60
|
+
bundle exec rake test
|
61
|
+
```
|
data/lib/reversed/version.rb
CHANGED
data/lib/reversed.rb
CHANGED
@@ -1,13 +1,41 @@
|
|
1
|
-
|
1
|
+
# dependencies
|
2
2
|
require "net/dns"
|
3
3
|
|
4
|
+
# stdlib
|
5
|
+
require "ipaddr"
|
6
|
+
|
7
|
+
# modules
|
8
|
+
require "reversed/version"
|
9
|
+
|
4
10
|
module Reversed
|
5
|
-
def self.lookup(ip)
|
11
|
+
def self.lookup(ip, timeout: 5, nameservers: nil)
|
6
12
|
ip = ip.to_s
|
7
13
|
unless ip.empty?
|
8
|
-
|
9
|
-
|
10
|
-
|
14
|
+
begin
|
15
|
+
# ensure valid ip
|
16
|
+
ip = IPAddr.new(ip)
|
17
|
+
rescue IPAddr::InvalidAddressError
|
18
|
+
raise ArgumentError, "Invalid IP"
|
19
|
+
end
|
20
|
+
|
21
|
+
options = {
|
22
|
+
retry_number: 3,
|
23
|
+
udp_timeout: timeout
|
24
|
+
}
|
25
|
+
options[:nameservers] = nameservers if nameservers
|
26
|
+
begin
|
27
|
+
resolver = Net::DNS::Resolver.new(options).search(ip.reverse, Net::DNS::PTR)
|
28
|
+
answer = resolver.answer.first || resolver.authority.first
|
29
|
+
if answer && !answer.value.empty?
|
30
|
+
answer.value.split(" ").first[0..-2]
|
31
|
+
end
|
32
|
+
rescue Net::DNS::Resolver::NoResponseError
|
33
|
+
nil
|
34
|
+
rescue Errno::EAFNOSUPPORT
|
35
|
+
options[:use_tcp] = true
|
36
|
+
options[:tcp_timeout] = timeout
|
37
|
+
retry
|
38
|
+
end
|
11
39
|
end
|
12
40
|
end
|
13
41
|
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
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-dns
|
@@ -24,67 +24,22 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
|
28
|
-
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description:
|
70
|
-
email:
|
71
|
-
- andrew@chartkick.com
|
27
|
+
description:
|
28
|
+
email: andrew@ankane.org
|
72
29
|
executables: []
|
73
30
|
extensions: []
|
74
31
|
extra_rdoc_files: []
|
75
32
|
files:
|
76
|
-
- ".gitignore"
|
77
33
|
- CHANGELOG.md
|
78
|
-
-
|
34
|
+
- LICENSE.txt
|
79
35
|
- README.md
|
80
|
-
- Rakefile
|
81
36
|
- lib/reversed.rb
|
82
37
|
- lib/reversed/version.rb
|
83
|
-
- reversed.gemspec
|
84
38
|
homepage: https://github.com/ankane/reversed
|
85
|
-
licenses:
|
39
|
+
licenses:
|
40
|
+
- MIT
|
86
41
|
metadata: {}
|
87
|
-
post_install_message:
|
42
|
+
post_install_message:
|
88
43
|
rdoc_options: []
|
89
44
|
require_paths:
|
90
45
|
- lib
|
@@ -92,16 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
47
|
requirements:
|
93
48
|
- - ">="
|
94
49
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
50
|
+
version: '2.7'
|
96
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
52
|
requirements:
|
98
53
|
- - ">="
|
99
54
|
- !ruby/object:Gem::Version
|
100
55
|
version: '0'
|
101
56
|
requirements: []
|
102
|
-
|
103
|
-
|
104
|
-
signing_key:
|
57
|
+
rubygems_version: 3.3.7
|
58
|
+
signing_key:
|
105
59
|
specification_version: 4
|
106
60
|
summary: Reverse DNS / IP Lookup for Ruby
|
107
61
|
test_files: []
|
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
|