pNet-DNS 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,68 +1,70 @@
1
- pNet::DNS
2
- ---------
3
-
4
- Ruby port of perl Net::DNS.
5
-
6
- This project is a direct port of perl Net::DNS, version 0.57.
7
- It has tried to stick as closely as possible to the original
8
- perl code, to allow existing perl code to be ported quickly and
9
- easily to Ruby. This project is not intended to be anything more
10
- than a direct port of the perl code.
11
-
12
- The perl test code has also been ported to Ruby, and all runs
13
- successfully. The demo code has also been ported.
14
-
15
- No effort has been made to fix bugs in the original perl code -
16
- this port is as close as possible to the perl.
17
-
18
- Author : AlexD
19
- Contact : alexd@nominet.org.uk
20
- Copyright (c) Nominet UK, 2006
21
-
22
- Check out demo and test folders for examples.
23
-
24
- Issues
25
- ------
26
-
27
- I've still not had a chance to test on IPv6, so the functionality in
28
- tc_inet6.rb is untested.
29
-
30
- Nameserver.rb is a port of the perl version - bugs and all.
31
- It's obviously broken, but would not be hard to fix.
32
- If you need a working version of this code, please contact me.
33
-
34
- Licensing
35
- ---------
36
-
37
- This project is licensed under the Mozilla Public License.
38
-
39
- The contents of this file are subject to the Mozilla Public Licence
40
- Version 1.1 (the `Licence'); you may not use this file except in
41
- compliance with the Licence. You may obtain a copy of the Licence at
42
- http://www.mozilla.org/MPL
43
-
44
- Software distributed under the Licence is distributed on an `AS IS'
45
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
46
- the Licence of the specific language governing rights and limitations
47
- under the Licence.
48
-
49
- The Original Code is pNet::DNS.
50
-
51
- The Initial Developer of the Original Code is Nominet UK
52
- (http://www.nominet.org.uk). Portions created by Nominet UK are
53
- Copyright (c) Nominet UK 2006. All rights reserved.
54
-
55
- PERL AUTHOR INFORMATION
56
- -----------------------
57
-
58
- Net::DNS is currently maintained at NLnet Labs (www.nlnetlabs.nl) by:
59
- Olaf Kolkman and his team.
60
- olaf at net-dns.org
61
-
62
- Between 2002 and 2004 Net::DNS was maintained by:
63
- Chris Reinhardt
64
-
65
-
66
- Net::DNS was created by:
67
- Michael Fuhr
68
- mike at fuhr.org
1
+ pNet::DNS
2
+ ---------
3
+
4
+ Ruby port of perl Net::DNS.
5
+
6
+ This project is a direct port of perl Net::DNS, version 0.57.
7
+ It has tried to stick as closely as possible to the original
8
+ perl code, to allow existing perl code to be ported quickly and
9
+ easily to Ruby. This project is not intended to be anything more
10
+ than a direct port of the perl code.
11
+
12
+ The perl test code has also been ported to Ruby, and all runs
13
+ successfully. The demo code has also been ported.
14
+
15
+ No effort has been made to fix bugs in the original perl code -
16
+ this port is as close as possible to the perl.
17
+
18
+ Author : AlexD
19
+ Contact : alexd@nominet.org.uk
20
+ Copyright (c) Nominet UK, 2006
21
+
22
+ Check out demo and test folders for examples.
23
+
24
+ Issues
25
+ ------
26
+
27
+ I've still not had a chance to test on IPv6, so the functionality in
28
+ tc_inet6.rb is untested.
29
+
30
+ Nameserver.rb is a port of the perl version - bugs and all.
31
+ It's obviously broken, but would not be hard to fix.
32
+ If you need a working version of this code, please contact me.
33
+
34
+ JRuby does not yet support TCP, although UDP is fully supported.
35
+
36
+ Licensing
37
+ ---------
38
+
39
+ This project is licensed under the Mozilla Public License.
40
+
41
+ The contents of this file are subject to the Mozilla Public Licence
42
+ Version 1.1 (the `Licence'); you may not use this file except in
43
+ compliance with the Licence. You may obtain a copy of the Licence at
44
+ http://www.mozilla.org/MPL
45
+
46
+ Software distributed under the Licence is distributed on an `AS IS'
47
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
48
+ the Licence of the specific language governing rights and limitations
49
+ under the Licence.
50
+
51
+ The Original Code is pNet::DNS.
52
+
53
+ The Initial Developer of the Original Code is Nominet UK
54
+ (http://www.nominet.org.uk). Portions created by Nominet UK are
55
+ Copyright (c) Nominet UK 2006. All rights reserved.
56
+
57
+ PERL AUTHOR INFORMATION
58
+ -----------------------
59
+
60
+ Net::DNS is currently maintained at NLnet Labs (www.nlnetlabs.nl) by:
61
+ Olaf Kolkman and his team.
62
+ olaf at net-dns.org
63
+
64
+ Between 2002 and 2004 Net::DNS was maintained by:
65
+ Chris Reinhardt
66
+
67
+
68
+ Net::DNS was created by:
69
+ Michael Fuhr
70
+ mike at fuhr.org
@@ -647,7 +647,16 @@ module Net
647
647
  def read_config_file(conf_file)
648
648
  ns=[]
649
649
  searchlist=[]
650
-
650
+ if !(File.exist? conf_file)
651
+ if (/java/ =~ RUBY_PLATFORM && !(conf_file=~/:/))
652
+ # Problem with paths and Windows on JRuby - see if we can munge the drive...
653
+ wd = Dir.getwd
654
+ drive = wd.split(':')[0]
655
+ if (drive.length==1)
656
+ conf_file = drive << ":" << conf_file
657
+ end
658
+ end
659
+ end
651
660
  IO.foreach(conf_file) do |line|
652
661
  line.gsub!(/\s*[;#].*/,"")
653
662
  next unless line =~ /\S/
@@ -795,8 +804,8 @@ module Net
795
804
  return addr;
796
805
  end
797
806
 
798
- # if ($self->{"udppacketsize"} > Net::DNS::PACKETSZ()
799
- # then we use EDNS and $self->{"udppacketsize"}
807
+ # if (@udppacketsize > Net::DNS::PACKETSZ()
808
+ # then we use EDNS and @udppacketsize
800
809
  # should be taken as the maximum packet_data length
801
810
  def _packetsz
802
811
  ret = (@udppacketsize > Net::DNS::PACKETSZ ? @udppacketsize : Net::DNS::PACKETSZ)
@@ -1251,8 +1260,8 @@ module Net
1251
1260
  next
1252
1261
  end
1253
1262
  begin
1254
- res = Socket::getaddrinfo(ns_address, dstport, Socket::AF_UNSPEC, Socket::SOCK_DGRAM,
1255
- 0, Socket::AI_NUMERICHOST)[0]
1263
+ res = Socket::getaddrinfo(ns_address, dstport)[0] # , Socket::AF_UNSPEC, Socket::SOCK_DGRAM,
1264
+ # 0, Socket::AI_NUMERICHOST)[0]
1256
1265
 
1257
1266
 
1258
1267
  sockfamily = res[0]
@@ -1486,8 +1495,8 @@ module Net
1486
1495
 
1487
1496
  begin
1488
1497
  # The AI_NUMERICHOST surpresses lookups.
1489
- res = Socket::getaddrinfo(ns_address, dstport, Socket::AF_UNSPEC,
1490
- Socket::SOCK_DGRAM, 0 , Socket::AI_NUMERICHOST)[0]
1498
+ res = Socket::getaddrinfo(ns_address, dstport)[0] # , Socket::AF_UNSPEC,
1499
+ # Socket::SOCK_DGRAM, 0 , Socket::AI_NUMERICHOST)[0]
1491
1500
 
1492
1501
  sockfamily = res[0]
1493
1502
  socktype_tmp = res[1]
@@ -1627,37 +1636,35 @@ module Net
1627
1636
 
1628
1637
  if (@dnssec)
1629
1638
  # RFC 3225
1630
- print ";; Adding EDNS extention with UDP packetsize #{@udppacketsize} and DNS OK bit set\n"
1631
- if @debug
1632
-
1633
- optrr = Net::DNS::RR.create({
1634
- :type => 'OPT',
1635
- :name => '',
1636
- :rrclass => @udppacketsize, # Decimal UDPpayload
1637
- :ednsflags => 0x8000, # first bit set see RFC 3225
1638
- })
1639
-
1640
- packet.push('additional', optrr)
1641
-
1642
- elsif (@udppacketsize > Net::DNS::PACKETSZ)
1643
- print ";; Adding EDNS extention with UDP packetsize #{@udppacketsize}.\n" if @debug
1644
- # RFC 3225
1645
- optrr = Net::DNS::RR.create( {
1646
- :type => 'OPT',
1647
- :name => '',
1648
- :rrclass => @udppacketsize, # Decimal UDPpayload
1649
- :ttl => 0x0000 # RCODE 32bit Hex
1650
- })
1651
-
1652
- packet.push('additional', optrr)
1653
- end
1639
+ print ";; Adding EDNS extention with UDP packetsize #{@udppacketsize} and DNS OK bit set\n" if @debug
1654
1640
 
1641
+ optrr = Net::DNS::RR.create({
1642
+ :type => 'OPT',
1643
+ :name => '',
1644
+ :rrclass => @udppacketsize, # Decimal UDPpayload
1645
+ :ednsflags => 0x8000, # first bit set see RFC 3225
1646
+ })
1655
1647
 
1656
- if (@tsig_rr != nil && @tsig_rr.length > 0)
1657
- # if (!grep { $_.type == 'TSIG' } packet.additional)
1658
- if (packet.additional.select { |i| i.type == 'TSIG' }.length > 0)
1659
- packet.push('additional', @tsig_rr)
1660
- end
1648
+ packet.push('additional', optrr)
1649
+
1650
+ elsif (@udppacketsize > Net::DNS::PACKETSZ)
1651
+ print ";; Adding EDNS extention with UDP packetsize #{@udppacketsize}.\n" if @debug
1652
+ # RFC 3225
1653
+ optrr = Net::DNS::RR.create( {
1654
+ :type => 'OPT',
1655
+ :name => '',
1656
+ :rrclass => @udppacketsize, # Decimal UDPpayload
1657
+ :ttl => 0x0000 # RCODE 32bit Hex
1658
+ })
1659
+
1660
+ packet.push('additional', optrr)
1661
+ end
1662
+
1663
+
1664
+ if (@tsig_rr != nil && @tsig_rr.length > 0)
1665
+ # if (!grep { $_.type == 'TSIG' } packet.additional)
1666
+ if (packet.additional.select { |i| i.type == 'TSIG' }.length > 0)
1667
+ packet.push('additional', @tsig_rr)
1661
1668
  end
1662
1669
  end
1663
1670
 
@@ -2044,11 +2051,20 @@ module Net
2044
2051
 
2045
2052
  srcaddr6 = srcaddr == '0.0.0.0' ? '::' : srcaddr
2046
2053
 
2047
- sock = Socket.new( Socket::AF_INET6, Socket::SOCK_STREAM, 0 )
2048
- sockaddr = Socket.pack_sockaddr_in( srcport, srcaddr6 )
2049
- sock.bind( sockaddr )
2050
- sockaddr = Socket.pack_sockaddr_in( dstport, ns )
2051
- sock.connect(sockaddr)
2054
+ sock=nil
2055
+ if (/java/=~RUBY_PLATFORM)
2056
+ sock = TCPSocket.new(ns, dstport, srcaddr, srcport)
2057
+ # We need to use Socket.new rather than TCPSocket.new because of
2058
+ # a bug with TCPSocket#recvfrom in Windows
2059
+ # But this breaks JRuby
2060
+ else
2061
+ sock = Socket.new( Socket::AF_INET6, Socket::SOCK_STREAM, 0 )
2062
+ sockaddr = Socket.pack_sockaddr_in( srcport, srcaddr6 )
2063
+ sock.bind( sockaddr )
2064
+ sockaddr = Socket.pack_sockaddr_in( dstport, ns )
2065
+ sock.connect(sockaddr)
2066
+ end
2067
+
2052
2068
  if sock==nil
2053
2069
  @errorstring=('connection failed(IPv6 socket failure)')
2054
2070
  print ";; ERROR: send_tcp: IPv6 connection to #{ns}" +
@@ -2073,11 +2089,19 @@ module Net
2073
2089
  end
2074
2090
 
2075
2091
 
2076
- sock = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
2077
- sockaddr = Socket.pack_sockaddr_in( srcport, srcaddr )
2078
- sock.bind( sockaddr )
2079
- sockaddr = Socket.pack_sockaddr_in( dstport, ns )
2080
- sock.connect(sockaddr)
2092
+ sock=nil
2093
+ if (/java/=~RUBY_PLATFORM)
2094
+ sock = TCPSocket.new(ns, dstport, srcaddr, srcport)
2095
+ # We need to use Socket.new rather than TCPSocket.new because of
2096
+ # a bug with TCPSocket#recvfrom in Windows
2097
+ # But this breaks JRuby
2098
+ else
2099
+ sock = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
2100
+ sockaddr = Socket.pack_sockaddr_in( srcport, srcaddr )
2101
+ sock.bind( sockaddr )
2102
+ sockaddr = Socket.pack_sockaddr_in( dstport, ns )
2103
+ sock.connect(sockaddr)
2104
+ end
2081
2105
 
2082
2106
 
2083
2107
  end
data/test/tc_axfr.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  require 'socket'
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestEscapedChars < Test::Unit::TestCase
data/test/tc_header.rb CHANGED
@@ -1,91 +1,92 @@
1
- # The contents of this file are subject to the Mozilla
2
- # Public Licence Version 1.1 (the "Licence"); you may
3
- # not use this file except in compliance with the
4
- # Licence. You may obtain a copy of the Licence at
5
- # http://www.mozilla.org/MPL
6
- # Software distributed under the Licence is distributed
7
- # on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
8
- # either express or implied. See the Licence of the
9
- # specific language governing rights and limitations
10
- # under the Licence.
11
- # The Original Code is pNet::DNS.
12
- # The Initial Developer of the Original Code is
13
- # Nominet UK (www.nominet.org.uk). Portions created by
14
- # Nominet UK are Copyright (c) Nominet UK 2006.
15
- # All rights reserved.
16
- require 'test/unit'
17
- require 'Net/DNS'
18
- class TestHeader < Test::Unit::TestCase
19
- def test_header
20
- header = Net::DNS::Header.new();
21
- assert(header, "new() returned something")
22
-
23
- header.id=41
24
- assert_equal(header.id, 41, "id() works")
25
-
26
- header.qr=1
27
- assert_equal(header.qr, 1, "qr() works")
28
-
29
- header.opcode="QUERY"
30
- assert_equal(header.opcode, "QUERY", "opcode() works")
31
-
32
- header.aa=1
33
- assert_equal(header.aa, 1, "aa() works")
34
-
35
- header.tc=0
36
- assert_equal(header.tc, 0, "tc() works")
37
-
38
- header.rd=1
39
- assert_equal(header.rd, 1, "rd() works")
40
-
41
- header.ra=1
42
- assert_equal(header.ra, 1, "ra() works")
43
-
44
- header.qr=1
45
- assert_equal(header.qr, 1, "qr() works")
46
-
47
- header.rcode="NOERROR"
48
- assert_equal(header.rcode, "NOERROR", "rcode() works")
49
-
50
- header.qdcount=1
51
- header.ancount=2
52
- header.nscount=3
53
- header.arcount=3
54
-
55
-
56
- # Reenable when support for CD is there
57
- #header.cd=0
58
- #assert_equal(header.cd, 0, "cd() works")
59
- puts(header.inspect)
60
- data = header.data;
61
-
62
- header2 = Net::DNS::Header.new(data);
63
- puts(header2.inspect)
64
-
65
- assert(header==(header2), 'Headers are the same');
66
-
67
- #
68
- # Is $header->string remotely sane?
69
- #
70
- assert(header.inspect =~ /opcode = QUERY/, 'string() has opcode correct');
71
- assert(header.inspect =~ /ancount = 2/, 'string() has ancount correct');
72
-
73
- header = Net::DNS::Header.new;
74
-
75
- #
76
- # Check that the aliases work properly.
77
- #
78
- header.zocount=(0);
79
- header.prcount=(1);
80
- header.upcount=(2);
81
- header.adcount=(3);
82
-
83
- assert_equal(header.zocount, 0, 'zocount works');
84
- assert_equal(header.prcount, 1, 'prcount works');
85
- assert_equal(header.upcount, 2, 'upcount works');
86
- assert_equal(header.adcount, 3, 'adcount works');
87
-
88
-
89
-
90
- end
91
- end
1
+ # The contents of this file are subject to the Mozilla
2
+ # Public Licence Version 1.1 (the "Licence"); you may
3
+ # not use this file except in compliance with the
4
+ # Licence. You may obtain a copy of the Licence at
5
+ # http://www.mozilla.org/MPL
6
+ # Software distributed under the Licence is distributed
7
+ # on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
8
+ # either express or implied. See the Licence of the
9
+ # specific language governing rights and limitations
10
+ # under the Licence.
11
+ # The Original Code is pNet::DNS.
12
+ # The Initial Developer of the Original Code is
13
+ # Nominet UK (www.nominet.org.uk). Portions created by
14
+ # Nominet UK are Copyright (c) Nominet UK 2006.
15
+ # All rights reserved.
16
+ require 'rubygems'
17
+ require 'test/unit'
18
+ require 'Net/DNS'
19
+ class TestHeader < Test::Unit::TestCase
20
+ def test_header
21
+ header = Net::DNS::Header.new();
22
+ assert(header, "new() returned something")
23
+
24
+ header.id=41
25
+ assert_equal(header.id, 41, "id() works")
26
+
27
+ header.qr=1
28
+ assert_equal(header.qr, 1, "qr() works")
29
+
30
+ header.opcode="QUERY"
31
+ assert_equal(header.opcode, "QUERY", "opcode() works")
32
+
33
+ header.aa=1
34
+ assert_equal(header.aa, 1, "aa() works")
35
+
36
+ header.tc=0
37
+ assert_equal(header.tc, 0, "tc() works")
38
+
39
+ header.rd=1
40
+ assert_equal(header.rd, 1, "rd() works")
41
+
42
+ header.ra=1
43
+ assert_equal(header.ra, 1, "ra() works")
44
+
45
+ header.qr=1
46
+ assert_equal(header.qr, 1, "qr() works")
47
+
48
+ header.rcode="NOERROR"
49
+ assert_equal(header.rcode, "NOERROR", "rcode() works")
50
+
51
+ header.qdcount=1
52
+ header.ancount=2
53
+ header.nscount=3
54
+ header.arcount=3
55
+
56
+
57
+ # Reenable when support for CD is there
58
+ #header.cd=0
59
+ #assert_equal(header.cd, 0, "cd() works")
60
+ puts(header.inspect)
61
+ data = header.data;
62
+
63
+ header2 = Net::DNS::Header.new(data);
64
+ puts(header2.inspect)
65
+
66
+ assert(header==(header2), 'Headers are the same');
67
+
68
+ #
69
+ # Is $header->string remotely sane?
70
+ #
71
+ assert(header.inspect =~ /opcode = QUERY/, 'string() has opcode correct');
72
+ assert(header.inspect =~ /ancount = 2/, 'string() has ancount correct');
73
+
74
+ header = Net::DNS::Header.new;
75
+
76
+ #
77
+ # Check that the aliases work properly.
78
+ #
79
+ header.zocount=(0);
80
+ header.prcount=(1);
81
+ header.upcount=(2);
82
+ header.adcount=(3);
83
+
84
+ assert_equal(header.zocount, 0, 'zocount works');
85
+ assert_equal(header.prcount, 1, 'prcount works');
86
+ assert_equal(header.upcount, 2, 'upcount works');
87
+ assert_equal(header.adcount, 3, 'adcount works');
88
+
89
+
90
+
91
+ end
92
+ end
data/test/tc_inet6.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  require 'socket'
data/test/tc_misc.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestMisc < Test::Unit::TestCase
data/test/tc_online.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  require 'socket'
data/test/tc_packet.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestPacket < Test::Unit::TestCase
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestPacketUniquePush < Test::Unit::TestCase
data/test/tc_question.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestQuestion < Test::Unit::TestCase
data/test/tc_recurse.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  require 'Net/DNS/Resolver/Recurse'
data/test/tc_res_env.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestResolverEnv < Test::Unit::TestCase
data/test/tc_res_file.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestAResolverFile < Test::Unit::TestCase
data/test/tc_res_opt.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestResOpt < Test::Unit::TestCase
data/test/tc_resolver.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestResolver < Test::Unit::TestCase
data/test/tc_rr-opt.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestRrOpt < Test::Unit::TestCase
data/test/tc_rr-rrsort.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestRrRrSort < Test::Unit::TestCase
data/test/tc_rr-txt.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestRrTest < Test::Unit::TestCase
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestRrUnknown < Test::Unit::TestCase
data/test/tc_rr.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestRR < Test::Unit::TestCase
data/test/tc_tcp.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestTcp < Test::Unit::TestCase
data/test/tc_thread.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'Net/DNS'
3
+
4
+ class TestOnline < Test::Unit::TestCase
5
+ def run_threads(d)
6
+ ts = []
7
+ 15.times do |i|
8
+ t = Thread.new {
9
+ begin
10
+ p "Querying " + i.to_s
11
+ p d.query("nominet.org.uk")
12
+ rescue (Exception)
13
+ p "Exception "
14
+ end
15
+ }
16
+ ts.push(t)
17
+ end
18
+ 15.times do |i|
19
+ ts[i].join
20
+ end
21
+ end
22
+
23
+ def test_non_persistent
24
+ d = Net::DNS::Resolver.new(:nameserver => "213.248.199.17")
25
+ d.persistent_udp=false
26
+ run_threads(d)
27
+ end
28
+
29
+ def test_persistent
30
+ d = Net::DNS::Resolver.new(:nameserver => "213.248.199.17")
31
+ d.persistent_udp=true
32
+ run_threads(d)
33
+ end
34
+ end
data/test/tc_tkey.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  require "digest/md5"
@@ -89,7 +90,7 @@ class TestTKey < Test::Unit::TestCase
89
90
  :key => key,
90
91
  :sign_func => Proc.new { |key,data|
91
92
  # OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new("md5"), key, data)
92
- hmac = Digest::MD5.new(key)
93
+ hmac = Digest::MD5.new.update(key)
93
94
  hmac.update(data)
94
95
  return hmac.digest
95
96
  },
data/test/tc_udp.rb ADDED
@@ -0,0 +1,35 @@
1
+ # The contents of this file are subject to the Mozilla
2
+ # Public Licence Version 1.1 (the "Licence"); you may
3
+ # not use this file except in compliance with the
4
+ # Licence. You may obtain a copy of the Licence at
5
+ # http://www.mozilla.org/MPL
6
+ # Software distributed under the Licence is distributed
7
+ # on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
8
+ # either express or implied. See the Licence of the
9
+ # specific language governing rights and limitations
10
+ # under the Licence.
11
+ # The Original Code is pNet::DNS.
12
+ # The Initial Developer of the Original Code is
13
+ # Nominet UK (www.nominet.org.uk). Portions created by
14
+ # Nominet UK are Copyright (c) Nominet UK 2006.
15
+ # All rights reserved.
16
+ require 'rubygems'
17
+ require 'test/unit'
18
+ require 'Net/DNS'
19
+ class TestTcp < Test::Unit::TestCase
20
+ def test_TCP
21
+ res = Net::DNS::Resolver.new(:config_file=>"/etc/resolv.conf")
22
+ res.debug=true
23
+ res.usevc = false
24
+ ret=res.query("example.com")
25
+ assert(ret.is_a?(Net::DNS::Packet))
26
+ end
27
+ def test_TCP_port
28
+ res = Net::DNS::Resolver.new(:config_file=>"/etc/resolv.conf")
29
+ res.debug=true
30
+ res.usevc = false
31
+ res.srcport=rand(60000) + 1025
32
+ ret=res.query("example.com")
33
+ assert(ret.is_a?(Net::DNS::Packet))
34
+ end
35
+ end
data/test/tc_update.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  # Nominet UK (www.nominet.org.uk). Portions created by
14
14
  # Nominet UK are Copyright (c) Nominet UK 2006.
15
15
  # All rights reserved.
16
+ require 'rubygems'
16
17
  require 'test/unit'
17
18
  require 'Net/DNS'
18
19
  class TestUpdate < Test::Unit::TestCase
data/test/ts_online.rb CHANGED
@@ -1,34 +1,34 @@
1
- # The contents of this file are subject to the Mozilla
2
- # Public Licence Version 1.1 (the "Licence"); you may
3
- # not use this file except in compliance with the
4
- # Licence. You may obtain a copy of the Licence at
5
- # http://www.mozilla.org/MPL
6
- # Software distributed under the Licence is distributed
7
- # on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
8
- # either express or implied. See the Licence of the
9
- # specific language governing rights and limitations
10
- # under the Licence.
11
- # The Original Code is pNet::DNS.
12
- # The Initial Developer of the Original Code is
13
- # Nominet UK (www.nominet.org.uk). Portions created by
14
- # Nominet UK are Copyright (c) Nominet UK 2006.
15
- # All rights reserved.
16
- require "test/unit"
17
- # Disable these tests if we're not online
18
- require 'socket'
19
- sock = UDPSocket.new()
20
- begin
21
- sock.connect('193.0.14.129', # k.root-servers.net.
22
- '25')
23
- # OK - online and ready to go
24
- require "test/tc_inet6.rb"
25
- require "test/tc_online.rb"
26
- require "test/tc_recurse.rb"
27
- require "test/tc_resolver.rb"
28
- require "test/tc_tcp.rb"
29
- require "test/tc_axfr.rb"
30
- rescue Error
31
- puts "Cannot bind to socket:\n\t"+$!+"\n"
32
- puts "This is an indication you have network problems\n"
33
- puts "\n\nNo online tests will be run!!\n\n"
34
- end
1
+ # The contents of this file are subject to the Mozilla
2
+ # Public Licence Version 1.1 (the "Licence"); you may
3
+ # not use this file except in compliance with the
4
+ # Licence. You may obtain a copy of the Licence at
5
+ # http://www.mozilla.org/MPL
6
+ # Software distributed under the Licence is distributed
7
+ # on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
8
+ # either express or implied. See the Licence of the
9
+ # specific language governing rights and limitations
10
+ # under the Licence.
11
+ # The Original Code is pNet::DNS.
12
+ # The Initial Developer of the Original Code is
13
+ # Nominet UK (www.nominet.org.uk). Portions created by
14
+ # Nominet UK are Copyright (c) Nominet UK 2006.
15
+ # All rights reserved.
16
+ require "test/unit"
17
+ # Disable these tests if we're not online
18
+ require 'socket'
19
+ sock = UDPSocket.new()
20
+ begin
21
+ sock.connect('193.0.14.129', # k.root-servers.net.
22
+ 25)
23
+ # OK - online and ready to go
24
+ require "test/tc_inet6.rb"
25
+ require "test/tc_online.rb"
26
+ require "test/tc_recurse.rb"
27
+ require "test/tc_resolver.rb"
28
+ require "test/tc_tcp.rb"
29
+ require "test/tc_axfr.rb"
30
+ rescue Error
31
+ puts "Cannot bind to socket:\n\t"+$!+"\n"
32
+ puts "This is an indication you have network problems\n"
33
+ puts "\n\nNo online tests will be run!!\n\n"
34
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: pNet-DNS
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-05-29 00:00:00 +01:00
6
+ version: 1.0.1
7
+ date: 2007-07-12 00:00:00 +01:00
8
8
  summary: Ruby port of perl Net::DNS
9
9
  require_paths:
10
10
  - lib
@@ -51,24 +51,23 @@ files:
51
51
  - test/tc_rr-unknown.rb
52
52
  - test/tc_rr.rb
53
53
  - test/tc_tcp.rb
54
+ - test/tc_thread.rb
54
55
  - test/tc_tkey.rb
56
+ - test/tc_udp.rb
55
57
  - test/tc_update.rb
56
58
  - test/ts_netdns.rb
57
59
  - test/ts_offline.rb
58
60
  - test/ts_online.rb
59
61
  - lib/Net
60
62
  - lib/Net/DNS
61
- - lib/Net/DNS.rb
62
63
  - lib/Net/DNS/Header.rb
63
64
  - lib/Net/DNS/Nameserver.rb
64
65
  - lib/Net/DNS/Packet.rb
65
66
  - lib/Net/DNS/Question.rb
66
67
  - lib/Net/DNS/Resolver
68
+ - lib/Net/DNS/Resolver/Recurse.rb
67
69
  - lib/Net/DNS/Resolver.rb
68
70
  - lib/Net/DNS/RR
69
- - lib/Net/DNS/RR.rb
70
- - lib/Net/DNS/Update.rb
71
- - lib/Net/DNS/Resolver/Recurse.rb
72
71
  - lib/Net/DNS/RR/A.rb
73
72
  - lib/Net/DNS/RR/AAAA.rb
74
73
  - lib/Net/DNS/RR/AFSDB.rb
@@ -103,6 +102,9 @@ files:
103
102
  - lib/Net/DNS/RR/TXT.rb
104
103
  - lib/Net/DNS/RR/UNKNOWN.rb
105
104
  - lib/Net/DNS/RR/X25.rb
105
+ - lib/Net/DNS/RR.rb
106
+ - lib/Net/DNS/Update.rb
107
+ - lib/Net/DNS.rb
106
108
  - README
107
109
  test_files:
108
110
  - test/ts_offline.rb