net-dns 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +8 -2
- data/CHANGELOG.md +48 -35
- data/{README.rdoc → README.md} +44 -51
- data/Rakefile +1 -1
- data/fixtures/resolv.conf +4 -0
- data/lib/net/dns/header.rb +41 -69
- data/lib/net/dns/resolver.rb +10 -3
- data/lib/net/dns/version.rb +2 -2
- data/net-dns.gemspec +8 -8
- data/test/header_test.rb +0 -3
- data/test/resolver_test.rb +9 -0
- metadata +9 -15
- data/setup.rb +0 -1361
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODAwMGQ4ODMyYTIyZmNkN2NlNjIwMDk3Y2Y0ODNmYmZkODY0NmE4NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTAzODI5MjhmZWNmZDZmOWEyM2UyMDBkZDRmNmQxY2E4MDE0YjYxYw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzMzY2RhYjJlNTcyNTllMzQ4ODdlYjkzNjViY2QyNDg4ZTQxNDJhNjA0MDM1
|
10
|
+
OThjMGZjY2EwMmY2ZTNjYTM0NGRmMDM2YzcwMDk0Yzg2MGVjYzNiODYzZDhj
|
11
|
+
M2JjNzExN2FkMTdlMzg5MGE1ZWIyMWJlOTQzMTBmMzYxOTAwYjk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDRiZjIyY2UxZTMxMjYxZDM3MjhlYjFiNDAxNDhmNWEwMDRmODNiYjg3MmY3
|
14
|
+
MzQxNWU4ZTlhMGE1ZDQ0MGYzNzBmMTU4YzVkYjc4ZjJlYmQ1NmY0OTE3ZDQ5
|
15
|
+
ZjkwYTNiZmM5ODBlMjM1MWU0Y2I5MmU4ZmI4NWJmNmEzMzRiNTQ=
|
data/.travis.yml
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
rvm:
|
3
4
|
- 1.8.7
|
4
5
|
- 1.9.2
|
5
6
|
- 1.9.3
|
7
|
+
- 2.0.0
|
6
8
|
# - jruby-18mode
|
7
9
|
# - jruby-19mode
|
8
10
|
- rbx-18mode
|
9
11
|
# - ruby-head
|
10
12
|
# - jruby-head
|
11
|
-
|
13
|
+
|
12
14
|
notifications:
|
13
15
|
recipients:
|
14
|
-
- weppos@weppos.net
|
16
|
+
- weppos@weppos.net
|
17
|
+
|
18
|
+
matrix:
|
19
|
+
allow_failures:
|
20
|
+
- rvm: 2.0.0
|
data/CHANGELOG.md
CHANGED
@@ -1,84 +1,97 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
3
|
|
4
|
+
## master
|
5
|
+
|
6
|
+
- FIXED: undefined local variable or method `source_address_inet6' (GH-40). [Thanks @simsicon]
|
7
|
+
|
8
|
+
- FIXED: Fixed bug on parsing multiple nameservers on different lines (GH-45). [Thanks @nicholasren]
|
9
|
+
|
10
|
+
- CHANGED: Dropped duplicate query ID filter. Query ID is now randomically generated but it's not guaranteed to be unique (GH-39). [Thanks @ebroder]
|
11
|
+
|
12
|
+
- CHANGED: require 'net/dns' is now the preferred way to load the library (GH-37). [Thanks @johnroa]
|
13
|
+
|
14
|
+
- CHANGED: Removed setup.rb installation script.
|
15
|
+
|
16
|
+
|
4
17
|
## Release 0.7.1
|
5
18
|
|
6
|
-
|
19
|
+
- FIXED: Invalid file permissions on several files (GH-35) [Thanks @jamespharaoh]
|
7
20
|
|
8
21
|
|
9
22
|
## Release 0.7.0
|
10
23
|
|
11
|
-
|
24
|
+
- ADDED: Added (experimental) Support for HINFO record.
|
12
25
|
|
13
|
-
|
26
|
+
- FIXED: Use Net::DNS::Resolver::Error class (not ResolverError, which does not exist).
|
14
27
|
|
15
|
-
|
28
|
+
- FIXED: Cleaned up require dependency and recursive require statements.
|
16
29
|
|
17
|
-
|
30
|
+
- FIXED: Use RbConfig instead of obsolete and deprecated Config (GH-28, GH-33) [Thanks @shadowbq, @eik3]
|
18
31
|
|
19
|
-
|
32
|
+
- FIXED: SRV record not required by Net::DNS::RR (GH-27) [Thanks @sebastian]
|
20
33
|
|
21
|
-
|
34
|
+
- FIXED: Resolver now supports IPv6 (GH-32) [Thanks @jamesotron]
|
22
35
|
|
23
|
-
|
36
|
+
- FIXED: Net::DNS::RR::PTR references an invalid parameter (GH-19) [Thanks @dd23]
|
24
37
|
|
25
|
-
|
38
|
+
- FIXED: Net::DNS::Question changes input arguments (GH-7) [Thanks @gfarfl]
|
26
39
|
|
27
|
-
|
40
|
+
- CHANGED: Refactoring unit test to follow most used Ruby conventions.
|
28
41
|
|
29
|
-
|
42
|
+
- CHANGED: Rewritten and simplified Net::DNS::Classes. Improved test harness.
|
30
43
|
|
31
|
-
|
44
|
+
- CHANGED: Removed Jeweler development dependency.
|
32
45
|
|
33
|
-
|
46
|
+
- CHANGED: The library is now compatible with Bundler.
|
34
47
|
|
35
|
-
|
48
|
+
- CHANGED: Minimum supported Ruby version changed to Ruby 1.8.7.
|
36
49
|
|
37
|
-
|
50
|
+
- CHANGED: Rescue NameError so unsupported record types only result in a warning.
|
38
51
|
|
39
|
-
|
52
|
+
- CHANGED: Renamed Net::DNS::Resolver#send to Net::DNS::Resolver#query to avoid overriding default meaning of send method.
|
40
53
|
|
41
54
|
|
42
55
|
## Release 0.6.1
|
43
56
|
|
44
|
-
|
57
|
+
- ADDED: Net::DNS::Packet#to_s method (alias of #inspect)
|
45
58
|
|
46
|
-
|
59
|
+
- FIXED: typo in lib/net/dns/rr/ptr.rb [Thanks Chris Lundquist]
|
47
60
|
|
48
|
-
|
61
|
+
- FIXED: warning: method redefined; discarding old inspect (GH-3) [Thanks Kevin Baker]
|
49
62
|
|
50
|
-
|
63
|
+
- FIXED: issue with rescue ArgumentError (GH-5) and with IPAddr handling (GH-6)
|
51
64
|
|
52
65
|
|
53
66
|
## Release 0.6.0
|
54
67
|
|
55
|
-
*WARNING
|
68
|
+
*WARNING:- If you are upgrading from a previous minor release, check out the Compatibility issue list below.
|
56
69
|
|
57
|
-
|
70
|
+
- FIXED: Added missing #to_s method to Net::DNS::Question.
|
58
71
|
|
59
|
-
|
72
|
+
- FIXED: Compatibility with Ruby 1.9
|
60
73
|
|
61
|
-
|
74
|
+
- FIXED: Types regexp order issue
|
62
75
|
|
63
|
-
|
76
|
+
- CHANGED: Refactoring unit test to follow most used Ruby conventions
|
64
77
|
|
65
|
-
|
78
|
+
- CHANGED: default timeout is now 5 seconds for both UDP and TCP
|
66
79
|
|
67
|
-
|
80
|
+
- CHANGED: Moved main dns.rb file to lib/net folder as default for GEMs. In this way it can be autoloaded when the gem is required.
|
68
81
|
|
69
82
|
### Compatibility issues
|
70
83
|
|
71
|
-
|
84
|
+
- CHANGED: RR#set_stype scope is now private to prevent invalid usage.
|
72
85
|
|
73
|
-
|
86
|
+
- CHANGED: DnsTimeout#timeout now raises LocalJumpError instead of DnsTimeoutArgumentError when block is missing.
|
74
87
|
|
75
|
-
|
88
|
+
- CHANGED: Renamed Net::DNS::RR::Types::Types to Net::DNS::RR::Types::TYPES to follow Ruby coding standards.
|
76
89
|
|
77
90
|
|
78
91
|
## Release 0.4
|
79
92
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
93
|
+
- many bug fixes (thanks guys!)
|
94
|
+
- a whole new class Net::DNS::Header::RCode
|
95
|
+
- new methods in Net::DNS::Resolver class to do AXFR queries
|
96
|
+
- a new SRV resource record written by Dan Janowski
|
97
|
+
- more documentation written and corrected
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,48 +1,40 @@
|
|
1
|
-
|
1
|
+
# Net::DNS
|
2
2
|
|
3
3
|
Net::DNS is a DNS library written in pure Ruby. It started as a port of Perl Net::DNS module, but it evolved in time into a full Ruby library.
|
4
4
|
|
5
5
|
|
6
|
-
|
6
|
+
## Features
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
- Complete OO interface
|
9
|
+
- Clean and intuitive API
|
10
|
+
- Modular and flexible
|
11
11
|
|
12
12
|
|
13
|
-
|
13
|
+
## Requirements
|
14
14
|
|
15
|
-
* Ruby >= 1.8.
|
15
|
+
* Ruby >= 1.8.7
|
16
16
|
|
17
|
-
As of release TODO, Net::DNS is compatible with Ruby 1.9.1.
|
18
17
|
|
18
|
+
## Installation
|
19
19
|
|
20
|
-
|
20
|
+
The best way to install this library is via [RubyGems](https://rubygems.org/).
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
$ gem install net-dns
|
22
|
+
$ gem install net-dns
|
25
23
|
|
26
|
-
|
24
|
+
You might need administrator privileges on your system to install the gem.
|
27
25
|
|
28
|
-
$ rake install
|
29
26
|
|
30
|
-
|
27
|
+
## API Documentation
|
31
28
|
|
32
|
-
|
29
|
+
Visit the page http://rdoc.info/gems/net-dns
|
33
30
|
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
Visit the page http://marcoceresa.com/net-dns
|
38
|
-
|
39
|
-
|
40
|
-
== Trivial resolver
|
32
|
+
## Trivial resolver
|
41
33
|
|
42
34
|
The simplest way to use the library is to invoke the Resolver() method:
|
43
35
|
|
44
36
|
require 'rubygems'
|
45
|
-
require 'net/dns
|
37
|
+
require 'net/dns'
|
46
38
|
p Resolver("www.google.com")
|
47
39
|
|
48
40
|
The output is compatible with BIND zone files and it's the same you would get with the dig utility.
|
@@ -75,39 +67,39 @@ The output is compatible with BIND zone files and it's the same you would get wi
|
|
75
67
|
ns3.google.com. 170275 IN A 216.239.36.10
|
76
68
|
ns4.google.com. 170275 IN A 216.239.38.10
|
77
69
|
|
78
|
-
|
79
70
|
An optional block can be passed yielding the Net::DNS::Packet object
|
80
71
|
|
81
|
-
|
82
|
-
|
72
|
+
Resolver("www.google.com") { |packet| puts packet.size + " bytes" }
|
73
|
+
# => 484 bytes
|
83
74
|
|
84
75
|
Same for Net::DNS::Resolver.start():
|
85
76
|
|
86
77
|
Net::DNS::Resolver.start("google.com").answer.size
|
87
|
-
|
78
|
+
# => 5
|
88
79
|
|
89
80
|
As optional parameters, +TYPE+ and +CLASS+ can be specified.
|
90
81
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
82
|
+
p Net::DNS::Resolver.start("google.com", Net::DNS::MX)
|
83
|
+
|
84
|
+
;; Answer received from localhost:53 (316 bytes)
|
85
|
+
;;
|
86
|
+
;; HEADER SECTION
|
87
|
+
;; id = 59980
|
88
|
+
;; qr = 1 opCode: QUERY aa = 0 tc = 0 rd = 1
|
89
|
+
;; ra = 1 ad = 0 cd = 0 rcode = NoError
|
90
|
+
;; qdCount = 1 anCount = 4 nsCount = 4 arCount = 8
|
91
|
+
|
92
|
+
;; QUESTION SECTION (1 record):
|
93
|
+
;; google.com. IN MX
|
94
|
+
|
95
|
+
;; ANSWER SECTION (4 records):
|
96
|
+
google.com. 10800 IN MX 10 smtp2.google.com.
|
97
|
+
google.com. 10800 IN MX 10 smtp3.google.com.
|
98
|
+
google.com. 10800 IN MX 10 smtp4.google.com.
|
99
|
+
google.com. 10800 IN MX 10 smtp1.google.com.
|
100
|
+
|
101
|
+
|
102
|
+
## Handling the response packet
|
111
103
|
|
112
104
|
The method Net::DNS::Resolver.start is a wrapper around Resolver.new. It returns a new Net::DNS::Packet object.
|
113
105
|
|
@@ -150,13 +142,14 @@ Gives:
|
|
150
142
|
74.125.45.100 is alive
|
151
143
|
74.125.67.100 is alive
|
152
144
|
209.85.171.100 is alive
|
153
|
-
|
154
145
|
|
155
|
-
|
146
|
+
|
147
|
+
## License
|
156
148
|
|
157
149
|
Net::DNS is distributed under the same license Ruby is.
|
158
150
|
|
159
151
|
|
160
|
-
|
152
|
+
## Authors
|
161
153
|
|
162
|
-
|
154
|
+
- Marco Ceresa (@bluemonk)
|
155
|
+
- Simone Carletti (@weppos)
|
data/Rakefile
CHANGED
@@ -27,7 +27,7 @@ spec = Gem::Specification.new do |s|
|
|
27
27
|
s.homepage = "http://github.com/bluemonk/net-dns"
|
28
28
|
s.rubyforge_project = "net-dns"
|
29
29
|
|
30
|
-
s.add_development_dependency "rake", "~> 0
|
30
|
+
s.add_development_dependency "rake", "~> 10.0"
|
31
31
|
s.add_development_dependency "yard"
|
32
32
|
|
33
33
|
s.files = `git ls-files`.split("\n")
|
data/lib/net/dns/header.rb
CHANGED
@@ -1,41 +1,32 @@
|
|
1
1
|
module Net
|
2
2
|
module DNS
|
3
3
|
|
4
|
-
#
|
5
|
-
# =Name
|
6
|
-
#
|
7
|
-
# Net::DNS::Header - DNS packet header class
|
8
|
-
#
|
9
|
-
# =Synopsis
|
10
|
-
#
|
11
|
-
# require 'net/dns/header'
|
12
|
-
#
|
13
|
-
# =Description
|
4
|
+
# DNS packet header class
|
14
5
|
#
|
15
6
|
# The Net::DNS::Header class represents the header portion of a
|
16
7
|
# DNS packet. An Header object is created whenever a new packet
|
17
8
|
# is parsed or as user request.
|
18
9
|
#
|
19
10
|
# header = Net::DNS::Header.new
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
11
|
+
# # ;; id = 18123
|
12
|
+
# # ;; qr = 0 opCode: 0 aa = 0 tc = 0 rd = 1
|
13
|
+
# # ;; ra = 0 ad = 0 cd = 0 rcode = 0
|
14
|
+
# # ;; qdCount = 1 anCount = 0 nsCount = 0 arCount = 0
|
24
15
|
#
|
25
16
|
# header.format
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
17
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
18
|
+
# # | 18123 |
|
19
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
20
|
+
# # |0| 0 |0|0|1|0|0| 0 | 0 |
|
21
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
22
|
+
# # | 1 |
|
23
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
24
|
+
# # | 0 |
|
25
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
26
|
+
# # | 0 |
|
27
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
28
|
+
# # | 0 |
|
29
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
39
30
|
#
|
40
31
|
# # packet is an instance of Net::DNS::Packet
|
41
32
|
# header = packet.header
|
@@ -63,17 +54,8 @@ module Net
|
|
63
54
|
class Error < StandardError
|
64
55
|
end
|
65
56
|
|
66
|
-
# The requested ID is already in use.
|
67
|
-
class DuplicateIDError < Error
|
68
|
-
end
|
69
|
-
|
70
57
|
|
71
|
-
#
|
72
|
-
# = Name
|
73
|
-
#
|
74
|
-
# Net::DNS::Header::RCode - DNS Header RCode handling class
|
75
|
-
#
|
76
|
-
# =Synopsis
|
58
|
+
# DNS Header RCode handling class
|
77
59
|
#
|
78
60
|
# It should be used internally by Net::DNS::Header class. However, it's still
|
79
61
|
# possible to instantiate it directly.
|
@@ -81,8 +63,6 @@ module Net
|
|
81
63
|
# require 'net/dns/header'
|
82
64
|
# rcode = Net::DNS::Header::RCode.new 0
|
83
65
|
#
|
84
|
-
# =Description
|
85
|
-
#
|
86
66
|
# The RCode class represents the RCode field in the Header portion of a
|
87
67
|
# DNS packet. This field (called Response Code) is used to get informations
|
88
68
|
# about the status of a DNS operation, such as a query or an update. These
|
@@ -171,6 +151,7 @@ module Net
|
|
171
151
|
end
|
172
152
|
end
|
173
153
|
|
154
|
+
|
174
155
|
# Constant for +opCode+ query
|
175
156
|
QUERY = 0
|
176
157
|
# Constant for +opCode+ iquery
|
@@ -180,8 +161,6 @@ module Net
|
|
180
161
|
# Array with given strings
|
181
162
|
OPARR = %w[QUERY IQUERY STATUS]
|
182
163
|
|
183
|
-
@@id_arr = []
|
184
|
-
|
185
164
|
# Reader for +id+ attribute
|
186
165
|
attr_reader :id
|
187
166
|
# Reader for the operational code
|
@@ -265,10 +244,10 @@ module Net
|
|
265
244
|
# Inspect method, prints out all the options and relative values.
|
266
245
|
#
|
267
246
|
# p Net::DNS::Header.new
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
247
|
+
# # ;; id = 18123
|
248
|
+
# # ;; qr = 0 opCode: 0 aa = 0 tc = 0 rd = 1
|
249
|
+
# # ;; ra = 0 ad = 0 cd = 0 rcode = 0
|
250
|
+
# # ;; qdCount = 1 anCount = 0 nsCount = 0 arCount = 0
|
272
251
|
#
|
273
252
|
# This method will maybe be changed in the future to a more pretty
|
274
253
|
# way of display output.
|
@@ -299,19 +278,19 @@ module Net
|
|
299
278
|
# similar to those often found on RFCs.
|
300
279
|
#
|
301
280
|
# p Net::DNS::Header.new.format
|
302
|
-
#
|
303
|
-
#
|
304
|
-
#
|
305
|
-
#
|
306
|
-
#
|
307
|
-
#
|
308
|
-
#
|
309
|
-
#
|
310
|
-
#
|
311
|
-
#
|
312
|
-
#
|
313
|
-
#
|
314
|
-
#
|
281
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
282
|
+
# # | 18123 |
|
283
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
284
|
+
# # |0| 0 |0|0|1|0|0| 0 | 0 |
|
285
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
286
|
+
# # | 1 |
|
287
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
288
|
+
# # | 0 |
|
289
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
290
|
+
# # | 0 |
|
291
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
292
|
+
# # | 0 |
|
293
|
+
# # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
315
294
|
#
|
316
295
|
# This can be very usefull for didactical purpouses :)
|
317
296
|
#
|
@@ -357,12 +336,8 @@ module Net
|
|
357
336
|
# performing security tests.
|
358
337
|
#
|
359
338
|
def id=(val)
|
360
|
-
if
|
361
|
-
raise DuplicateIDError, "ID `#{val}' already used"
|
362
|
-
end
|
363
|
-
if (1..65535).include? val
|
339
|
+
if (0..65535).include? val
|
364
340
|
@id = val
|
365
|
-
@@id_arr.push val
|
366
341
|
else
|
367
342
|
raise ArgumentError, "ID `#{val}' out of range"
|
368
343
|
end
|
@@ -403,7 +378,7 @@ module Net
|
|
403
378
|
# Returns a string representation of the +opCode+
|
404
379
|
#
|
405
380
|
# puts "Packet is a #{header.opCode_str}"
|
406
|
-
#
|
381
|
+
# #=> Packet is a QUERY
|
407
382
|
#
|
408
383
|
def opCode_str
|
409
384
|
OPARR[@opCode]
|
@@ -689,7 +664,7 @@ module Net
|
|
689
664
|
end
|
690
665
|
end
|
691
666
|
|
692
|
-
|
667
|
+
private
|
693
668
|
|
694
669
|
def new_from_scratch
|
695
670
|
@id = genID # generate ad unique id
|
@@ -729,10 +704,7 @@ module Net
|
|
729
704
|
end
|
730
705
|
|
731
706
|
def genID
|
732
|
-
|
733
|
-
end
|
734
|
-
@@id_arr.push(q)
|
735
|
-
q
|
707
|
+
rand(65535)
|
736
708
|
end
|
737
709
|
|
738
710
|
end
|