pNet-DNS 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/Net/DNS/Resolver.rb +27 -20
 - data/test/tc_axfr.rb +30 -0
 - data/test/ts_online.rb +1 -0
 - metadata +3 -2
 
    
        data/lib/Net/DNS/Resolver.rb
    CHANGED
    
    | 
         @@ -164,8 +164,8 @@ module Net 
     | 
|
| 
       164 
164 
     | 
    
         
             
                  # @TODO@ should get config working on Windows
         
     | 
| 
       165 
165 
     | 
    
         
             
                  os = Config::CONFIG['host_os'] # e.g. "mswin32"
         
     | 
| 
       166 
166 
     | 
    
         
             
                  if (os=='mswin32')
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
            #        print "WARNING: You must have \\etc\\resolv.conf for Net::DNS to work correctly\n"
         
     | 
| 
      
 167 
     | 
    
         
            +
                    # Should we print a warning here? We don't *really* need the file...
         
     | 
| 
      
 168 
     | 
    
         
            +
                    #        print "WARNING: You must have \\etc\\resolv.conf for Net::DNS to work correctly\n"
         
     | 
| 
       169 
169 
     | 
    
         
             
                  end
         
     | 
| 
       170 
170 
     | 
    
         
             
                  # /etc/resolv.conf required
         
     | 
| 
       171 
171 
     | 
    
         | 
| 
         @@ -1594,9 +1594,9 @@ module Net 
     | 
|
| 
       1594 
1594 
     | 
    
         
             
                  #    socket = nil
         
     | 
| 
       1595 
1595 
     | 
    
         
             
                  #
         
     | 
| 
       1596 
1596 
     | 
    
         
             
                  def bgisready(socket)
         
     | 
| 
       1597 
     | 
    
         
            -
             
     | 
| 
       1598 
     | 
    
         
            -
             
     | 
| 
       1599 
     | 
    
         
            -
            #        return socket.ready? > 0
         
     | 
| 
      
 1597 
     | 
    
         
            +
                    ready = IO.select([socket], nil, nil, 0)
         
     | 
| 
      
 1598 
     | 
    
         
            +
                    return ready!=nil
         
     | 
| 
      
 1599 
     | 
    
         
            +
                    #        return socket.ready? > 0
         
     | 
| 
       1600 
1600 
     | 
    
         
             
                  end
         
     | 
| 
       1601 
1601 
     | 
    
         | 
| 
       1602 
1602 
     | 
    
         
             
                  def make_query_packet(args)
         
     | 
| 
         @@ -1696,9 +1696,14 @@ module Net 
     | 
|
| 
       1696 
1696 
     | 
    
         
             
                    zone=[]
         
     | 
| 
       1697 
1697 
     | 
    
         | 
| 
       1698 
1698 
     | 
    
         
             
                    if (axfr_start(args[0], args[1]))
         
     | 
| 
       1699 
     | 
    
         
            -
                       
     | 
| 
       1700 
     | 
    
         
            -
                       
     | 
| 
       1701 
     | 
    
         
            -
             
     | 
| 
      
 1699 
     | 
    
         
            +
                      continueLoop= true
         
     | 
| 
      
 1700 
     | 
    
         
            +
                      err = nil
         
     | 
| 
      
 1701 
     | 
    
         
            +
                      while (continueLoop)
         
     | 
| 
      
 1702 
     | 
    
         
            +
                        rr, err = axfr_next
         
     | 
| 
      
 1703 
     | 
    
         
            +
                        continueLoop = rr!=nil && err==nil
         
     | 
| 
      
 1704 
     | 
    
         
            +
                        if (continueLoop)
         
     | 
| 
      
 1705 
     | 
    
         
            +
                          zone.push(rr)
         
     | 
| 
      
 1706 
     | 
    
         
            +
                        end
         
     | 
| 
       1702 
1707 
     | 
    
         
             
                      end
         
     | 
| 
       1703 
1708 
     | 
    
         
             
                      zone = [] if err
         
     | 
| 
       1704 
1709 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1809,8 +1814,9 @@ module Net 
     | 
|
| 
       1809 
1814 
     | 
    
         
             
                  def axfr_next
         
     | 
| 
       1810 
1815 
     | 
    
         
             
                    err  = ''
         
     | 
| 
       1811 
1816 
     | 
    
         | 
| 
       1812 
     | 
    
         
            -
                     
     | 
| 
       1813 
     | 
    
         
            -
             
     | 
| 
      
 1817 
     | 
    
         
            +
                    # @todo this can't be right!!!
         
     | 
| 
      
 1818 
     | 
    
         
            +
                    unless (@axfr_rr!=[])
         
     | 
| 
      
 1819 
     | 
    
         
            +
                      unless (@axfr_sock!=nil)
         
     | 
| 
       1814 
1820 
     | 
    
         
             
                        err = 'no zone transfer in progress'
         
     | 
| 
       1815 
1821 
     | 
    
         | 
| 
       1816 
1822 
     | 
    
         
             
                        print ";; #{err}\n" if @debug
         
     | 
| 
         @@ -1820,12 +1826,13 @@ module Net 
     | 
|
| 
       1820 
1826 
     | 
    
         
             
                      end
         
     | 
| 
       1821 
1827 
     | 
    
         | 
| 
       1822 
1828 
     | 
    
         
             
                      timeout = @tcp_timeout
         
     | 
| 
      
 1829 
     | 
    
         
            +
                      sock = @axfr_sock
         
     | 
| 
       1823 
1830 
     | 
    
         | 
| 
       1824 
1831 
     | 
    
         
             
                      #--------------------------------------------------------------
         
     | 
| 
       1825 
1832 
     | 
    
         
             
                      # Read the length of the response packet.
         
     | 
| 
       1826 
1833 
     | 
    
         
             
                      #--------------------------------------------------------------
         
     | 
| 
       1827 
1834 
     | 
    
         | 
| 
       1828 
     | 
    
         
            -
            #          ready = sock.wait(timeout)
         
     | 
| 
      
 1835 
     | 
    
         
            +
                      #          ready = sock.wait(timeout)
         
     | 
| 
       1829 
1836 
     | 
    
         
             
                      ready = IO.select([sock], nil, nil, timeout)
         
     | 
| 
       1830 
1837 
     | 
    
         
             
                      unless (ready)
         
     | 
| 
       1831 
1838 
     | 
    
         
             
                        err = 'timeout';
         
     | 
| 
         @@ -1833,7 +1840,7 @@ module Net 
     | 
|
| 
       1833 
1840 
     | 
    
         
             
                        return nil, err
         
     | 
| 
       1834 
1841 
     | 
    
         
             
                      end
         
     | 
| 
       1835 
1842 
     | 
    
         | 
| 
       1836 
     | 
    
         
            -
                      buf, from = read_tcp( 
     | 
| 
      
 1843 
     | 
    
         
            +
                      buf, from = read_tcp(sock, Net::DNS::INT16SZ, @debug)
         
     | 
| 
       1837 
1844 
     | 
    
         
             
                      unless (buf.length > 0)
         
     | 
| 
       1838 
1845 
     | 
    
         
             
                        err = 'truncated zone transfer'
         
     | 
| 
       1839 
1846 
     | 
    
         
             
                        @errorstring=(err)
         
     | 
| 
         @@ -1852,25 +1859,25 @@ module Net 
     | 
|
| 
       1852 
1859 
     | 
    
         
             
                      #--------------------------------------------------------------
         
     | 
| 
       1853 
1860 
     | 
    
         | 
| 
       1854 
1861 
     | 
    
         
             
                      ready = IO.select([sock], nil, nil, timeout)
         
     | 
| 
       1855 
     | 
    
         
            -
            #          ready = sel.wait(timeout) # should be sock.wait, anyway!
         
     | 
| 
      
 1862 
     | 
    
         
            +
                      #          ready = sel.wait(timeout) # should be sock.wait, anyway!
         
     | 
| 
       1856 
1863 
     | 
    
         
             
                      unless (ready)
         
     | 
| 
       1857 
1864 
     | 
    
         
             
                        err = 'timeout'
         
     | 
| 
       1858 
1865 
     | 
    
         
             
                        @errorstring=(err)
         
     | 
| 
       1859 
1866 
     | 
    
         
             
                        return nil, err
         
     | 
| 
       1860 
1867 
     | 
    
         
             
                      end
         
     | 
| 
       1861 
1868 
     | 
    
         | 
| 
       1862 
     | 
    
         
            -
                      buf, from = read_tcp( 
     | 
| 
      
 1869 
     | 
    
         
            +
                      buf, from = read_tcp(sock, len, @debug)
         
     | 
| 
       1863 
1870 
     | 
    
         | 
| 
       1864 
     | 
    
         
            -
                      print ';; received ' + buf.length +  " bytes\n" if @debug
         
     | 
| 
      
 1871 
     | 
    
         
            +
                      print ';; received ' + buf.length.to_s +  " bytes\n" if @debug
         
     | 
| 
       1865 
1872 
     | 
    
         | 
| 
       1866 
1873 
     | 
    
         
             
                      unless (buf.length == len)
         
     | 
| 
       1867 
     | 
    
         
            -
                        err = "expected #{len} bytes, received " + buf.length
         
     | 
| 
      
 1874 
     | 
    
         
            +
                        err = "expected #{len} bytes, received " + buf.length.to_s
         
     | 
| 
       1868 
1875 
     | 
    
         
             
                        @errorstring=(err)
         
     | 
| 
       1869 
1876 
     | 
    
         
             
                        print ";; #{err}\n" if @debug
         
     | 
| 
       1870 
1877 
     | 
    
         
             
                        return nil, err
         
     | 
| 
       1871 
1878 
     | 
    
         
             
                      end
         
     | 
| 
       1872 
1879 
     | 
    
         | 
| 
       1873 
     | 
    
         
            -
                      ans, err = Net::DNS::Packet. 
     | 
| 
      
 1880 
     | 
    
         
            +
                      ans, err = Net::DNS::Packet.new_from_binary(buf, @debug)
         
     | 
| 
       1874 
1881 
     | 
    
         | 
| 
       1875 
1882 
     | 
    
         
             
                      if (ans)
         
     | 
| 
       1876 
1883 
     | 
    
         
             
                        if (ans.header.rcode != 'NOERROR') 
         
     | 
| 
         @@ -1894,8 +1901,8 @@ module Net 
     | 
|
| 
       1894 
1901 
     | 
    
         | 
| 
       1895 
1902 
     | 
    
         
             
                      ans.answer.each do |rr|
         
     | 
| 
       1896 
1903 
     | 
    
         
             
                        if (rr.type == 'SOA')
         
     | 
| 
       1897 
     | 
    
         
            -
                          axfr_soa_count +=1
         
     | 
| 
       1898 
     | 
    
         
            -
                          if (axfr_soa_count < 2)
         
     | 
| 
      
 1904 
     | 
    
         
            +
                          @axfr_soa_count +=1
         
     | 
| 
      
 1905 
     | 
    
         
            +
                          if (@axfr_soa_count < 2)
         
     | 
| 
       1899 
1906 
     | 
    
         
             
                            @axfr_rr.push(rr)
         
     | 
| 
       1900 
1907 
     | 
    
         
             
                          end
         
     | 
| 
       1901 
1908 
     | 
    
         
             
                        else
         
     | 
| 
         @@ -1914,7 +1921,7 @@ module Net 
     | 
|
| 
       1914 
1921 
     | 
    
         | 
| 
       1915 
1922 
     | 
    
         
             
                    rr = @axfr_rr.shift
         
     | 
| 
       1916 
1923 
     | 
    
         | 
| 
       1917 
     | 
    
         
            -
                    return rr # ,  
     | 
| 
      
 1924 
     | 
    
         
            +
                    return rr # , nil)
         
     | 
| 
       1918 
1925 
     | 
    
         
             
                  end
         
     | 
| 
       1919 
1926 
     | 
    
         | 
| 
       1920 
1927 
     | 
    
         
             
                  def dnssec=(new_val)
         
     | 
    
        data/test/tc_axfr.rb
    ADDED
    
    | 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            require 'socket'
         
     | 
| 
      
 19 
     | 
    
         
            +
            class TestAxfr < Test::Unit::TestCase
         
     | 
| 
      
 20 
     | 
    
         
            +
              def test_carlos
         
     | 
| 
      
 21 
     | 
    
         
            +
                res = Net::DNS::Resolver.new()
         
     | 
| 
      
 22 
     | 
    
         
            +
                res.nameservers=('ns1.net-dns.org')
         
     | 
| 
      
 23 
     | 
    
         
            +
                res.debug=false
         
     | 
| 
      
 24 
     | 
    
         
            +
                
         
     | 
| 
      
 25 
     | 
    
         
            +
                zone = res.axfr("net-dns.org")
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                assert(zone.size > 0)
         
     | 
| 
      
 28 
     | 
    
         
            +
                
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
    
        data/test/ts_online.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -3,8 +3,8 @@ rubygems_version: 0.9.0 
     | 
|
| 
       3 
3 
     | 
    
         
             
            specification_version: 1
         
     | 
| 
       4 
4 
     | 
    
         
             
            name: pNet-DNS
         
     | 
| 
       5 
5 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       6 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
       7 
     | 
    
         
            -
            date: 2006-12- 
     | 
| 
      
 6 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
      
 7 
     | 
    
         
            +
            date: 2006-12-19 00:00:00 +00:00
         
     | 
| 
       8 
8 
     | 
    
         
             
            summary: Ruby port of perl Net::DNS
         
     | 
| 
       9 
9 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -31,6 +31,7 @@ authors: 
     | 
|
| 
       31 
31 
     | 
    
         
             
            files: 
         
     | 
| 
       32 
32 
     | 
    
         
             
            - test/custom.txt
         
     | 
| 
       33 
33 
     | 
    
         
             
            - test/resolv.conf
         
     | 
| 
      
 34 
     | 
    
         
            +
            - test/tc_axfr.rb
         
     | 
| 
       34 
35 
     | 
    
         
             
            - test/tc_escapedchars.rb
         
     | 
| 
       35 
36 
     | 
    
         
             
            - test/tc_header.rb
         
     | 
| 
       36 
37 
     | 
    
         
             
            - test/tc_inet6.rb
         
     |