reversed 0.2.0 → 0.2.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
  SHA1:
3
- metadata.gz: 7f68b9bdb55dc7644951970c62f8deaec3438e73
4
- data.tar.gz: 42a3eca12663b9822ff74be891f2a00cf0b96fa4
3
+ metadata.gz: e2a0f5332c4c10206b8d14fc18a84d8faf2469fd
4
+ data.tar.gz: e2845ea93f46a5cee9321874b8be2f712c6171a0
5
5
  SHA512:
6
- metadata.gz: c95592f062bd35a0f28e82e11788884f82b25442c933e9d4a9e3068581a03c877aa66601d7ad3c861ce7ddb7cf5d474a49d06f276deb78be07fd60975caaa755
7
- data.tar.gz: 60a48b1e7c38581c78394cecd379f0c331ddd54626a3d3ae49320dc64cc4064da34cd2070c61709ef24632df9337d1afc081504aaea428c61b044920891ded6f
6
+ metadata.gz: fbb064aded74596ddb6c2520a381ec28de82abf3b56fc91f640bed215ca0f2c7d1fcd6219dfedf48d622987749e0e91abef7966dc44691dc534f13e0afd421be
7
+ data.tar.gz: 81c4f5a32c44a2613401bb8fefc6a8f029959e784fb597d91dc0d4cee3705cc00157f8e17f8785a73cf2095b08bbfc1eb26f0ce97fafa5f0b3bf60f9e20dd58b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.1
2
+
3
+ - Added `timeout` and `nameservers` options
4
+
1
5
  ## 0.2.0
2
6
 
3
7
  - Removed unnecessary dependency
data/README.md CHANGED
@@ -9,6 +9,11 @@ Reversed.lookup("8.8.4.4")
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
+
12
17
  ## Installation
13
18
 
14
19
  Add this line to your application’s Gemfile:
data/lib/reversed.rb CHANGED
@@ -2,12 +2,23 @@ require "reversed/version"
2
2
  require "net/dns"
3
3
 
4
4
  module Reversed
5
- def self.lookup(ip)
5
+ def self.lookup(ip, timeout: 5, nameservers: nil)
6
6
  ip = ip.to_s
7
7
  unless ip.empty?
8
- resolver = Net::DNS::Resolver.new(retry: 3).search(ip)
9
- answer = resolver.answer.first || resolver.authority.first
10
- answer.value.split(" ").first[0..-2] if answer
8
+ options = {
9
+ retry: 3,
10
+ udp_timeout: timeout
11
+ }
12
+ options[:nameservers] = nameservers if nameservers
13
+ begin
14
+ resolver = Net::DNS::Resolver.new(options).search(ip)
15
+ answer = resolver.answer.first || resolver.authority.first
16
+ if answer && !answer.value.empty?
17
+ answer.value.split(" ").first[0..-2]
18
+ end
19
+ rescue Net::DNS::Resolver::NoResponseError
20
+ nil
21
+ end
11
22
  end
12
23
  end
13
24
  end
@@ -1,3 +1,3 @@
1
1
  module Reversed
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-dns
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.6.8
103
+ rubygems_version: 2.6.11
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Reverse DNS / IP Lookup for Ruby