reversed 0.3.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: e3b4c985d2b327609a7949bc759185fb4c168c9eeee9d4027d39d100468e9ff1
4
- data.tar.gz: 61413538ab3f1ca493f1704906ac3560dd914eb36facf3560b85d804743ef991
3
+ metadata.gz: dd9f6328cbd5be97594a5bae2f2a48506628cf6fcf17924408442647cccc27e2
4
+ data.tar.gz: 5adcd195cfd69de89460f51c2306058e124f41d5db714a2970cf4ef555bf13c0
5
5
  SHA512:
6
- metadata.gz: 782b5033b06e3ec7ce06f138c4e5c43c68779471553fa187b314c27be9a01931d871b080b1280cd9448293d18cfc299fe4ee437a9c2132a2a7956fb714686582
7
- data.tar.gz: 964caee270849d6671363c1085a36edcc091acdfab250a54f0eebb0697b4ba7d3c058550ccbe8131f4d89f1e2292aef797d1bb84bed50b8def80edeb0e0a6a5c
6
+ metadata.gz: b67e975eee622d55fdd878888e7e1049091f253a50aceb388d9b943bb71d738d13107752b014c07fbb418c67a29b81377ca18cb8732fe6e7758bfeb96c94e34f
7
+ data.tar.gz: 797949b1d5ce6a8535bbe63b28e9f565e887cc205aaf719b81e33f3b6b28f57c1e73404f0a50a3f96f343565d4c3ccc4417423069fd3fbaf765952651b6f3c66
data/CHANGELOG.md CHANGED
@@ -1,20 +1,28 @@
1
- ## 0.3.0
1
+ ## 0.4.1 (2022-12-28)
2
+
3
+ - Added `fallback` option
4
+
5
+ ## 0.4.0 (2022-06-12)
6
+
7
+ - Dropped support for Ruby < 2.7
8
+
9
+ ## 0.3.0 (2019-10-28)
2
10
 
3
11
  - Added support for machines with IPv6 disabled
4
12
  - Raise `ArgumentError` for invalid IP
5
13
 
6
- ## 0.2.1
14
+ ## 0.2.1 (2017-05-08)
7
15
 
8
16
  - Added `timeout` and `nameservers` options
9
17
 
10
- ## 0.2.0
18
+ ## 0.2.0 (2017-01-09)
11
19
 
12
20
  - Removed unnecessary dependency
13
21
 
14
- ## 0.1.1
22
+ ## 0.1.1 (2016-11-14)
15
23
 
16
24
  - Use machine nameservers
17
25
 
18
- ## 0.1.0
26
+ ## 0.1.0 (2016-11-14)
19
27
 
20
28
  - First release
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016-2019 Andrew Kane
1
+ Copyright (c) 2016-2022 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -14,20 +14,14 @@ Reversed.lookup("2a03:2880:2110:df07:face:b00c::1")
14
14
  # "a.ns.facebook.com"
15
15
  ```
16
16
 
17
- [![Build Status](https://travis-ci.org/ankane/reversed.svg?branch=master)](https://travis-ci.org/ankane/reversed)
17
+ [![Build Status](https://github.com/ankane/reversed/workflows/build/badge.svg?branch=master)](https://github.com/ankane/reversed/actions)
18
18
 
19
19
  ## Installation
20
20
 
21
21
  Add this line to your application’s Gemfile:
22
22
 
23
23
  ```ruby
24
- gem 'reversed'
25
- ```
26
-
27
- And then execute:
28
-
29
- ```sh
30
- bundle
24
+ gem "reversed"
31
25
  ```
32
26
 
33
27
  ## Reference
@@ -41,7 +35,13 @@ Reversed.lookup(ip, timeout: 3)
41
35
  Set nameservers
42
36
 
43
37
  ```ruby
44
- Reversed.lookup(ip, nameservers: ["8.8.8.8"])
38
+ Reversed.lookup(ip, nameservers: ["1.1.1.1"])
39
+ ```
40
+
41
+ Disable SOA fallback (only check PTR record) [unreleased]
42
+
43
+ ```ruby
44
+ Reversed.lookup(ip, fallback: false)
45
45
  ```
46
46
 
47
47
  ## History
@@ -57,3 +57,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
57
57
  - Write, clarify, or fix documentation
58
58
  - Suggest or add new features
59
59
 
60
+ To get started with development:
61
+
62
+ ```sh
63
+ git clone https://github.com/ankane/reversed.git
64
+ cd reversed
65
+ bundle install
66
+ bundle exec rake test
67
+ ```
@@ -1,3 +1,3 @@
1
1
  module Reversed
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/reversed.rb CHANGED
@@ -1,9 +1,14 @@
1
- require "reversed/version"
1
+ # dependencies
2
2
  require "net/dns"
3
+
4
+ # stdlib
3
5
  require "ipaddr"
4
6
 
7
+ # modules
8
+ require "reversed/version"
9
+
5
10
  module Reversed
6
- def self.lookup(ip, timeout: 5, nameservers: nil)
11
+ def self.lookup(ip, timeout: 5, nameservers: nil, fallback: true)
7
12
  ip = ip.to_s
8
13
  unless ip.empty?
9
14
  begin
@@ -20,7 +25,10 @@ module Reversed
20
25
  options[:nameservers] = nameservers if nameservers
21
26
  begin
22
27
  resolver = Net::DNS::Resolver.new(options).search(ip.reverse, Net::DNS::PTR)
23
- answer = resolver.answer.first || resolver.authority.first
28
+ answer = resolver.answer.first
29
+ if !answer && fallback
30
+ answer = resolver.authority.first
31
+ end
24
32
  if answer && !answer.value.empty?
25
33
  answer.value.split(" ").first[0..-2]
26
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.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-28 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
@@ -24,50 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
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: '5'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '5'
69
- description:
70
- email: andrew@chartkick.com
27
+ description:
28
+ email: andrew@ankane.org
71
29
  executables: []
72
30
  extensions: []
73
31
  extra_rdoc_files: []
@@ -81,7 +39,7 @@ homepage: https://github.com/ankane/reversed
81
39
  licenses:
82
40
  - MIT
83
41
  metadata: {}
84
- post_install_message:
42
+ post_install_message:
85
43
  rdoc_options: []
86
44
  require_paths:
87
45
  - lib
@@ -89,15 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
47
  requirements:
90
48
  - - ">="
91
49
  - !ruby/object:Gem::Version
92
- version: '2.4'
50
+ version: '2.7'
93
51
  required_rubygems_version: !ruby/object:Gem::Requirement
94
52
  requirements:
95
53
  - - ">="
96
54
  - !ruby/object:Gem::Version
97
55
  version: '0'
98
56
  requirements: []
99
- rubygems_version: 3.0.3
100
- signing_key:
57
+ rubygems_version: 3.4.1
58
+ signing_key:
101
59
  specification_version: 4
102
60
  summary: Reverse DNS / IP Lookup for Ruby
103
61
  test_files: []