net-dns 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +6 -0
  2. data/AUTHORS.rdoc +7 -0
  3. data/CHANGELOG.rdoc +34 -0
  4. data/README.rdoc +26 -14
  5. data/Rakefile +23 -30
  6. data/{THANKS → THANKS.rdoc} +0 -0
  7. data/VERSION.yml +3 -2
  8. data/demo/check_soa.rb +6 -11
  9. data/lib/net/{dns/dns.rb → dns.rb} +5 -12
  10. data/lib/net/dns/core_ext.rb +52 -0
  11. data/lib/net/dns/header.rb +55 -49
  12. data/lib/net/dns/names/names.rb +20 -10
  13. data/lib/net/dns/packet.rb +33 -26
  14. data/lib/net/dns/question.rb +60 -27
  15. data/lib/net/dns/resolver.rb +101 -156
  16. data/lib/net/dns/resolver/timeouts.rb +71 -65
  17. data/lib/net/dns/rr.rb +131 -166
  18. data/lib/net/dns/rr/a.rb +20 -26
  19. data/lib/net/dns/rr/aaaa.rb +15 -20
  20. data/lib/net/dns/rr/classes.rb +1 -1
  21. data/lib/net/dns/rr/cname.rb +8 -14
  22. data/lib/net/dns/rr/hinfo.rb +8 -14
  23. data/lib/net/dns/rr/mr.rb +8 -14
  24. data/lib/net/dns/rr/mx.rb +11 -18
  25. data/lib/net/dns/rr/ns.rb +8 -14
  26. data/lib/net/dns/rr/null.rb +7 -14
  27. data/lib/net/dns/rr/ptr.rb +9 -15
  28. data/lib/net/dns/rr/soa.rb +9 -15
  29. data/lib/net/dns/rr/srv.rb +10 -19
  30. data/lib/net/dns/rr/txt.rb +9 -20
  31. data/lib/net/dns/rr/types.rb +51 -58
  32. data/lib/net/dns/version.rb +22 -0
  33. data/test/{net/dns/test_header.rb → header_test.rb} +20 -20
  34. data/test/{net/dns/test_packet.rb → packet_test.rb} +2 -2
  35. data/test/question_test.rb +84 -0
  36. data/test/resolver/timeouts_test.rb +109 -0
  37. data/test/{net/dns/test_resolver.rb → resolver_test.rb} +6 -6
  38. data/test/rr/a_test.rb +66 -0
  39. data/test/{net/dns/rr/test_classes.rb → rr/classes_test.rb} +5 -5
  40. data/test/rr/ns_test.rb +64 -0
  41. data/test/rr/types_test.rb +69 -0
  42. data/test/{net/dns/test_rr.rb → rr_test.rb} +10 -12
  43. data/test/test_helper.rb +4 -0
  44. metadata +50 -35
  45. data/AUTHORS +0 -10
  46. data/CHANGELOG +0 -7
  47. data/INSTALL +0 -8
  48. data/net-dns.gemspec +0 -92
  49. data/test/net/dns/resolver/test_timeouts.rb +0 -59
  50. data/test/net/dns/rr/test_a.rb +0 -72
  51. data/test/net/dns/rr/test_ns.rb +0 -66
  52. data/test/net/dns/rr/test_types.rb +0 -124
  53. data/test/net/dns/test_question.rb +0 -54
@@ -1,66 +0,0 @@
1
- require 'test/unit'
2
- require 'net/dns/rr'
3
-
4
- class Test_NS < Test::Unit::TestCase
5
- def setup
6
-
7
- @name = "google.com."
8
- @type = "NS"
9
- @cls = "IN"
10
- @ttl = 10800
11
- @nsdname = "ns1.google.com."
12
-
13
-
14
- @hash = Net::DNS::RR::NS.new(:name => @name,
15
- :nsdname => @nsdname)
16
-
17
- @string = Net::DNS::RR::NS.new("google.com. 10800 IN NS ns1.google.com.")
18
-
19
- @arr = Net::DNS::RR.parse(@string.data)
20
-
21
- @str = "google.com. 10800 IN NS ns1.google.com."
22
- end
23
-
24
- def test_simple
25
- assert_equal(@str,@hash.inspect)
26
- assert_equal(@name, @hash.name)
27
- assert_equal(@type, @hash.type)
28
- assert_equal(@cls, @hash.cls)
29
- assert_equal(@ttl, @hash.ttl)
30
- assert_equal(@nsdname, @hash.nsdname)
31
-
32
- assert_equal(@str, @string.inspect)
33
- assert_equal(@name, @string.name)
34
- assert_equal(@type, @string.type)
35
- assert_equal(@cls, @string.cls)
36
- assert_equal(@ttl, @string.ttl)
37
- assert_equal(@nsdname, @string.nsdname)
38
-
39
- assert_equal(@str, @arr.inspect)
40
- assert_equal(@name, @arr.name)
41
- assert_equal(@type, @arr.type)
42
- assert_equal(@cls, @arr.cls)
43
- assert_equal(@ttl, @arr.ttl)
44
- assert_equal(@nsdname, @arr.nsdname)
45
- end
46
-
47
- def test_range
48
- assert_raise(RRArgumentError) do
49
- Net::DNS::RR::NS.new(:name => "google.com",
50
- :nsdname => "255.256")
51
- end
52
- assert_raise(RRArgumentError) do
53
- Net::DNS::RR::NS.new(:name => "google.com")
54
- end
55
- assert_raise(ArgumentError) do
56
- Net::DNS::RR::NS.new(Range.new)
57
- end
58
- assert_raise(RRArgumentError) do
59
- Net::DNS::RR::NS.new(Array.new(7))
60
- end
61
- assert_raise(RRArgumentError) do
62
- Net::DNS::RR::NS.new("10800 IN A")
63
- end
64
- end
65
- end
66
-
@@ -1,124 +0,0 @@
1
- require 'test/unit'
2
- require 'net/dns/rr/types'
3
-
4
- class Test_Types < Test::Unit::TestCase
5
- def setup
6
- @types = {
7
- 'SIGZERO' => 0,
8
- 'A' => 1,
9
- 'NS' => 2,
10
- 'MD' => 3,
11
- 'MF' => 4,
12
- 'CNAME' => 5,
13
- 'SOA' => 6,
14
- 'MB' => 7,
15
- 'MG' => 8,
16
- 'MR' => 9,
17
- 'NULL' => 10,
18
- 'WKS' => 11,
19
- 'PTR' => 12,
20
- 'HINFO' => 13,
21
- 'MINFO' => 14,
22
- 'MX' => 15,
23
- 'TXT' => 16,
24
- 'RP' => 17,
25
- 'AFSDB' => 18,
26
- 'X25' => 19,
27
- 'ISDN' => 20,
28
- 'RT' => 21,
29
- 'NSAP' => 22,
30
- 'NSAP_PTR' => 23,
31
- 'SIG' => 24,
32
- 'KEY' => 25,
33
- 'PX' => 26,
34
- 'GPOS' => 27,
35
- 'AAAA' => 28,
36
- 'LOC' => 29,
37
- 'NXT' => 30,
38
- 'EID' => 31,
39
- 'NIMLOC' => 32,
40
- 'SRV' => 33,
41
- 'ATMA' => 34,
42
- 'NAPTR' => 35,
43
- 'KX' => 36,
44
- 'CERT' => 37,
45
- 'DNAME' => 39,
46
- 'OPT' => 41,
47
- 'DS' => 43,
48
- 'SSHFP' => 44,
49
- 'RRSIG' => 46,
50
- 'NSEC' => 47,
51
- 'DNSKEY' => 48,
52
- 'UINFO' => 100,
53
- 'UID' => 101,
54
- 'GID' => 102,
55
- 'UNSPEC' => 103,
56
- 'TKEY' => 249,
57
- 'TSIG' => 250,
58
- 'IXFR' => 251,
59
- 'AXFR' => 252,
60
- 'MAILB' => 253,
61
- 'MAILA' => 254,
62
- 'ANY' => 255,
63
- }
64
-
65
- @regexp_string = "A|AAAA|AFSDB|ANY|ATMA|AXFR|CERT|CNAME|DNAME|DNSKEY|DS|EID|GID|GPOS|HINFO|ISDN|IXFR|KEY|KX|LOC|MAILA|MAILB|MB|MD|MF|MG|MINFO|MR|MX|NAPTR|NIMLOC|NS|NSAP|NSAP_PTR|NSEC|NULL|NXT|OPT|PTR|PX|RP|RRSIG|RT|SIG|SIGZERO|SOA|SRV|SSHFP|TKEY|TSIG|TXT|UID|UINFO|UNSPEC|WKS|X25"
66
- end
67
-
68
- def test_default
69
- # Default type should be ANY => 255
70
- instance = Net::DNS::RR::Types.new(nil)
71
- assert_equal("1", instance.to_str)
72
- assert_equal("A", instance.to_s)
73
-
74
- # Let's change default behaviour
75
- Net::DNS::RR::Types.default = "A"
76
- instance = Net::DNS::RR::Types.new(nil)
77
- assert_equal("1", instance.to_str)
78
- assert_equal("A", instance.to_s)
79
-
80
- Net::DNS::RR::Types.default = "ANY"
81
- instance = Net::DNS::RR::Types.new(nil)
82
- assert_equal("255", instance.to_str)
83
- assert_equal("ANY", instance.to_s)
84
- end
85
-
86
- def test_types
87
- @types.each do |key,num|
88
- instance_from_string = Net::DNS::RR::Types.new(key)
89
- instance_from_num = Net::DNS::RR::Types.new(num)
90
- assert_equal(key, instance_from_string.to_s)
91
- assert_equal(num.to_s, instance_from_string.to_str)
92
- assert_equal(key, instance_from_num.to_s)
93
- assert_equal(num.to_s, instance_from_num.to_str)
94
- end
95
- assert_raise(TypeArgumentError) do
96
- Net::DNS::RR::Types.new(Hash.new)
97
- end
98
- end
99
-
100
- def test_regexp
101
- assert_equal(@regexp_string, Net::DNS::RR::Types.regexp)
102
- end
103
-
104
- def test_valid
105
- assert_equal(true, Net::DNS::RR::Types.valid?("A"))
106
- assert_equal(true, Net::DNS::RR::Types.valid?(1))
107
- assert_equal(false, Net::DNS::RR::Types.valid?("Q"))
108
- assert_equal(false, Net::DNS::RR::Types.valid?(256))
109
- assert_raise(TypeArgumentError) do
110
- Net::DNS::RR::Types.valid? Hash.new
111
- end
112
- end
113
-
114
- def test_to_str
115
- assert_equal("A", Net::DNS::RR::Types.to_str(1))
116
- assert_raise(TypeArgumentError) do
117
- Net::DNS::RR::Types.to_str(256)
118
- end
119
- assert_raise(TypeArgumentError) do
120
- Net::DNS::RR::Types.to_str("string")
121
- end
122
- end
123
-
124
- end
@@ -1,54 +0,0 @@
1
- require 'test/unit'
2
- require 'net/dns/question'
3
-
4
- class Test_Question < Test::Unit::TestCase
5
- include Net::DNS
6
-
7
- def setup
8
- @domain = 'example.com.'
9
- @type = 'MX'
10
- @cls = 'HS'
11
- @data = "\006google\003com\000\000\001\000\001"
12
-
13
- @default = Question.new(@domain)
14
- @string = Question.new(@domain,@type,@cls)
15
- @binary = Question.parse(@data)
16
- @binary2 = Question.parse(@string.data)
17
- end
18
-
19
- def test_simple
20
- assert_equal(@default.qName, @domain)
21
- assert_equal(@default.qType.to_s, "A")
22
- assert_equal(@default.qClass.to_s, "IN")
23
-
24
- assert_equal(@string.qName, @domain)
25
- assert_equal(@string.qType.to_s, "MX")
26
- assert_equal(@string.qClass.to_s, "HS")
27
-
28
- assert_equal(@binary.qName, "google.com.")
29
- assert_equal(@binary.qType.to_s, "A")
30
- assert_equal(@binary.qClass.to_s, "IN")
31
-
32
- assert_equal(@binary2.qName, @domain)
33
- assert_equal(@binary2.qType.to_s, "MX")
34
- assert_equal(@binary2.qClass.to_s, "HS")
35
- end
36
-
37
- def test_raise
38
- assert_raise(QuestionNameError) do
39
- Question.new(1)
40
- end
41
- assert_raise(QuestionNameError) do
42
- Question.new("test{")
43
- end
44
- assert_raise(QuestionArgumentError) do
45
- Question.parse(Array.new)
46
- end
47
- assert_raise(QuestionArgumentError) do
48
- Question.parse("test")
49
- end
50
-
51
- end
52
-
53
-
54
- end