Sha256: f1d7e16faaa467d6629f30c1d2ea7b140895f4e61bfee102b2affd32902421c7

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

#!/usr/bin/env ruby

$:.unshift File.join(File.dirname(__FILE__), %w{.. lib})
require 'globetrotter'
require 'optparse'
require 'ostruct'
require 'dnsruby'

class GlobetrotterOptions
  def self.parse(args)
    options = OpenStruct.new
    options.domain = 'googleapis.com'
    options.ns_count_to_check = 100
    options.ns_max_age_minutes = 60
    options.timeout_seconds = 2
    options.ns_query_concurrency = 10

    opt_parser = OptionParser.new do |opts|
      opts.banner = 'Usage: globetrotter [options] example.org'
      opts.on('-q googleapis.com', String, 'Domain to look up') do |o|
        options.domain = o
      end
      opts.on('-n 100', Integer, 'Query N name servers') do |o|
        options.ns_count_to_check = o
      end
      opts.on('-t 2', Integer, 'Wait T seconds per request') do |o|
        options.timeout_seconds = o
      end
      opts.on('-p 10', Integer, 'Query P name servers in parallel') do |o|
        options.ns_query_concurrency = o
      end
      opts.on('-a 60', Integer, 'Use name servers checked less than A minutes ago') do |o|
        options.ns_max_age_minutes = o
      end
      opts.on_tail('-h', '--help', 'Display CLI help (this output)') do |o|
        puts opts.help
        exit
      end
      opts.on_tail('-v', '--version', 'Display Globetrotter version') do |o|
        puts "Globetrotter #{Globetrotter::VERSION}"
        exit
      end
    end # opt_parser

    opt_parser.parse!(args)

    options
  end # parse()
end # class Globetrotter Options

options = GlobetrotterOptions.parse(ARGV)
gt = Globetrotter.new(options)
gt.run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
globetrotter-0.0.6 bin/globetrotter