Class: Ronin::CLI::Commands::TldList Private

Inherits:
Ronin::CLI::Command show all
Includes:
CommandKit::Options::Verbose, Core::CLI::Logging, Support::Network::TLD
Defined in:
lib/ronin/cli/commands/tld_list.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Updates and parses the TLD list file.

Usage

ronin tld-list [options]

Options

-v, --verbose                    Enables verbose output
-u, --update                     Updates the TLD list file
-U, --url URL                    URL to the TLD list (Default: https://data.iana.org/TLD/tlds-alpha-by-domain.txt)
-p, --path FILE                  Path to the TLD list file (Default: ~/.cache/ronin/ronin-support/tlds-alpha-by-domain.txt)
-h, --help                       Print help information

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#downloadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Downloads the TLD list file.

Since:

  • 2.0.0



112
113
114
115
116
117
118
# File 'lib/ronin/cli/commands/tld_list.rb', line 112

def download
  if verbose?
    log_info "Downloading TLD list from #{options[:url]} to #{options[:path]} ..."
  end

  List.download(url: options[:url], path: options[:path])
end

#downloaded?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Determines if the TLD list file has been downloaded already.

Returns:

  • (Boolean)

Since:

  • 2.0.0



96
97
98
# File 'lib/ronin/cli/commands/tld_list.rb', line 96

def downloaded?
  List.downloaded?(options[:path])
end

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs the ronin tld-list command.

Since:

  • 2.0.0



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ronin/cli/commands/tld_list.rb', line 77

def run
  if !downloaded?
    download
  elsif options[:update] || stale?
    update
  end

  list_file = List.load_file(options[:path])

  list_file.each do |tld|
    puts tld
  end
end

#stale?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Determines if the TLD list file is stale.

Returns:

  • (Boolean)

Since:

  • 2.0.0



105
106
107
# File 'lib/ronin/cli/commands/tld_list.rb', line 105

def stale?
  List.stale?(options[:path])
end

#updateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Updates the TLD list file.

Since:

  • 2.0.0



123
124
125
126
127
128
129
# File 'lib/ronin/cli/commands/tld_list.rb', line 123

def update
  if verbose?
    log_info "Updating TLD list file #{options[:path]} ..."
  end

  List.update(path: options[:path])
end