dnsutils 2.0.2 → 2.0.3
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.
- checksums.yaml +4 -4
 - data/README.md +12 -0
 - data/lib/dnslazy.rb +96 -0
 - data/lib/version.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: afd7bb1ca403821d4031102c20440894c3354091
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 64d6c7cd5ca4d0ae34a5f69e0966e2e278d1475f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c69bb2f4bf523783e526e8782a64253e4d79562f176cf3d048f19627642e17077432288e52bc28f297fe21920ecd9f54fb0b55662425b917c7697c5c85b636c5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fee6acf1c556b243df85a6a1477e5c2bdd9544360f40138fc31fb1f125b8e35aaa9b12c585e9813c0225e2b7b29a62a8a67849eba994d27b6a9065ce5a8c8006
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -181,6 +181,17 @@ little message telling you so: 
     | 
|
| 
       181 
181 
     | 
    
         | 
| 
       182 
182 
     | 
    
         
             
            And that's pretty much all there is to it!
         
     | 
| 
       183 
183 
     | 
    
         | 
| 
      
 184 
     | 
    
         
            +
            ### dnslazy
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
            A simple utility that lets you put the IP address you want in the domain name.
         
     | 
| 
      
 187 
     | 
    
         
            +
            For example, 1.2.3.4.domain.com will resolve to 1.2.3.4.
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
            It's simply run with no special arguments
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                $ dnslazy
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
            It currently only supports IPv4.
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
       184 
195 
     | 
    
         
             
            ### dnsmastermind
         
     | 
| 
       185 
196 
     | 
    
         | 
| 
       186 
197 
     | 
    
         
             
            `dnsmastermind` is a silly little game I wrote to demonstrate how DNS works.
         
     | 
| 
         @@ -234,3 +245,4 @@ There are no tests for these utilities, so be warned. :) 
     | 
|
| 
       234 
245 
     | 
    
         
             
            * 2.0.0 - Initial port from the old DNS architecture
         
     | 
| 
       235 
246 
     | 
    
         
             
            * 2.0.1 - Small documentation updates
         
     | 
| 
       236 
247 
     | 
    
         
             
            * 2.0.2 - Add support for PTR records (reverse DNS)
         
     | 
| 
      
 248 
     | 
    
         
            +
            * 2.0.3 - Added dnslazy
         
     | 
    
        data/lib/dnslazy.rb
    ADDED
    
    | 
         @@ -0,0 +1,96 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ##
         
     | 
| 
      
 2 
     | 
    
         
            +
            # dnslogger.rb
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Created July 22, 2015
         
     | 
| 
      
 4 
     | 
    
         
            +
            # By Ron Bowes
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            # See: LICENSE.md
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            # Implements a stupidly simple DNS server.
         
     | 
| 
      
 9 
     | 
    
         
            +
            ##
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            require 'nesser'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'socket'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'trollop'
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            require_relative 'version'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            module DnsUtils
         
     | 
| 
      
 18 
     | 
    
         
            +
              # version info
         
     | 
| 
      
 19 
     | 
    
         
            +
              MY_NAME = "dnslazy (#{NAME}) #{VERSION}"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              Thread.abort_on_exception = true
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # Options
         
     | 
| 
      
 24 
     | 
    
         
            +
              opts = Trollop::options do
         
     | 
| 
      
 25 
     | 
    
         
            +
                version(MY_NAME)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                opt :version, "Get the #{MY_NAME} version (spoiler alert)", :type => :boolean, :default => false
         
     | 
| 
      
 28 
     | 
    
         
            +
                opt :host, "The ip address to listen on", :type => :string, :default => "0.0.0.0"
         
     | 
| 
      
 29 
     | 
    
         
            +
                opt :port, "The port to listen on", :type => :integer, :default => 53
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                opt :packet_trace, "If enabled, print details about the packets", :type => :boolean, :default => false
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                opt :ttl, "The TTL value to return", :type => :integer, :default => 60
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              if opts[:port] < 0 || opts[:port] > 65535
         
     | 
| 
      
 37 
     | 
    
         
            +
                Trollop::die(:port, "must be a valid port (between 0 and 65535)")
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              puts("Starting #{MY_NAME} DNS server on #{opts[:host]}:#{opts[:port]}")
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              s = UDPSocket.new()
         
     | 
| 
      
 43 
     | 
    
         
            +
              nesser = Nesser::Nesser.new(s: s, host: opts[:host], port: opts[:port]) do |transaction|
         
     | 
| 
      
 44 
     | 
    
         
            +
                request = transaction.request
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                if(request.questions.length < 1)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  puts("The request didn't ask any questions!")
         
     | 
| 
      
 48 
     | 
    
         
            +
                  next
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                if(request.questions.length > 1)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  puts("The request asked multiple questions! This is super unusual, if you can reproduce, please report! I'd love to see an example of something that does this. :)")
         
     | 
| 
      
 53 
     | 
    
         
            +
                  next
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                question = request.questions[0]
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                # Display the long or short version of the request
         
     | 
| 
      
 59 
     | 
    
         
            +
                puts("IN: " + request.to_s(brief: !opts[:packet_trace]))
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                segments = question.name.split(/\./)[0..3]
         
     | 
| 
      
 62 
     | 
    
         
            +
                if segments.length != 4
         
     | 
| 
      
 63 
     | 
    
         
            +
                  puts("The request doesn't have enough segments! (should be a.b.c.d.domain.name)")
         
     | 
| 
      
 64 
     | 
    
         
            +
                  transaction.error!(Nesser::RCODE_NAME_ERROR)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  next
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                bad = false
         
     | 
| 
      
 69 
     | 
    
         
            +
                segments.each do |segment|
         
     | 
| 
      
 70 
     | 
    
         
            +
                  if segment !~ /^\d+$/ && !bad
         
     | 
| 
      
 71 
     | 
    
         
            +
                    puts("The request must start with an ip! (a.b.c.d.domain.name)")
         
     | 
| 
      
 72 
     | 
    
         
            +
                    bad = true
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
                if bad
         
     | 
| 
      
 76 
     | 
    
         
            +
                  transaction.error!(Nesser::RCODE_NAME_ERROR)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  next
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                ip = segments.join('.')
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                answer = Nesser::Answer.new(
         
     | 
| 
      
 83 
     | 
    
         
            +
                  name: request.questions[0].name,
         
     | 
| 
      
 84 
     | 
    
         
            +
                  type: Nesser::TYPE_A,
         
     | 
| 
      
 85 
     | 
    
         
            +
                  cls: Nesser::CLS_IN,
         
     | 
| 
      
 86 
     | 
    
         
            +
                  ttl: 10,
         
     | 
| 
      
 87 
     | 
    
         
            +
                  rr: Nesser::A.new(address: ip),
         
     | 
| 
      
 88 
     | 
    
         
            +
                )
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                transaction.answer!([answer])
         
     | 
| 
      
 91 
     | 
    
         
            +
                puts("OUT: " + transaction.response.to_s(brief: !opts[:packet_trace]))
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              # Wait for it to finish (never-ending, essentially)
         
     | 
| 
      
 95 
     | 
    
         
            +
              nesser.wait()
         
     | 
| 
      
 96 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dnsutils
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - iagox86
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-10-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -101,6 +101,7 @@ files: 
     | 
|
| 
       101 
101 
     | 
    
         
             
            - exe/dnslogger
         
     | 
| 
       102 
102 
     | 
    
         
             
            - exe/dnsmastermind
         
     | 
| 
       103 
103 
     | 
    
         
             
            - exe/dnstest
         
     | 
| 
      
 104 
     | 
    
         
            +
            - lib/dnslazy.rb
         
     | 
| 
       104 
105 
     | 
    
         
             
            - lib/dnslogger.rb
         
     | 
| 
       105 
106 
     | 
    
         
             
            - lib/dnsmastermind.rb
         
     | 
| 
       106 
107 
     | 
    
         
             
            - lib/dnstest.rb
         
     |