class Yawast::Scanner::Plugins::Spider::Spider

Public Class Methods

spider(uri, silent = false) click to toggle source
# File lib/scanner/plugins/spider/spider.rb, line 10
def self.spider(uri, silent = false)
  @uri = uri.copy

  @workers = []
  @results = Queue.new

  @links = []
  @links.push @uri.to_s
  puts 'Spidering site...' unless silent
  get_links @uri

  results = Thread.new do
    begin
      while true
        if @results.length.positive?
          out = @results.pop(true)

          Yawast::Utilities.puts_info out unless silent

          Yawast::Shared::Output.log_append_value 'spider', 'get', out
        end
      end
    rescue ThreadError # rubocop:disable Lint/HandleExceptions
      # do nothing
    end
  end

  @workers.map(&:join)
  results.terminate

  puts

  @links
end