hostdig 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in hostdig.gemspec
4
+ gemspec
@@ -0,0 +1,4 @@
1
+ HostDig
2
+ ======
3
+
4
+ A simple tool to gather DNS information for a domain name.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'hostdig/digtool'
5
+
6
+ options = {}
7
+
8
+ optparse = OptionParser.new do | opts |
9
+ opts.banner = "Usage: digger.rb host [options]"
10
+ options[:type] = nil
11
+ options[:outfile] = nil
12
+
13
+ opts.on('-t','--type TYPE', 'Specify record type to request. e.g. A, MX, CNAME, TXT ...') do |type|
14
+ options[:type] = type
15
+ end
16
+
17
+ opts.on('-o','--outfile [FILE]', 'Write output to FILE. If left blank, output will write to a file matching the hostname') do |file|
18
+ options[:outfile] = file.nil? ? :default : file
19
+ end
20
+
21
+ opts.on('-h', '--help', 'Display help') do
22
+ puts opts
23
+ exit
24
+ end
25
+ end
26
+
27
+ optparse.parse!
28
+
29
+ if ARGV[0].nil?
30
+ puts "ERROR: no host provided"
31
+ puts optparse.help
32
+ exit 1
33
+ end
34
+
35
+ host = ARGV[0]
36
+
37
+ options[:type] = "A" if options[:type].nil?
38
+ options[:outfile] = host if options[:outfile] == :default
39
+
40
+ mydig = HostDig::DigTool.new
41
+ result = mydig.dig(host, options[:type])
42
+
43
+ if options[:outfile].nil?
44
+ puts result
45
+ else
46
+ File.open(options[:outfile], 'w') {|f| f.write(result)}
47
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "hostdig/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "hostdig"
7
+ s.version = HostDig::VERSION
8
+ s.authors = ["Josh Cody"]
9
+ s.email = ["joshcody@taklbox.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Lookup DNS records for a host}
12
+ s.description = %q{Simple tool for querying DNS servers for host information}
13
+
14
+ s.rubyforge_project = "hostdig"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,5 @@
1
+ require "hostdig/version"
2
+
3
+ module HostDig
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,11 @@
1
+
2
+ module HostDig
3
+ class DigTool
4
+ def dig(host, type)
5
+ host_result = `host -t ns #{host}`
6
+ primary_ns = host_result.split("\n")[0].split.last
7
+ dig_result = `dig @#{primary_ns} #{host} #{type}`
8
+ dig_result
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module HostDig
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hostdig
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Josh Cody
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-13 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Simple tool for querying DNS servers for host information
23
+ email:
24
+ - joshcody@taklbox.com
25
+ executables:
26
+ - digger
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.md
35
+ - Rakefile
36
+ - bin/digger
37
+ - hostdig.gemspec
38
+ - lib/hostdig.rb
39
+ - lib/hostdig/digtool.rb
40
+ - lib/hostdig/version.rb
41
+ has_rdoc: true
42
+ homepage: ""
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project: hostdig
71
+ rubygems_version: 1.6.2
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Lookup DNS records for a host
75
+ test_files: []
76
+