net-dns 0.9.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -16
  3. data/README.md +1 -1
  4. data/lib/net/dns/header.rb +48 -64
  5. data/lib/net/dns/names.rb +8 -10
  6. data/lib/net/dns/packet.rb +46 -53
  7. data/lib/net/dns/question.rb +5 -3
  8. data/lib/net/dns/resolver/socks.rb +5 -7
  9. data/lib/net/dns/resolver/timeouts.rb +3 -5
  10. data/lib/net/dns/resolver.rb +54 -69
  11. data/lib/net/dns/rr/a.rb +3 -4
  12. data/lib/net/dns/rr/aaaa.rb +3 -5
  13. data/lib/net/dns/rr/classes.rb +6 -8
  14. data/lib/net/dns/rr/cname.rb +3 -5
  15. data/lib/net/dns/rr/hinfo.rb +9 -13
  16. data/lib/net/dns/rr/mr.rb +3 -5
  17. data/lib/net/dns/rr/mx.rb +5 -7
  18. data/lib/net/dns/rr/ns.rb +3 -5
  19. data/lib/net/dns/rr/null.rb +3 -5
  20. data/lib/net/dns/rr/ptr.rb +3 -5
  21. data/lib/net/dns/rr/soa.rb +11 -7
  22. data/lib/net/dns/rr/srv.rb +5 -2
  23. data/lib/net/dns/rr/txt.rb +4 -6
  24. data/lib/net/dns/rr/types.rb +90 -79
  25. data/lib/net/dns/rr.rb +2 -2
  26. data/lib/net/dns/version.rb +1 -1
  27. data/lib/net/dns.rb +3 -1
  28. metadata +11 -104
  29. data/.gitignore +0 -8
  30. data/.rubocop.yml +0 -3
  31. data/.rubocop_defaults.yml +0 -364
  32. data/.rubocop_todo.yml +0 -207
  33. data/Gemfile +0 -8
  34. data/Rakefile +0 -38
  35. data/bin/console +0 -14
  36. data/lib/net/dns/core_ext.rb +0 -45
  37. data/net-dns.gemspec +0 -23
  38. data/spec/fixtures/resolv.conf +0 -4
  39. data/spec/spec_helper.rb +0 -14
  40. data/spec/unit/resolver/dns_timeout_spec.rb +0 -36
  41. data/spec/unit/resolver/tcp_timeout_spec.rb +0 -46
  42. data/spec/unit/resolver/udp_timeout_spec.rb +0 -46
  43. data/test/test_helper.rb +0 -13
  44. data/test/unit/header_test.rb +0 -164
  45. data/test/unit/names_test.rb +0 -21
  46. data/test/unit/packet_test.rb +0 -47
  47. data/test/unit/question_test.rb +0 -81
  48. data/test/unit/resolver_test.rb +0 -114
  49. data/test/unit/rr/a_test.rb +0 -106
  50. data/test/unit/rr/aaaa_test.rb +0 -102
  51. data/test/unit/rr/classes_test.rb +0 -83
  52. data/test/unit/rr/cname_test.rb +0 -90
  53. data/test/unit/rr/hinfo_test.rb +0 -111
  54. data/test/unit/rr/mr_test.rb +0 -99
  55. data/test/unit/rr/mx_test.rb +0 -106
  56. data/test/unit/rr/ns_test.rb +0 -80
  57. data/test/unit/rr/types_test.rb +0 -71
  58. data/test/unit/rr_test.rb +0 -127
@@ -1,80 +0,0 @@
1
- require 'test_helper'
2
- require 'net/dns/rr'
3
-
4
- class RRNSTest < Minitest::Test
5
- def setup
6
- @rr_name = "google.com."
7
- @rr_type = "NS"
8
- @rr_cls = "IN"
9
- @rr_ttl = 10_800
10
- @rr_nsdname = "ns1.google.com."
11
-
12
- @rr_output = "google.com. 10800 IN NS ns1.google.com."
13
-
14
- @rr = Net::DNS::RR::NS.new(name: "google.com.", nsdname: "ns1.google.com.", ttl: @rr_ttl)
15
- end
16
-
17
- def test_initialize_from_hash
18
- @record = Net::DNS::RR::NS.new(name: "google.com.", nsdname: "ns1.google.com.")
19
- assert_equal @rr_output, @record.inspect
20
- assert_equal @rr_name, @record.name
21
- assert_equal @rr_type, @record.type
22
- assert_equal @rr_cls, @record.cls
23
- assert_equal @rr_ttl, @record.ttl
24
- assert_equal @rr_nsdname, @record.nsdname
25
- end
26
-
27
- def test_initialize_from_string
28
- @record = Net::DNS::RR::NS.new("google.com. 10800 IN NS ns1.google.com.")
29
- assert_equal @rr_output, @record.inspect
30
- assert_equal @rr_name, @record.name
31
- assert_equal @rr_type, @record.type
32
- assert_equal @rr_cls, @record.cls
33
- assert_equal @rr_ttl, @record.ttl
34
- assert_equal @rr_nsdname, @record.nsdname
35
- end
36
-
37
- def test_parse
38
- data = "\006google\003com\000\000\002\000\001\000\000*0\000\020\003ns1\006google\003com\000"
39
- @record = Net::DNS::RR.parse(data)
40
- assert_equal @rr_output, @record.inspect
41
- assert_equal @rr_name, @record.name
42
- assert_equal @rr_type, @record.type
43
- assert_equal @rr_cls, @record.cls
44
- assert_equal @rr_ttl, @record.ttl
45
- assert_equal @rr_nsdname, @record.nsdname
46
- end
47
-
48
- InvalidArguments = [
49
- { name: "google.com", nsdname: "255.256" },
50
- { name: "google.com" },
51
- Object.new,
52
- Array.new(7),
53
- "10800 IN A",
54
- ].freeze
55
-
56
- InvalidArguments.each_with_index do |arguments, index|
57
- define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
58
- assert_raises(ArgumentError) { Net::DNS::RR::NS.new(arguments) }
59
- end
60
- end
61
-
62
- def test_value
63
- assert_equal "ns1.google.com.", @rr.value
64
- end
65
-
66
- def test_inspect
67
- assert_equal "google.com. 10800 IN NS ns1.google.com.",
68
- @rr.inspect
69
- end
70
-
71
- def test_to_s
72
- assert_equal "google.com. 10800 IN NS ns1.google.com.",
73
- @rr.to_s
74
- end
75
-
76
- def test_to_a
77
- assert_equal ["google.com.", 10_800, "IN", "NS", "ns1.google.com."],
78
- @rr.to_a
79
- end
80
- end
@@ -1,71 +0,0 @@
1
- require 'test_helper'
2
- require 'net/dns/rr'
3
-
4
- class RRTypesTest < Minitest::Test
5
- def setup
6
- end
7
-
8
- def test_default
9
- @_default = Net::DNS::RR::Types.default
10
-
11
- # Default type should be ANY => 255
12
- instance = Net::DNS::RR::Types.new(nil)
13
- assert_equal("1", instance.to_str)
14
- assert_equal("A", instance.to_s)
15
-
16
- # Let's change default behaviour
17
- Net::DNS::RR::Types.default = "A"
18
- instance = Net::DNS::RR::Types.new(nil)
19
- assert_equal("1", instance.to_str)
20
- assert_equal("A", instance.to_s)
21
-
22
- Net::DNS::RR::Types.default = "ANY"
23
- instance = Net::DNS::RR::Types.new(nil)
24
- assert_equal("255", instance.to_str)
25
- assert_equal("ANY", instance.to_s)
26
- ensure
27
- Net::DNS::RR::Types.default = Net::DNS::RR::Types::TYPES.invert[@_default]
28
- end
29
-
30
- def test_types
31
- Net::DNS::RR::Types::TYPES.each do |key, num|
32
- instance_from_string = Net::DNS::RR::Types.new(key)
33
- instance_from_num = Net::DNS::RR::Types.new(num)
34
- assert_equal(key, instance_from_string.to_s)
35
- assert_equal(num.to_s, instance_from_string.to_str)
36
- assert_equal(key, instance_from_num.to_s)
37
- assert_equal(num.to_s, instance_from_num.to_str)
38
- end
39
- assert_raises(ArgumentError) do
40
- Net::DNS::RR::Types.new({})
41
- end
42
- end
43
-
44
- def test_regexp
45
- pattern = Net::DNS::RR::Types.regexp
46
- assert_instance_of String, pattern
47
- Net::DNS::RR::Types::TYPES.each do |key, num|
48
- assert_match /\|?#{key}\|?/, pattern
49
- end
50
- end
51
-
52
- def test_valid?
53
- assert_equal(true, Net::DNS::RR::Types.valid?("A"))
54
- assert_equal(true, Net::DNS::RR::Types.valid?(1))
55
- assert_equal(false, Net::DNS::RR::Types.valid?("Q"))
56
- assert_equal(false, Net::DNS::RR::Types.valid?(256))
57
- assert_raises(ArgumentError) do
58
- Net::DNS::RR::Types.valid?({})
59
- end
60
- end
61
-
62
- def test_to_str
63
- assert_equal("A", Net::DNS::RR::Types.to_str(1))
64
- assert_raises(ArgumentError) do
65
- Net::DNS::RR::Types.to_str(256)
66
- end
67
- assert_raises(ArgumentError) do
68
- Net::DNS::RR::Types.to_str("string")
69
- end
70
- end
71
- end
data/test/unit/rr_test.rb DELETED
@@ -1,127 +0,0 @@
1
- require 'test_helper'
2
- require 'net/dns/rr'
3
-
4
- class RRTest < Minitest::Test
5
- def setup
6
- @rr_name = "example.com."
7
- @type = "A"
8
- @cls = "IN"
9
- @ttl = 10_800
10
- @rdata = "64.233.187.99"
11
-
12
- @defaults = Net::DNS::RR.new(name: @rr_name,
13
- rdata: @rdata)
14
-
15
- @a_hash = Net::DNS::RR.new(name: @rr_name,
16
- ttl: @ttl,
17
- cls: @cls,
18
- type: @type,
19
- address: @rdata)
20
-
21
- @a_string = Net::DNS::RR::A.new("example.com. 10800 IN A 64.233.187.99")
22
-
23
- @str = "example.com. 10800 IN A 64.233.187.99"
24
-
25
- @a = Net::DNS::RR.new("foo.example.com. 86400 A 10.1.2.3")
26
- @mx = Net::DNS::RR.new("example.com. 7200 MX 10 mailhost.example.com.")
27
- @cname = Net::DNS::RR.new("www.example.com IN CNAME www1.example.com")
28
- @txt = Net::DNS::RR.new('baz.example.com 3600 HS TXT "text record"')
29
-
30
- @a_data = @a.data
31
- @a_binary = Net::DNS::RR.parse(@a_data)
32
- @mx_data = @mx.data
33
- @mx_binary = Net::DNS::RR.parse(@mx_data)
34
-
35
- @array = [@rr_name, @ttl, @cls, @type, @rdata]
36
- end
37
-
38
- def test_classes
39
- assert_instance_of Net::DNS::RR::A, @a
40
- assert_instance_of Net::DNS::RR::MX, @mx
41
- assert_instance_of Net::DNS::RR::CNAME, @cname
42
- assert_instance_of Net::DNS::RR::TXT, @txt
43
- assert_instance_of Net::DNS::RR::A, @a_binary
44
- assert_instance_of Net::DNS::RR::MX, @mx_binary
45
- end
46
-
47
- def test_ttl
48
- assert_equal @a.ttl, 86_400
49
- assert_equal @mx.ttl, 7200
50
- assert_equal @cname.ttl, 10_800
51
- assert_equal @txt.ttl, 3600
52
- assert_equal @a_binary.ttl, 86_400
53
- assert_equal @mx_binary.ttl, 7200
54
- end
55
-
56
- def test_types
57
- assert_equal @a.type, "A"
58
- assert_equal @mx.type, "MX"
59
- assert_equal @cname.type, "CNAME"
60
- assert_equal @txt.type, "TXT"
61
- assert_equal @a_binary.type, "A"
62
- assert_equal @mx_binary.type, "MX"
63
- end
64
-
65
- def test_cls
66
- assert_equal @a.cls, "IN"
67
- assert_equal @mx.cls, "IN"
68
- assert_equal @cname.cls, "IN"
69
- assert_equal @txt.cls, "HS"
70
- assert_equal @a_binary.cls, "IN"
71
- assert_equal @mx_binary.cls, "IN"
72
- end
73
-
74
- def test_name
75
- assert_equal @a.name, "foo.example.com."
76
- assert_equal @mx.name, "example.com."
77
- assert_equal @cname.name, "www.example.com"
78
- assert_equal @txt.name, "baz.example.com"
79
- assert_equal @a_binary.name, "foo.example.com."
80
- assert_equal @mx_binary.name, "example.com."
81
- end
82
-
83
- def test_rdata
84
- assert_equal @a.address.to_s, "10.1.2.3"
85
- assert_equal @mx.preference, 10
86
- assert_equal @mx.exchange, "mailhost.example.com."
87
- assert_equal @cname.cname, "www1.example.com"
88
- assert_equal @txt.txt, '"text record"'
89
- assert_equal @a_binary.address.to_s, "10.1.2.3"
90
- assert_equal @mx_binary.preference, 10
91
- assert_equal @mx_binary.exchange, "mailhost.example.com."
92
- end
93
-
94
- def test_simple
95
- assert_equal @rr_name, @defaults.name
96
- assert_equal @type, @defaults.type
97
- assert_equal @cls, @defaults.cls
98
- assert_equal @ttl, @defaults.ttl
99
- assert_equal @rdata, @defaults.rdata.to_s
100
-
101
- assert_equal(@str, @a_hash.inspect)
102
- assert_equal(@rr_name, @a_hash.name)
103
- assert_equal(@type, @a_hash.type)
104
- assert_equal(@cls, @a_hash.cls)
105
- assert_equal(@ttl, @a_hash.ttl)
106
- assert_equal(@rdata, @a_hash.address.to_s)
107
-
108
- assert_equal(@str, @a_string.inspect)
109
- assert_equal(@rr_name, @a_string.name)
110
- assert_equal(@type, @a_string.type)
111
- assert_equal(@cls, @a_string.cls)
112
- assert_equal(@ttl, @a_string.ttl)
113
- assert_equal(@rdata, @a_string.address.to_s)
114
-
115
- assert_equal(@a_data, @a_binary.data)
116
- assert_equal(@mx_data, @mx_binary.data)
117
-
118
- assert_equal(@str, @a_hash.to_s)
119
- assert_equal(@array, @a_hash.to_a)
120
- end
121
-
122
- def test_range
123
- assert_raises(ArgumentError) do
124
- Net::DNS::RR.new("google.com. 10800 IM A")
125
- end
126
- end
127
- end