Class: Schatz::Output::CMD

Inherits:
Out
  • Object
show all
Defined in:
lib/schatz/output/cmd.rb

Instance Attribute Summary

Attributes inherited from Out

#options

Instance Method Summary collapse

Methods inherited from Out

#generate

Constructor Details

#initialize(options = {}) ⇒ CMD

Returns a new instance of CMD.



4
5
6
# File 'lib/schatz/output/cmd.rb', line 4

def initialize(options={})
  @options = options
end

Instance Method Details

#direct(connection) ⇒ Object



18
19
20
21
# File 'lib/schatz/output/cmd.rb', line 18

def direct(connection)
 color = connection.result == "open" ? :green : :red
 puts (connection.host+" "+connection.port.to_s+" "+connection.scheme).foreground(color)
end


23
24
25
26
27
# File 'lib/schatz/output/cmd.rb', line 23

def link(connection)
  codes = %w(403 302 200)
  color = codes.include?(connection.result) ? :green : :red
  puts (connection.scheme+"://"+connection.host+" "+connection.port.to_s+" via "+ connection.proxy).foreground(color)
end


7
8
9
10
11
12
13
14
15
16
# File 'lib/schatz/output/cmd.rb', line 7

def print(connection)
  case connection.scheme
      when "tcp" 
        direct(connection)
      when "http"
        link(connection)
      when "https"
        link(connection)
  end
end